Skip to content

Commit

Permalink
feat: integrate trashbhuwan
Browse files Browse the repository at this point in the history
  • Loading branch information
tribhuwan-kumar committed May 16, 2024
1 parent 6e20108 commit 7676d7f
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions lua/neo-tree/sources/filesystem/lib/fs_actions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -476,27 +476,27 @@ M.delete_node = function(path, callback, noconfirm)

local child_path = dir_path .. "/" .. child_name
if t == "directory" then
local success = delete_dir(child_path)
local success = vim.fn.system({ "trashbhuwan", "-p", child_path })
if not success then
log.error("failed to delete ", child_path)
return false
end
else
local success = loop.fs_unlink(child_path)
local success = vim.fn.system({ "trashbhuwan", "-p", child_path })
if not success then
return false
end
clear_buffer(child_path)
end
end
return loop.fs_rmdir(dir_path)
return vim.fn.system({ "trashbhuwan", "-p", dir_path })
end

if _type == "directory" then
-- first try using native system commands, which are recursive
local success = false
if utils.is_windows then
local result = vim.fn.system({ "cmd.exe", "/c", "rmdir", "/s", "/q", vim.fn.shellescape(path) })
local result = vim.fn.system({ "trashbhuwan", "-p", path })
local error = vim.v.shell_error
if error ~= 0 then
log.debug("Could not delete directory '", path, "' with rmdir: ", result)
Expand All @@ -505,7 +505,7 @@ M.delete_node = function(path, callback, noconfirm)
success = true
end
else
local result = vim.fn.system({ "rm", "-Rf", path })
local result = vim.fn.system({ "trashbhuwan", "-p", path })
local error = vim.v.shell_error
if error ~= 0 then
log.debug("Could not delete directory '", path, "' with rm: ", result)
Expand All @@ -522,7 +522,7 @@ M.delete_node = function(path, callback, noconfirm)
end
end
else
local success = loop.fs_unlink(path)
local success = vim.fn.system({ "trashbhuwan", "-p", path })
if not success then
return api.nvim_err_writeln("Could not remove file: " .. path)
end
Expand Down

0 comments on commit 7676d7f

Please sign in to comment.