Skip to content

feat(watcher): add filesystem_watchers.ignore_dirs #1705

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions doc/nvim-tree-lua.txt
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,7 @@ Subsequent calls to setup will replace the previous configuration.
filesystem_watchers = {
enable = true,
debounce_delay = 50,
ignore_dirs = {},
},
git = {
enable = true,
Expand Down Expand Up @@ -601,6 +602,12 @@ performance.
Idle milliseconds between filesystem change and action.
Type: `number`, Default: `50` (ms)

*nvim-tree.filesystem_watchers.ignore_dirs*
List of vim regex for absolute directory paths that will not be watched.
Backslashes must be escaped e.g. `"my-project/\\.build$"`. See |string-match|.
Useful when path is not in `.gitignore` or git integration is disabled.
Type: {string}, Default: `{}`

*nvim-tree.on_attach*
Function ran when creating the nvim-tree buffer.
This can be used to attach keybindings to the tree buffer.
Expand Down
1 change: 1 addition & 0 deletions lua/nvim-tree.lua
Original file line number Diff line number Diff line change
Expand Up @@ -589,6 +589,7 @@ local DEFAULT_OPTS = { -- BEGIN_DEFAULT_OPTS
filesystem_watchers = {
enable = true,
debounce_delay = 50,
ignore_dirs = {},
},
git = {
enable = true,
Expand Down
8 changes: 8 additions & 0 deletions lua/nvim-tree/explorer/watch.lua
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,13 @@ local function is_folder_ignored(path)
return true
end
end

for _, ignore_dir in ipairs(M.ignore_dirs) do
if vim.fn.match(path, ignore_dir) ~= -1 then
return true
end
end

return false
end

Expand Down Expand Up @@ -78,6 +85,7 @@ end
function M.setup(opts)
M.enabled = opts.filesystem_watchers.enable
M.debounce_delay = opts.filesystem_watchers.debounce_delay
M.ignore_dirs = opts.filesystem_watchers.ignore_dirs
M.uid = 0
end

Expand Down