telescope-pathogen.nvim is a telescope extension to help you to navigate through different path when using builtin actions from telescope such as grep_string, find_files and live_grep.
- builtin action
grep_stringsearches string(word under cursor or visual selection) within current working directory. If there is nothing found for what you want, and you want to search the same string within parent directory, you need close the ui and launch anothergrep_stringwith parent directory specified incwd. Withpathogen grep_stringfrom this extension, to pressC-oto search within an outer directory(aka the parent different) for the same string, you can pressC-oagain and again until it reaches at the right ancestor directory. PressC-lto revert back to the last directory.
-
a worse case is that there is nothing found for what you want along the path from current working directory to the ancestor directory you picked. You want to search it within sibling folders or grand sibling folders(not sure if you can understand what I mean, maybe there is a better term to describe it), press
C-bto call out the file browser to choose a directory. -
the same for
find_filesandlive_grep.
-
consider to use builtin action
find_filesto locate a file that you have its path(or partly) in a directory with millions of files or directories, you cannot quickly locate your target file though the telescope ui is considerably smooth.pathogen browse_fileis for the case, with which you can pick up it by entering the path level by level. Or at least, you can useC-fto triggerfind_filesin a deeper directory which will have less files. If the directory is still too large to have your file be found byfind_files, pressC-bto bring back file browser to navigate manually or enter another deeper directory toC-f. -
C-yin the popup forgrep_stringto toggle exact word matches. -
grep_in_fileshelps to grep a string in a specified file list. It will launch a popup first for you to edit the file list, then<Cr>to continue with same UI aslive_grepor<Esc>to abort.
- Continuous search to help you continuously search in previous search result to generate a new result which should include or exclude another pattern, which works for both
live_grepandgrep_string.Ctrl-g ito initiate another search(invert grep) among the previous results to exclude another pattern.Ctrl-g gto initiate another search(grep) among the previous results to include another pattern.Ctrl-bto go back to previous search.
A quick ui within telescope to pick up file or directory.
CRpick up the file or directory.Tabpick up the file or directory.,edit current working directory.C-onavigate to parent directory.C-etriggerlive_grepwithin picked directory.C-ftriggerfind_fileswithin picked directory.C-g ccopy current selection to another file or create a new file.C-g ddelete current selection.C-g topen terminal from current working directory.
A swift way to switch buffer or pick recently opened file, use Telescope pathogen quick_buffer to launch it, which will list current buffers and some recently opened files, with each prefixed with a label. You can then press the labelled key(s) to switch to a buffer or open a file, if a key not from the labels are pressed, Telescope oldfiles will be launched for you to search old files.
The idea comes from Switch tabs feature of Surfingkeys.
Use lazy.nvim
{
"nvim-telescope/telescope.nvim",
dependencies = {
{ "telescope-pathogen.nvim" },
},
config = function()
require("telescope").setup({
extensions = {
["pathogen"] = {
attach_mappings = function(map, actions)
map("i", "<C-o>", actions.proceed_with_parent_dir)
map("i", "<C-l>", actions.revert_back_last_dir)
map("i", "<C-b>", actions.change_working_directory)
map("i", "<C-g>g", actions.grep_in_result)
map("i", "<C-g>i", actions.invert_grep_in_result)
end,
-- remove below if you want to enable it
use_last_search_for_live_grep = false,
-- quick_buffer_characters = "asdfgqwertzxcvb",
prompt_prefix_length = 100,
-- uses a relative path instead of the full path
relative_prompt_path = false,
-- customize the prompt suffix after the path
prompt_suffix = "» "
}
},
})
require("telescope").load_extension("pathogen")
vim.keymap.set('v', '<space>g', require("telescope").extensions["pathogen"].grep_string)
end,
keys = {
{ "<space>a", ":Telescope pathogen live_grep<CR>", silent = true },
{ "<C-p>", ":Telescope pathogen<CR>", silent = true },
{ "<C-f>", ":Telescope pathogen find_files<CR>", silent = true },
{ "<space>g", ":Telescope pathogen grep_string<CR>", silent = true },
}
}





