Skip to content

feat(#3292): add nvim_tree.config.filesystem_watchers.whitelist_dirs - strongly recommended for windows#3298

Merged
alex-courtis merged 3 commits intomasterfrom
fix/3292
Mar 25, 2026
Merged

feat(#3292): add nvim_tree.config.filesystem_watchers.whitelist_dirs - strongly recommended for windows#3298
alex-courtis merged 3 commits intomasterfrom
fix/3292

Conversation

@alex-courtis
Copy link
Copy Markdown
Member

Adds a watcher whitelist.

@andriysavin I'd be most grateful if you thoroughly tested the fix branch

cd /path/to/nvim-tree.lua
git pull
git checkout fix/3292

When you're finished testing:

git checkout master

@andriysavin
Copy link
Copy Markdown

Thanks, I'm looking. Have a silly question: are white-listed directories (as well as ignored directories) supposed to be plain paths or patterns? I'm asking because matching doesn't seem to work (everything is ignored regardless of whitelist). I see you're using vim.fn.match(p, dir), and I believe it expects regex as second parameter. For instance, :lua=vim.fn.match("E:\\Code", "E:\\Code") returns -1, and this is exactly how whitelisted directories are matched.

@alex-courtis
Copy link
Copy Markdown
Member Author

Thanks, I'm looking. Have a silly question: are white-listed directories (as well as ignored directories) supposed to be plain paths or patterns? I'm asking because matching doesn't seem to work (everything is ignored regardless of whitelist). I see you're using vim.fn.match(p, dir), and I believe it expects regex as second parameter. For instance, :lua=vim.fn.match("E:\\Code", "E:\\Code") returns -1, and this is exactly how whitelisted directories are matched.

They're patterns, as are {ignore_dirs}. I wasn't really clear in the help, I'll polish that a bit.

We need double escapes for backslashes: #3178 (comment)

This case is a problem:

local expr = 'E:\\Code';

local pat = 'E:\\\\Code';

local ret = vim.fn.match(expr, pat)

print(expr .. " " .. pat .. " match ret=" .. ret)

local pat2 = 'E:\\Code';

local ret2 = vim.fn.match(expr, pat2)

print(expr .. " " .. pat2 .. " NO match ret2=" .. ret2)
E:\Code E:\\Code match ret=0
E:\Code E:\Code NO match ret2=-1

@alex-courtis
Copy link
Copy Markdown
Member Author

@andriysavin
Copy link
Copy Markdown

Thanks, with double escaping the path works well.

I've been using the whitelist throughout the day and it does the job! I don't see any unusual memory allocation when browsing non-whitelisted locations. This doesn't fix watcher digging whitelisted dirs, but at least in those dirs not that many events happen to cause memory growth.

And updated docs look great, thanks again!

@alex-courtis
Copy link
Copy Markdown
Member Author

Thanks, with double escaping the path works well.

I've been using the whitelist throughout the day and it does the job! I don't see any unusual memory allocation when browsing non-whitelisted locations. This doesn't fix watcher digging whitelisted dirs, but at least in those dirs not that many events happen to cause memory growth.

And updated docs look great, thanks again!

Thanks for the thorough testing, merging.

You can add more {ignore_dirs} that will be still obeyed inside whitelisted. I've had to add a few over the years.

@alex-courtis alex-courtis changed the title feat(#3292): add nvim_tree.config.filesystem_watchers.whitelist_dirs feat(#3292): add nvim_tree.config.filesystem_watchers.whitelist_dirs - strongly recommended for windows Mar 25, 2026
@alex-courtis alex-courtis merged commit 6eaf74c into master Mar 25, 2026
5 checks passed
@alex-courtis alex-courtis deleted the fix/3292 branch March 25, 2026 23:40
@andriysavin
Copy link
Copy Markdown

Great, thanks for your work!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants