[Feature] fzf content of files in the dir under the cursor #1257
Answered
by
cseickel
LintaoAmons
asked this question in
Q&A
-
So, I want to have some shortcut to trigger maybe a telescope fzf window to search the content inside the files of dir under the current cursor. |
Beta Was this translation helpful? Give feedback.
Answered by
cseickel
Dec 10, 2023
Replies: 1 comment 2 replies
-
You know, I want that too so I just wrote a custom mapping for it. You can put this in your config: require("neo-tree").setup({
filesystem = {
window = {
mappings = {
["g"] = function(state)
-- get the current node
local node = state.tree:get_node()
-- if the node is not a directory, walk up the tree until we find one
while node and node.type ~= 'directory' do
local parent_id = node:get_parent_id()
if parent_id == nil then
-- we must have reached the root node
-- this should not happen because the root node is always a directory
-- but just in case...
node = nil
break
end
node = state.tree:get_node(parent_id)
end
-- if we somehow didn't find a directory, just use the root node
local path = node and node.path or state.path
require('telescope.builtin').live_grep({
search_dirs = { path },
prompt_title = string.format('Grep in [%s]', vim.fs.basename(path)),
})
end,
}
}
}
}) |
Beta Was this translation helpful? Give feedback.
2 replies
Answer selected by
LintaoAmons
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You know, I want that too so I just wrote a custom mapping for it. You can put this in your config: