From e33750c6612e645ab3ca934cc936ccc02f0b4690 Mon Sep 17 00:00:00 2001 From: Ariel D'Alessandro Date: Sat, 21 Jan 2023 23:05:43 +0100 Subject: feat: fix snippets reload, add telescope actions for plugins and config --- lua/alpha/scratchs/sample.lua | 37 ++++++++++++++++++++++++++----------- 1 file changed, 26 insertions(+), 11 deletions(-) (limited to 'lua/alpha/scratchs/sample.lua') 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('') - 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 :,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", "", 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() -- cgit v1.2.3