mirror of
https://github.com/folke/snacks.nvim
synced 2025-08-04 10:49:08 +00:00
feat(picker): added exclude option for files and grep. Closes #581
This commit is contained in:
parent
5ab2621d81
commit
192fb31c4b
3 changed files with 20 additions and 0 deletions
|
@ -116,6 +116,7 @@ M.diagnostics_buffer = {
|
|||
---@field ignored? boolean show ignored files
|
||||
---@field dirs? string[] directories to search
|
||||
---@field follow? boolean follow symlinks
|
||||
---@field exclude? string[] exclude patterns
|
||||
M.files = {
|
||||
finder = "files",
|
||||
format = "file",
|
||||
|
@ -198,6 +199,7 @@ M.git_diff = {
|
|||
---@field regex? boolean use regex search pattern (defaults to `true`)
|
||||
---@field buffers? boolean search in open buffers
|
||||
---@field need_search? boolean require a search pattern
|
||||
---@field exclude? string[] exclude patterns
|
||||
M.grep = {
|
||||
finder = "grep",
|
||||
format = "file",
|
||||
|
|
|
@ -30,6 +30,19 @@ local function get_cmd(opts, filter)
|
|||
args = vim.deepcopy(args)
|
||||
local is_fd, is_fd_rg, is_find, is_rg = cmd == "fd" or cmd == "fdfind", cmd ~= "find", cmd == "find", cmd == "rg"
|
||||
|
||||
-- exclude
|
||||
for _, e in ipairs(opts.exclude or {}) do
|
||||
if is_fd then
|
||||
vim.list_extend(args, { "-E", e })
|
||||
elseif is_rg then
|
||||
vim.list_extend(args, { "-g", "!" .. e })
|
||||
elseif is_find then
|
||||
table.insert(args, "-not")
|
||||
table.insert(args, "-path")
|
||||
table.insert(args, e)
|
||||
end
|
||||
end
|
||||
|
||||
-- hidden
|
||||
if opts.hidden and is_fd_rg then
|
||||
table.insert(args, "--hidden")
|
||||
|
|
|
@ -26,6 +26,11 @@ local function get_cmd(opts, filter)
|
|||
|
||||
args = vim.deepcopy(args)
|
||||
|
||||
-- exclude
|
||||
for _, e in ipairs(opts.exclude or {}) do
|
||||
vim.list_extend(args, { "-g", "!" .. e })
|
||||
end
|
||||
|
||||
-- hidden
|
||||
if opts.hidden then
|
||||
table.insert(args, "--hidden")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue