diff options
| author | Ariel D'Alessandro <dalessandro.ariel@gmail.com> | 2023-01-21 23:05:43 +0100 |
|---|---|---|
| committer | Ariel D'Alessandro <dalessandro.ariel@gmail.com> | 2023-01-21 23:05:43 +0100 |
| commit | e33750c6612e645ab3ca934cc936ccc02f0b4690 (patch) | |
| tree | 6fb5051c45b8ff5aa759e11053db937671f4629f /lua/alpha/scratchs/sample.lua | |
| parent | 221b69d165669371695842d12a85f338ac17ce47 (diff) | |
| download | nvim-conf-e33750c6612e645ab3ca934cc936ccc02f0b4690.tar.gz nvim-conf-e33750c6612e645ab3ca934cc936ccc02f0b4690.zip | |
feat: fix snippets reload, add telescope actions for plugins and config
Diffstat (limited to 'lua/alpha/scratchs/sample.lua')
| -rw-r--r-- | lua/alpha/scratchs/sample.lua | 37 |
1 files changed, 26 insertions, 11 deletions
diff --git a/lua/alpha/scratchs/sample.lua b/lua/alpha/scratchs/sample.lua index 80b0b77..415e9a2 100644 --- a/lua/alpha/scratchs/sample.lua +++ b/lua/alpha/scratchs/sample.lua @@ -1,14 +1,29 @@ -function reverse_current_word() - local line = vim.fn.getline('.') - local current_word = vim.fn.expand('<cword>') - local start_index = vim.fn.col('.') - #current_word + 1 - local reversed_word = current_word:reverse() - - local reversed_line = line:sub(1, start_index -1)..reversed_word..line:sub(start_index+#current_word) - P(reversed_line) - vim.fn.setline('.', reversed_line) +local M = {} + +local action_state = require("telescope.actions.state") +local actions = require('telescope.actions') + +M.find_config = function() + require("telescope.builtin").find_files({ + prompt_title = "< Neovim >", + cwd = "$HOME/.config/nvim/", + }) end -vim.api.nvim_command('command! -range=% ReverseWord :<line1>,<line2>lua reverse_current_word()') +M.find_plugin = function() + require("telescope.builtin").find_files({ + prompt_title = "< Plugins >", + cwd = "$HOME/.config/nvim/lua/alpha/plugins/", + attach_mappings = function(_, map) + map("i", "<C-t>", function(prompt_bufnr) + local new_plugin = action_state.get_current_line() + actions.close(prompt_bufnr) + vim.cmd(string.format("edit ~/.config/nvim/lua/alpha/plugins/%s.lua", new_plugin)) + end) + + return true + end, + }) +end --- testing +M.find_plugin() |