feat: nvim search in folder

This commit is contained in:
Klesh Wong 2022-07-13 23:14:12 +08:00
parent 495b112e1d
commit 7f4eb6db9b
3 changed files with 39 additions and 4 deletions

View File

@ -62,3 +62,4 @@ require("plugins/bufferline")
require("plugins/statusline")
require("plugins/comment")
require("plugins/tree")
require("plugins/searchinfolder")

View 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 = "?" })

View File

@ -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 = {}