* chore: add type annotations to (almost) all functions
* stylua
* Add classes for symlink nodes
* Replace deprecated `@vararg`
* Move node classes to `node` module
* Fix `Symlink*` classes
* add vim and libuv runtime for luals, qualify libuv types
* add scripts/luals-check, not quite ready for CI
* additional nil checks for git/init.lua and git/runner.lua
* additional nil checks for nvim-tree.lua
* wrap vim.cmd-as-a-function calls inside functions
* vim.tbl_filter predicate returns booleans
* Revert "add scripts/luals-check, not quite ready for CI"
This reverts commit c70229cad9.
* Add `MinimalNode` class in `marks` module
* Fix various LSP warnings
* stylua
* Fix `Explorer` class, update related annotations and add necessary checks
* Add missing annotations to `live-filter`
* Add temporary aliases for `uv.*` types
* Resolve remaining LSP warnings
* Revert changes not related to internal types
* Minor adjustments
* Update doc comments style
* Minor adjustments (pt. 2)
---------
Co-authored-by: Alexander Courtis <alex@courtis.org>
48 lines
1.1 KiB
Lua
48 lines
1.1 KiB
Lua
local marks = require "nvim-tree.marks"
|
|
local utils = require "nvim-tree.utils"
|
|
local remove_file = require "nvim-tree.actions.fs.trash"
|
|
local notify = require "nvim-tree.notify"
|
|
local lib = require "nvim-tree.lib"
|
|
|
|
local M = {
|
|
config = {},
|
|
}
|
|
|
|
--- Delete nodes; each removal will be optionally notified
|
|
---@param nodes Node[]
|
|
local function do_trash(nodes)
|
|
for _, node in pairs(nodes) do
|
|
remove_file.remove(node)
|
|
end
|
|
|
|
marks.clear_marks()
|
|
end
|
|
|
|
function M.bulk_trash()
|
|
local nodes = marks.get_marks()
|
|
if not nodes or #nodes == 0 then
|
|
notify.warn "No bookmarks to trash."
|
|
return
|
|
end
|
|
|
|
if M.config.ui.confirm.trash then
|
|
local prompt_select = "Trash bookmarked ?"
|
|
local prompt_input = prompt_select .. " y/N: "
|
|
lib.prompt(prompt_input, prompt_select, { "", "y" }, { "No", "Yes" }, function(item_short)
|
|
utils.clear_prompt()
|
|
if item_short == "y" then
|
|
do_trash(nodes)
|
|
end
|
|
end)
|
|
else
|
|
do_trash(nodes)
|
|
end
|
|
end
|
|
|
|
function M.setup(opts)
|
|
M.config.ui = opts.ui
|
|
M.config.filesystem_watchers = opts.filesystem_watchers
|
|
end
|
|
|
|
return M
|