Skip to content

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`.

Notifications You must be signed in to change notification settings

brookhong/telescope-pathogen.nvim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 

Repository files navigation

✨ telescope-pathogen.nvim

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.

⚡️ Usage scenarios

  • builtin action grep_string searches 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 another grep_string with parent directory specified in cwd. With pathogen grep_string from this extension, to press C-o to search within an outer directory(aka the parent different) for the same string, you can press C-o again and again until it reaches at the right ancestor directory. Press C-l to revert back to the last directory.

a

  • 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-b to call out the file browser to choose a directory.

  • the same for find_files and live_grep.

b

c

  • consider to use builtin action find_files to 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_file is for the case, with which you can pick up it by entering the path level by level. Or at least, you can use C-f to trigger find_files in a deeper directory which will have less files. If the directory is still too large to have your file be found by find_files, press C-b to bring back file browser to navigate manually or enter another deeper directory to C-f.

  • C-y in the popup for grep_string to toggle exact word matches.

  • grep_in_files helps 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 as live_grep or <Esc> to abort.

grep_in_files

  • 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_grep and grep_string.
    • Ctrl-g i to initiate another search(invert grep) among the previous results to exclude another pattern.
    • Ctrl-g g to initiate another search(grep) among the previous results to include another pattern.
    • Ctrl-b to go back to previous search.

Showcase on Youtube

file browser

A quick ui within telescope to pick up file or directory.

  • CR pick up the file or directory.
  • Tab pick up the file or directory.
  • , edit current working directory.
  • C-o navigate to parent directory.
  • C-e trigger live_grep within picked directory.
  • C-f trigger find_files within picked directory.
  • C-g c copy current selection to another file or create a new file.
  • C-g d delete current selection.
  • C-g t open terminal from current working directory.

d

quick buffer

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.

quick_buffer

📦 Installation

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
                }
            },
        })
        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 },
    }
}

About

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`.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published