Skip to content

Commit cf79942

Browse files
committed
Add search_dirs option
1 parent 7de3bae commit cf79942

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,12 @@ Call live grep args:
7272

7373
## Usage
7474

75+
### Options
76+
77+
| Name | Description |
78+
| --- | --- |
79+
| `search_dirs` | Directory/directories/files to search. Paths are expanded and appended to the grep command. |
80+
7581
### Grep argument examples
7682

7783
(Some examples are ripgrep specific)

lua/telescope/_extensions/live_grep_args.lua

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,12 @@ local live_grep_args = function(opts)
3333
opts.entry_maker = opts.entry_maker or make_entry.gen_from_vimgrep(opts)
3434
opts.cwd = opts.cwd and vim.fn.expand(opts.cwd)
3535

36+
if opts.search_dirs then
37+
for i, path in ipairs(opts.search_dirs) do
38+
opts.search_dirs[i] = vim.fn.expand(path)
39+
end
40+
end
41+
3642
local cmd_generator = function(prompt)
3743
if not prompt or prompt == "" then
3844
return nil
@@ -41,7 +47,7 @@ local live_grep_args = function(opts)
4147
local args = tbl_clone(opts.vimgrep_arguments)
4248
local prompt_parts = prompt_parser.parse(prompt, opts.auto_quoting)
4349

44-
local cmd = vim.tbl_flatten { args, prompt_parts }
50+
local cmd = vim.tbl_flatten { args, prompt_parts, opts.search_dirs }
4551
return cmd
4652
end
4753

0 commit comments

Comments
 (0)