Skip to content

Commit ac90664

Browse files
committed
fix(watchers): disable watchers on kernel filesystems
fixes #1465
1 parent 2928f8f commit ac90664

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

Diff for: lua/nvim-tree/explorer/watch.lua

+18-1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,23 @@ local function is_git(path)
2222
return path:match "%.git$" ~= nil or path:match(utils.path_add_trailing ".git") ~= nil
2323
end
2424

25+
local IGNORED_PATHS = {
26+
-- disable watchers on kernel filesystems
27+
-- which have a lot of unwanted events
28+
"/sys",
29+
"/proc",
30+
"/dev",
31+
}
32+
33+
local function is_folder_ignored(path)
34+
for _, folder in ipairs(IGNORED_PATHS) do
35+
if vim.startswith(path, folder) then
36+
return true
37+
end
38+
end
39+
return false
40+
end
41+
2542
local function refresh_path(path)
2643
log.line("watcher", "node event executing '%s'", path)
2744
local n = utils.get_node_from_path(path)
@@ -41,7 +58,7 @@ function M.create_watcher(absolute_path)
4158
if not M.enabled then
4259
return nil
4360
end
44-
if is_git(absolute_path) then
61+
if is_git(absolute_path) or is_folder_ignored(absolute_path) then
4562
return nil
4663
end
4764

0 commit comments

Comments
 (0)