Skip to content

Telescope extension that uses Telescope builtins (live_grep or grep_string) to grep through help files

Notifications You must be signed in to change notification settings

catgoose/telescope-helpgrep.nvim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 

Repository files navigation

Telescope helpgrep

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

Using help

help
Searching for help the help topic: vim.api.nvim_open_win using :help
Telescope helptags
Searching for help the help topic: vim.api.nvim_open_win using :Telescope help_tags
Telescope helpgrep
Grepping through help files for vim.api.nvim_open_win with :Telescope helpgrep

Alternative

Of course you can use the built in helpgrep, but I wanted something more "Telescopic" rather than having to filter through quickfix.

Usage

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

Default picker options

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

Setup

ignore_paths defines which paths will be ignored by helpgrep mappings defines mappings overrides

Defaults

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

Example

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

TODO

  • Set win/buffer optsions for help window, configurable by setup opts

Extra

My other neovim projects

About

Telescope extension that uses Telescope builtins (live_grep or grep_string) to grep through help files

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages