Telescope extension that uses Telescope builtins (live_grep
or grep_string
)
to grep through help files
Sometimes help tags are not available for what you are looking for with
Telescope help_tags
or :help
. Telescope helpgrep can be used to grep through
help files using Telescope's builtins
Searching for help the help topic: vim.api.nvim_open_win using :help |
Searching for help the help topic: vim.api.nvim_open_win using :Telescope help_tags |
Grepping through help files for vim.api.nvim_open_win with :Telescope helpgrep |
Of course you can use the built in helpgrep
, but I wanted something more
"Telescopic" rather than having to filter through quickfix.
Defaults to live_grep
picker:
:Telescope helpgrep
Uses Telescope live_grep
builtin:
:Telescope helpgrep live_grep
Uses Telescope grep_string
builtin:
:Telescope helpgrep grep_string
These are the default options passed into the Telescope picker
{
prompt_title = "Help Grep",
glob_pattern = "*.txt",
disable_coordinates = true,
path_display = { "tail" },
}
These options can be overridden by passing opts table into live_grep
or grep_string
:help telescope.builtin.live_grep
and :help telescope.builtin.grep_string
require("telescope-helpgrep").live_grep({
prompt_title = "Helpy McGrepperson",
...,
})
require("telescope-helpgrep").grep_string({
prompt_title = "grep_string",
...,
})
ignore_paths
defines which paths will be ignored by helpgrep
mappings
defines mappings overrides
local actions = require("telescope.actions")
local builtin = require("telescope.builtin")({
ignore_paths = {},
mappings = {
i = {
["<CR>"] = actions.select_tab,
},
n = {
["<CR>"] = actions.select_tab,
},
},
default_grep = builtin.live_grep,
})
In Telescope setup:
local actions = require("telescope.actions")
local builtin = require("telescope.builtin")
telescope.setup({
...
extensions = {
helpgrep = {
ignore_paths = {
vim.fn.stdpath("state") .. "/lazy/readme",
},
mappings = {
i = {
["<CR>"] = actions.select_default,
["<C-v>"] = actions.select_vertical,
},
n = {
["<CR>"] = actions.select_default,
["<C-s>"] = actions.select_horizontal,
}
},
default_grep = builtin.live_grep,
}
}
})
require("telescope").load_extension("helpgrep")
No paths are ignored by default, but if you use lazy.nvim
it is recommended
to add vim.fn.stdpath("state") .. "/lazy/readme"
to the ignore_paths
table
- Set win/buffer optsions for help window, configurable by setup opts
My other neovim projects