Skip to content

Commit 3f0f71a

Browse files
committed
Live grep with arguments
The motivation to include this was to be able to exclude test files from my search like this: "search term" -g "!test"
1 parent 9d05f8f commit 3f0f71a

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

lua/plugins/telescope.lua

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ return { -- Fuzzy Finder (files, lsp, etc)
2020

2121
-- Useful for getting pretty icons, but requires a Nerd Font.
2222
{ 'nvim-tree/nvim-web-devicons', enabled = vim.g.have_nerd_font },
23+
-- Useful for searching within a particular directory
24+
{ 'nvim-telescope/telescope-live-grep-args.nvim', version = '^1.0.0' },
2325
},
2426
config = function()
2527
-- Telescope is a fuzzy finder that comes with a lot of different things that
@@ -64,6 +66,7 @@ return { -- Fuzzy Finder (files, lsp, etc)
6466
-- Enable Telescope extensions if they are installed
6567
pcall(require('telescope').load_extension, 'fzf')
6668
pcall(require('telescope').load_extension, 'ui-select')
69+
pcall(require('telescope').load_extension, 'live_grep_args')
6770

6871
-- See `:help telescope.builtin`
6972
local builtin = require 'telescope.builtin'
@@ -94,6 +97,9 @@ return { -- Fuzzy Finder (files, lsp, etc)
9497
vim.keymap.set('n', '<leader>s.', builtin.oldfiles, { desc = '[S]earch Recent Files ("." for repeat)' })
9598
vim.keymap.set('n', '<leader><leader>', builtin.buffers, { desc = '[ ] Find existing buffers' })
9699

100+
local lga = require('telescope').extensions.live_grep_args
101+
vim.keymap.set('n', '<leader>sa', lga.live_grep_args, { desc = '[S]earch by Grep with [A]rgs, e.g. in certain dirs' })
102+
97103
-- Slightly advanced example of overriding default behavior and theme
98104
vim.keymap.set('n', '<leader>/', function()
99105
-- You can pass additional configuration to Telescope to change the theme, layout, etc.

0 commit comments

Comments
 (0)