feat: nvim search in folder
This commit is contained in:
parent
495b112e1d
commit
7f4eb6db9b
|
@ -62,3 +62,4 @@ require("plugins/bufferline")
|
|||
require("plugins/statusline")
|
||||
require("plugins/comment")
|
||||
require("plugins/tree")
|
||||
require("plugins/searchinfolder")
|
||||
|
|
25
cli/vim/neovim/lua/plugins/searchinfolder.lua
Normal file
25
cli/vim/neovim/lua/plugins/searchinfolder.lua
Normal file
|
@ -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 = "?" })
|
||||
|
|
@ -4,8 +4,17 @@ if not telescope_ok then
|
|||
end
|
||||
|
||||
-- telescope.load_extension "file_browser"
|
||||
local actions = require("telescope.actions")
|
||||
telescope.load_extension('media_files')
|
||||
telescope.setup({
|
||||
defaults = {
|
||||
mappings = {
|
||||
i = {
|
||||
["<C-u>"] = false,
|
||||
["<esc>"] = actions.close,
|
||||
},
|
||||
},
|
||||
},
|
||||
extensions = {
|
||||
-- file_browser = {}
|
||||
media_files = {}
|
||||
|
|
Loading…
Reference in New Issue
Block a user