Skip to content

Commit 00fd8ae

Browse files
authored
feat: filters.custom can specify regex (#1112)
1 parent 4d8ab7d commit 00fd8ae

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

doc/nvim-tree-lua.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,8 @@ Here is a list of the options available in the setup call:
405405
type: `boolean`
406406
default: `false`
407407

408-
- |filters.custom|: custom list of string that will not be shown.
408+
- |filters.custom|: custom list of vim regex for file/directory names that will not be shown.
409+
Backslashes must be escaped e.g. "^\\.git". See |string-match|.
409410
type: `{string}`
410411
default: `{}`
411412

lua/nvim-tree/explorer/filters.lua

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,10 @@ function M.should_ignore(path)
3535
end
3636

3737
local relpath = utils.path_relative(path, vim.loop.cwd())
38-
if M.ignore_list[relpath] == true or M.ignore_list[basename] == true then
39-
return true
38+
for pat, _ in pairs(M.ignore_list) do
39+
if vim.fn.match(relpath, pat) ~= -1 or vim.fn.match(basename, pat) ~= -1 then
40+
return true
41+
end
4042
end
4143

4244
local idx = path:match ".+()%.[^.]+$"

0 commit comments

Comments
 (0)