Skip to content

Commit

Permalink
fix(watchers): disable watchers on kernel filesystems
Browse files Browse the repository at this point in the history
fixes #1465
  • Loading branch information
kyazdani42 committed Jul 28, 2022
1 parent 2928f8f commit ac90664
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion lua/nvim-tree/explorer/watch.lua
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,23 @@ local function is_git(path)
return path:match "%.git$" ~= nil or path:match(utils.path_add_trailing ".git") ~= nil
end

local IGNORED_PATHS = {
-- disable watchers on kernel filesystems
-- which have a lot of unwanted events
"/sys",
"/proc",
"/dev",
}

local function is_folder_ignored(path)
for _, folder in ipairs(IGNORED_PATHS) do
if vim.startswith(path, folder) then
return true
end
end
return false
end

local function refresh_path(path)
log.line("watcher", "node event executing '%s'", path)
local n = utils.get_node_from_path(path)
Expand All @@ -41,7 +58,7 @@ function M.create_watcher(absolute_path)
if not M.enabled then
return nil
end
if is_git(absolute_path) then
if is_git(absolute_path) or is_folder_ignored(absolute_path) then
return nil
end

Expand Down

0 comments on commit ac90664

Please sign in to comment.