feat(event): add WillCreateFile, WillRemoveFile (#2273)
node. These are mostly going to be useful for implementing lsp file operation actions. Co-authored-by: Alexander Courtis <alex@courtis.org>
This commit is contained in:
@@ -9,6 +9,7 @@ local find_file = require("nvim-tree.actions.finders.find-file").fn
|
||||
local M = {}
|
||||
|
||||
local function create_and_notify(file)
|
||||
events._dispatch_will_create_file(file)
|
||||
local ok, fd = pcall(vim.loop.fs_open, file, "w", 420)
|
||||
if not ok then
|
||||
notify.error("Couldn't create file " .. file)
|
||||
|
||||
@@ -81,6 +81,7 @@ function M.remove(node)
|
||||
end
|
||||
events._dispatch_folder_removed(node.absolute_path)
|
||||
else
|
||||
events._dispatch_will_remove_file(node.absolute_path)
|
||||
local success = vim.loop.fs_unlink(node.absolute_path)
|
||||
if not success then
|
||||
return notify.error("Could not remove " .. node.name)
|
||||
|
||||
@@ -75,6 +75,7 @@ function M.fn(node)
|
||||
end
|
||||
end)
|
||||
else
|
||||
events._dispatch_will_remove_file(node.absolute_path)
|
||||
trash_path(function(_, rc)
|
||||
if rc ~= 0 then
|
||||
notify.warn("trash failed: " .. err_msg .. "; please see :help nvim-tree.trash")
|
||||
|
||||
Reference in New Issue
Block a user