Skip to content

Commit ed9db63

Browse files
authored
feat(watcher): add filesystem_watchers.ignore_dirs (#1705)
1 parent 33ce8e3 commit ed9db63

File tree

3 files changed

+16
-0
lines changed

3 files changed

+16
-0
lines changed

doc/nvim-tree-lua.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,7 @@ Subsequent calls to setup will replace the previous configuration.
308308
filesystem_watchers = {
309309
enable = true,
310310
debounce_delay = 50,
311+
ignore_dirs = {},
311312
},
312313
git = {
313314
enable = true,
@@ -604,6 +605,12 @@ performance.
604605
Idle milliseconds between filesystem change and action.
605606
Type: `number`, Default: `50` (ms)
606607

608+
*nvim-tree.filesystem_watchers.ignore_dirs*
609+
List of vim regex for absolute directory paths that will not be watched.
610+
Backslashes must be escaped e.g. `"my-project/\\.build$"`. See |string-match|.
611+
Useful when path is not in `.gitignore` or git integration is disabled.
612+
Type: {string}, Default: `{}`
613+
607614
*nvim-tree.on_attach*
608615
Function ran when creating the nvim-tree buffer.
609616
This can be used to attach keybindings to the tree buffer.

lua/nvim-tree.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -589,6 +589,7 @@ local DEFAULT_OPTS = { -- BEGIN_DEFAULT_OPTS
589589
filesystem_watchers = {
590590
enable = true,
591591
debounce_delay = 50,
592+
ignore_dirs = {},
592593
},
593594
git = {
594595
enable = true,

lua/nvim-tree/explorer/watch.lua

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,13 @@ local function is_folder_ignored(path)
3636
return true
3737
end
3838
end
39+
40+
for _, ignore_dir in ipairs(M.ignore_dirs) do
41+
if vim.fn.match(path, ignore_dir) ~= -1 then
42+
return true
43+
end
44+
end
45+
3946
return false
4047
end
4148

@@ -78,6 +85,7 @@ end
7885
function M.setup(opts)
7986
M.enabled = opts.filesystem_watchers.enable
8087
M.debounce_delay = opts.filesystem_watchers.debounce_delay
88+
M.ignore_dirs = opts.filesystem_watchers.ignore_dirs
8189
M.uid = 0
8290
end
8391

0 commit comments

Comments
 (0)