feat(#1804): add api.marks.bulk.delete with default bd mapping (#2276)

This commit is contained in:
Alexander Courtis
2023-06-18 14:09:11 +10:00
committed by GitHub
parent d4f6d33496
commit bdceaf5096
8 changed files with 93 additions and 24 deletions

View File

@@ -1,7 +1,7 @@
local Marks = require "nvim-tree.marks"
local Core = require "nvim-tree.core"
local marks = require "nvim-tree.marks"
local core = require "nvim-tree.core"
local utils = require "nvim-tree.utils"
local FsRename = require "nvim-tree.actions.fs.rename-file"
local rename_file = require "nvim-tree.actions.fs.rename-file"
local notify = require "nvim-tree.notify"
local M = {
@@ -9,12 +9,12 @@ local M = {
}
function M.bulk_move()
if #Marks.get_marks() == 0 then
notify.warn "no bookmark to perform bulk move on, aborting."
if #marks.get_marks() == 0 then
notify.warn "No bookmarks to move."
return
end
vim.ui.input({ prompt = "Move to: ", default = Core.get_cwd(), completion = "dir" }, function(location)
vim.ui.input({ prompt = "Move to: ", default = core.get_cwd(), completion = "dir" }, function(location)
utils.clear_prompt()
if not location or location == "" then
return
@@ -24,13 +24,15 @@ function M.bulk_move()
return
end
local marks = Marks.get_marks()
for _, node in pairs(marks) do
local nodes = marks.get_marks()
for _, node in pairs(nodes) do
local head = vim.fn.fnamemodify(node.absolute_path, ":t")
local to = utils.path_join { location, head }
FsRename.rename(node, to)
rename_file.rename(node, to)
end
marks.clear_marks()
if not M.config.filesystem_watchers.enable then
require("nvim-tree.actions.reloaders.reloaders").reload_explorer()
end