diff --git a/cli/vim/neovim/lua/plugins.lua b/cli/vim/neovim/lua/plugins.lua index f98e3e2..7a2586c 100644 --- a/cli/vim/neovim/lua/plugins.lua +++ b/cli/vim/neovim/lua/plugins.lua @@ -62,3 +62,4 @@ require("plugins/bufferline") require("plugins/statusline") require("plugins/comment") require("plugins/tree") +require("plugins/searchinfolder") diff --git a/cli/vim/neovim/lua/plugins/searchinfolder.lua b/cli/vim/neovim/lua/plugins/searchinfolder.lua new file mode 100644 index 0000000..1c81f1f --- /dev/null +++ b/cli/vim/neovim/lua/plugins/searchinfolder.lua @@ -0,0 +1,25 @@ +local nvim_tree_lib_ok, nvim_tree_lib = pcall(require, "nvim-tree/lib") +if not nvim_tree_lib_ok then + return +end +local telescope_builtin_ok, telescope_builtin = pcall(require, "telescope/builtin") +if not telescope_builtin_ok then + return +end + +function search_in_folder(folder_path) + if folder_path == "" then + folder = nvim_tree_lib.get_node_at_cursor() + if folder.fs_stat.type == "file" then + folder = folder.parent + end + folder_path = folder.absolute_path + end + telescope_builtin.live_grep{cwd = folder_path} + -- print(vim.inspect(folder_path)) +end + +vim.api.nvim_create_user_command("SearchInFolder", function(res) + search_in_folder(res.args) +end, { nargs = "?" }) + diff --git a/cli/vim/neovim/lua/plugins/telescope.lua b/cli/vim/neovim/lua/plugins/telescope.lua index 039f164..0ad02bc 100644 --- a/cli/vim/neovim/lua/plugins/telescope.lua +++ b/cli/vim/neovim/lua/plugins/telescope.lua @@ -4,10 +4,19 @@ if not telescope_ok then end -- telescope.load_extension "file_browser" +local actions = require("telescope.actions") telescope.load_extension('media_files') telescope.setup({ - extensions = { - -- file_browser = {} - media_files = {} - } + defaults = { + mappings = { + i = { + [""] = false, + [""] = actions.close, + }, + }, + }, + extensions = { + -- file_browser = {} + media_files = {} + } })