fix(#2240): disable watchers following EMFILE (#2268)

* fix(#2240): disable watchers following EMFILE

* fix(#2240): disable watchers following EMFILE
This commit is contained in:
Alexander Courtis
2023-06-18 11:42:48 +10:00
committed by GitHub
parent f873625d06
commit d4f6d33496
10 changed files with 101 additions and 65 deletions

View File

@@ -7,7 +7,9 @@ local notify = require "nvim-tree.notify"
local find_file = require("nvim-tree.actions.finders.find-file").fn
local M = {}
local M = {
config = {},
}
local clipboard = {
move = {},
@@ -175,7 +177,7 @@ local function do_paste(node, action_type, action_fn)
end
clipboard[action_type] = {}
if M.enable_reload then
if not M.config.filesystem_watchers.enable then
return require("nvim-tree.actions.reloaders.reloaders").reload_explorer()
end
end
@@ -226,7 +228,7 @@ function M.print_clipboard()
end
local function copy_to_clipboard(content)
if M.use_system_clipboard == true then
if M.config.actions.use_system_clipboard == true then
vim.fn.setreg("+", content)
vim.fn.setreg('"', content)
return notify.info(string.format("Copied %s to system clipboard!", content))
@@ -255,8 +257,8 @@ function M.copy_absolute_path(node)
end
function M.setup(opts)
M.use_system_clipboard = opts.actions.use_system_clipboard
M.enable_reload = not opts.filesystem_watchers.enable
M.config.filesystem_watchers = opts.filesystem_watchers
M.config.actions = opts.actions
end
return M

View File

@@ -96,8 +96,4 @@ function M.fn(node)
end)
end
function M.setup(opts)
M.enable_reload = not opts.filesystem_watchers.enable
end
return M

View File

@@ -4,7 +4,9 @@ local view = require "nvim-tree.view"
local lib = require "nvim-tree.lib"
local notify = require "nvim-tree.notify"
local M = {}
local M = {
config = {},
}
local function close_windows(windows)
if view.View.float.enable and #vim.api.nvim_list_wins() == 1 then
@@ -31,7 +33,7 @@ local function clear_buffer(absolute_path)
end
end
vim.api.nvim_buf_delete(buf.bufnr, { force = true })
if M.close_window then
if M.config.actions.remove_file.close_window then
close_windows(buf.windows)
end
return
@@ -90,7 +92,7 @@ function M.fn(node)
clear_buffer(node.absolute_path)
end
notify.info(node.absolute_path .. " was properly removed.")
if M.enable_reload then
if not M.config.filesystem_watchers.enable then
require("nvim-tree.actions.reloaders.reloaders").reload_explorer()
end
end
@@ -110,10 +112,9 @@ function M.fn(node)
end
function M.setup(opts)
M.config = {}
M.config.ui = opts.ui or {}
M.enable_reload = not opts.filesystem_watchers.enable
M.close_window = opts.actions.remove_file.close_window
M.config.ui = opts.ui
M.config.actions = opts.actions
M.config.filesystem_watchers = opts.filesystem_watchers
end
return M

View File

@@ -5,7 +5,9 @@ local notify = require "nvim-tree.notify"
local find_file = require("nvim-tree.actions.finders.find-file").fn
local M = {}
local M = {
config = {},
}
local ALLOWED_MODIFIERS = {
[":p:h"] = true,
@@ -83,7 +85,7 @@ function M.fn(default_modifier)
end
M.rename(node, prepend .. new_file_path .. append)
if M.enable_reload then
if not M.config.filesystem_watchers.enable then
require("nvim-tree.actions.reloaders.reloaders").reload_explorer()
end
@@ -93,7 +95,7 @@ function M.fn(default_modifier)
end
function M.setup(opts)
M.enable_reload = not opts.filesystem_watchers.enable
M.config.filesystem_watchers = opts.filesystem_watchers
end
return M

View File

@@ -1,7 +1,9 @@
local lib = require "nvim-tree.lib"
local notify = require "nvim-tree.notify"
local M = {}
local M = {
config = {},
}
local utils = require "nvim-tree.utils"
local events = require "nvim-tree.events"
@@ -68,7 +70,7 @@ function M.fn(node)
return
end
events._dispatch_folder_removed(node.absolute_path)
if M.enable_reload then
if not M.config.filesystem_watchers.enable then
require("nvim-tree.actions.reloaders.reloaders").reload_explorer()
end
end)
@@ -80,7 +82,7 @@ function M.fn(node)
end
events._dispatch_file_removed(node.absolute_path)
clear_buffer(node.absolute_path)
if M.enable_reload then
if not M.config.filesystem_watchers.enable then
require("nvim-tree.actions.reloaders.reloaders").reload_explorer()
end
end)
@@ -102,10 +104,9 @@ function M.fn(node)
end
function M.setup(opts)
M.config = {}
M.config.ui = opts.ui or {}
M.config.trash = opts.trash or {}
M.enable_reload = not opts.filesystem_watchers.enable
M.config.ui = opts.ui
M.config.trash = opts.trash
M.config.filesystem_watchers = opts.filesystem_watchers
end
return M

View File

@@ -6,7 +6,6 @@ function M.setup(opts)
require("nvim-tree.actions.node.file-popup").setup(opts)
require("nvim-tree.actions.node.open-file").setup(opts)
require("nvim-tree.actions.root.change-dir").setup(opts)
require("nvim-tree.actions.fs.create-file").setup(opts)
require("nvim-tree.actions.fs.rename-file").setup(opts)
require("nvim-tree.actions.fs.remove-file").setup(opts)
require("nvim-tree.actions.fs.copy-paste").setup(opts)