Skip to content

Commit bec98b4

Browse files
committed
feat(#3292): add nvim_tree.config.filesystem_watchers.whitelist_dirs
1 parent 23f2688 commit bec98b4

2 files changed

Lines changed: 26 additions & 21 deletions

File tree

doc/nvim-tree-lua.txt

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1695,25 +1695,27 @@ Config: filesystem_watchers *nvim-tree-config-filesystem-watchers*
16951695
With this feature, the tree will be partially updated on specific
16961696
directory changes, resulting in better performance.
16971697

1698-
Watchers may be disabled for absolute directory paths via {ignore_dirs}.
1699-
This may be useful when a path is not in `.gitignore` or git integration
1700-
is disabled.
1701-
• A list of |regular-expression| to match a path, backslash escaped e.g.
1702-
`"my-proj/\\.build$"` OR
1703-
• A function that is passed an absolute path and returns `true` to disable
1704-
1705-
Watchers may be enabled only for specific directories via
1706-
{whitelist_dirs}. When it is empty (default), watchers are enabled for all
1707-
directories. Uses same semantics as {ignore_dirs} except that the function
1708-
returns `true` to enable watchers for that path. This is strongly
1709-
recommended for windows: |nvim-tree-os-specific|.
1698+
Blacklist watching absolute directory paths via {ignore_dirs} and
1699+
optionally whitelist via {whitelist_dirs}:
1700+
• A table of |regular-expression| that will be passed to `vim.fn.match`
1701+
• Backslashes must be escaped e.g. `"my-proj/\\.build$"`
1702+
• Literal backslashes must be double escaped to avoid |/magic| e.g.
1703+
`"C:\\\\src\\\\my-proj"`
1704+
• OR a function that is passed an absolute path and returns:
1705+
• {ignore_dirs}: `true` to disable
1706+
{whitelist_dirs}: `true` to enable
1707+
1708+
{whitelist_dirs} is STRONGLY recommended for windows:
1709+
|nvim-tree-os-specific|.
17101710

17111711
After {max_events} consecutive filesystem events on a single directory
17121712
with an interval < {debounce_delay}:
17131713
• The filesystem watcher will be disabled for that directory.
17141714
• A warning notification will be shown.
17151715
• Consider adding this directory to {ignore_dirs}
17161716

1717+
By default, {max_events} is only enabled for windows.
1718+
17171719
Fields: ~
17181720
{enable}? (`boolean`) (default: `true`)
17191721
• {debounce_delay}? (`integer`, default: `50`) Idle milliseconds
@@ -1722,7 +1724,7 @@ Config: filesystem_watchers *nvim-tree-config-filesystem-watchers*
17221724
Disable for specific directories.
17231725
• {whitelist_dirs}? (`string[]|(fun(path: string): boolean)`, default:
17241726
`{}`) Optionally enable only for specific
1725-
directories, obeying {ignore_dirs}
1727+
directories.
17261728
• {max_events}? (`integer`, default: `0` or `1000` on windows)
17271729
Disable for a single directory after {max_events}
17281730
consecutive events with an interval <

lua/nvim-tree/_meta/config/filesystem_watchers.lua

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,23 @@ error("Cannot require a meta file")
77
---
88
---With this feature, the tree will be partially updated on specific directory changes, resulting in better performance.
99
---
10-
---Watchers may be disabled for absolute directory paths via {ignore_dirs}.
11-
---This may be useful when a path is not in `.gitignore` or git integration is disabled.
12-
--- - A list of [regular-expression] to match a path, backslash escaped e.g. `"my-proj/\\.build$"` OR
13-
--- - A function that is passed an absolute path and returns `true` to disable
10+
---Blacklist watching absolute directory paths via {ignore_dirs} and optionally whitelist via {whitelist_dirs}:
11+
---- A table of |regular-expression| that will be passed to `vim.fn.match`
12+
--- - Backslashes must be escaped e.g. `"my-proj/\\.build$"`
13+
--- - Literal backslashes must be double escaped to avoid |/magic| e.g. `"C:\\\\src\\\\my-proj"`
14+
---- OR a function that is passed an absolute path and returns:
15+
--- - {ignore_dirs}: `true` to disable
16+
--- - {whitelist_dirs}: `true` to enable
1417
---
15-
---Watchers may be enabled only for specific directories via {whitelist_dirs}. When it is empty (default), watchers are enabled for all directories.
16-
---Uses same semantics as {ignore_dirs} except that the function returns `true` to enable watchers for that path.
17-
---This is strongly recommended for windows: [nvim-tree-os-specific].
18+
---{whitelist_dirs} is STRONGLY recommended for windows: [nvim-tree-os-specific].
1819
---
1920
---After {max_events} consecutive filesystem events on a single directory with an interval < {debounce_delay}:
2021
---- The filesystem watcher will be disabled for that directory.
2122
---- A warning notification will be shown.
2223
---- Consider adding this directory to {ignore_dirs}
2324
---
25+
---By default, {max_events} is only enabled for windows.
26+
---
2427
---@class nvim_tree.config.filesystem_watchers
2528
---
2629
---(default: `true`)
@@ -34,7 +37,7 @@ error("Cannot require a meta file")
3437
---(default: `{ "/.ccls-cache", "/build", "/node_modules", "/target", "/.zig-cache"}`)
3538
---@field ignore_dirs? string[]|(fun(path: string): boolean)
3639
---
37-
---Optionally enable only for specific directories, obeying {ignore_dirs}
40+
---Optionally enable only for specific directories.
3841
---(default: `{}`)
3942
---@field whitelist_dirs? string[]|(fun(path: string): boolean)
4043
---

0 commit comments

Comments
 (0)