diff --git a/doc/nvim-tree-lua.txt b/doc/nvim-tree-lua.txt index 29565bc6b98..37136524b1c 100644 --- a/doc/nvim-tree-lua.txt +++ b/doc/nvim-tree-lua.txt @@ -1148,8 +1148,10 @@ Configuration options for trashing. *nvim-tree.trash.cmd* The command used to trash items (must be installed on your system). - The default is shipped with glib2 which is a common linux package. - Type: `string`, Default: `"gio trash"` + The default `"gio trash"` is shipped with glib2 which is a common linux package. + macOS default `"trash"` requires the homebrew package `trash` + Windows default `"trash"` requires `trash-cli` or similar + Type: `string`, Default: `"gio trash"` or `"trash"` *nvim-tree.actions* Configuration for various actions. @@ -2291,7 +2293,6 @@ vim.keymap.set("n", "ms", require("nvim-tree.api").marks.navigate.select 10. OS SPECIFIC RESTRICTIONS *nvim-tree-os-specific* macOS -- Trash is unavailable - Rename to different case is not possible when using a case insensitive file system. diff --git a/lua/nvim-tree.lua b/lua/nvim-tree.lua index d07a4870a5e..f1164a62175 100644 --- a/lua/nvim-tree.lua +++ b/lua/nvim-tree.lua @@ -669,6 +669,13 @@ local function validate_options(conf) end end +--- Apply OS specific localisations to DEFAULT_OPTS +local function localise_default_opts() + if utils.is_macos or utils.is_windows then + DEFAULT_OPTS.trash.cmd = "trash" + end +end + function M.purge_all_state() require("nvim-tree.watcher").purge_watchers() view.close_all_tabs() @@ -687,6 +694,8 @@ function M.setup(conf) M.init_root = vim.fn.getcwd() + localise_default_opts() + legacy.migrate_legacy_options(conf or {}) validate_options(conf) diff --git a/lua/nvim-tree/actions/fs/trash.lua b/lua/nvim-tree/actions/fs/trash.lua index 523beb50cb6..00124108ef7 100644 --- a/lua/nvim-tree/actions/fs/trash.lua +++ b/lua/nvim-tree/actions/fs/trash.lua @@ -29,22 +29,9 @@ function M.fn(node) return end - -- configs - if utils.is_unix or utils.is_windows then - if M.config.trash.cmd == nil then - M.config.trash.cmd = "trash" - end - if M.config.ui.confirm.trash == nil then - M.config.ui.confirm.trash = true - end - else - notify.warn "Trash is currently a UNIX only feature!" - return - end - local binary = M.config.trash.cmd:gsub(" .*$", "") if vim.fn.executable(binary) == 0 then - notify.warn(binary .. " is not executable.") + notify.warn(string.format("trash.cmd '%s' is not an executable.", M.config.trash.cmd)) return end