Skip to content

About

Live tgrep search for Neovim with the fff-plus.nvim picker

Topics

Resources

Stars

1 star

Watchers

1 watching

Forks

Latest commit

 

History

5 Commits

Folders and files

Repository files navigation

tgrep.nvim

Live tgrep search in Neovim, rendered by the fff-plus.nvim picker.

picker query
    │
    ▼
debounce and cancel stale work
    │
    ▼
tgrep --json ──► running server / local index / filesystem fallback
    │
    ▼
decode matches ──► fff-plus picker ──► file, split, tab, quickfix

Demo

tgrep.nvim searching its own source in Neovim

Running :Tgrep :Tgrep in Kitty searches this repository's README, tests, and help documentation.

Requirements

For indexed, continuously updated searches, start a server in the project:

tgrep serve .

The plugin still works without a server. The tgrep CLI uses an on-disk index when available and otherwise falls back to scanning the filesystem.

Installation

lazy.nvim

{
  'vinitkumar/tgrep.nvim',
  dependencies = {
    {
      'dmtrKovalenko/fff',
      build = function()
        require('fff.download').download_or_build_binary()
      end,
    },
    'vinitkumar/fff-plus.nvim',
  },
  cmd = 'Tgrep',
  opts = {},
  keys = {
    {
      '<leader>tg',
      function()
        require('tgrep').live_grep()
      end,
      desc = 'Tgrep project',
    },
    {
      '<leader>tw',
      function()
        require('tgrep').live_grep({ query = vim.fn.expand('<cword>') })
      end,
      desc = 'Tgrep word',
    },
  },
}

Usage

:Tgrep
:Tgrep function_name
:Tgrep! TODO|FIXME

:Tgrep! uses the fullscreen fff-plus layout. Searches begin after three characters by default because tgrep's index is trigram-based. Each new query cancels pending or active work before starting another search.

The picker inherits fff-plus controls, including:

Key Action
<CR> Open match
<C-s> Open in split
<C-v> Open in vertical split
<C-t> Open in tab
<C-p> / <C-n> Move up / down
<C-q> Send match to quickfix
<C-g>q Send match to location list
<C-/> Toggle preview
<F1> Show picker help

Configuration

require('tgrep').setup({
  binary = 'tgrep',
  debounce_ms = 80,
  min_chars = 3,
  smart_case = true,
  root_markers = { '.git' },
  args = {
    '--hidden',
    '--glob',
    '!vendor/**',
  },
  picker = {
    preview = { enabled = true },
    layout = {
      preview_position = 'right',
      preview_size = 0.5,
    },
  },
})

Per-call options override picker defaults:

require('tgrep').live_grep({
  cwd = '/path/to/project',
  query = 'SearchPattern',
  fullscreen = true,
})

Run :checkhealth tgrep to verify the executable and both picker dependencies.

Development

make test
make lint
make format-check

The integration test additionally requires real fff.nvim and fff-plus.nvim checkouts plus an installed tgrep executable:

make test-integration \
  FFF_PATH=/path/to/fff \
  FFF_PLUS_PATH=/path/to/fff-plus.nvim

Credits

tgrep.nvim integrates Microsoft's tgrep and renders its results with fff.nvim through fff-plus.nvim. It is an independent community plugin and is not affiliated with Microsoft.

License

MIT

About

Live tgrep search for Neovim with the fff-plus.nvim picker

Topics

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages