refactor: improve API readability and tidy actions submodules (#2593)

* refactor: improve API readability, tidy actions modules

* Apply requested changes

* `actions/reloaders/reloaders.lua` -> `actions/reloaders.lua`

---------

Co-authored-by: Alexander Courtis <alex@courtis.org>
This commit is contained in:
Azad 2023-12-31 05:52:27 +01:00 committed by GitHub
parent dc839a72a6
commit f779abaf2a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
20 changed files with 210 additions and 147 deletions

View File

@ -5,14 +5,12 @@ local renderer = require "nvim-tree.renderer"
local view = require "nvim-tree.view" local view = require "nvim-tree.view"
local commands = require "nvim-tree.commands" local commands = require "nvim-tree.commands"
local utils = require "nvim-tree.utils" local utils = require "nvim-tree.utils"
local change_dir = require "nvim-tree.actions.root.change-dir" local actions = require "nvim-tree.actions"
local legacy = require "nvim-tree.legacy" local legacy = require "nvim-tree.legacy"
local core = require "nvim-tree.core" local core = require "nvim-tree.core"
local reloaders = require "nvim-tree.actions.reloaders.reloaders"
local git = require "nvim-tree.git" local git = require "nvim-tree.git"
local filters = require "nvim-tree.explorer.filters" local filters = require "nvim-tree.explorer.filters"
local modified = require "nvim-tree.modified" local modified = require "nvim-tree.modified"
local find_file = require "nvim-tree.actions.tree.find-file"
local events = require "nvim-tree.events" local events = require "nvim-tree.events"
local notify = require "nvim-tree.notify" local notify = require "nvim-tree.notify"
@ -51,7 +49,7 @@ function M.change_root(path, bufnr)
-- test if in vim_cwd -- test if in vim_cwd
if utils.path_relative(path, vim_cwd) ~= path then if utils.path_relative(path, vim_cwd) ~= path then
if vim_cwd ~= cwd then if vim_cwd ~= cwd then
change_dir.fn(vim_cwd) actions.root.change_dir.fn(vim_cwd)
end end
return return
end end
@ -62,19 +60,19 @@ function M.change_root(path, bufnr)
-- otherwise test M.init_root -- otherwise test M.init_root
if _config.prefer_startup_root and utils.path_relative(path, M.init_root) ~= path then if _config.prefer_startup_root and utils.path_relative(path, M.init_root) ~= path then
change_dir.fn(M.init_root) actions.root.change_dir.fn(M.init_root)
return return
end end
-- otherwise root_dirs -- otherwise root_dirs
for _, dir in pairs(_config.root_dirs) do for _, dir in pairs(_config.root_dirs) do
dir = vim.fn.fnamemodify(dir, ":p") dir = vim.fn.fnamemodify(dir, ":p")
if utils.path_relative(path, dir) ~= path then if utils.path_relative(path, dir) ~= path then
change_dir.fn(dir) actions.root.change_dir.fn(dir)
return return
end end
end end
-- finally fall back to the folder containing the file -- finally fall back to the folder containing the file
change_dir.fn(vim.fn.fnamemodify(path, ":p:h")) actions.root.change_dir.fn(vim.fn.fnamemodify(path, ":p:h"))
end end
function M.tab_enter() function M.tab_enter()
@ -87,7 +85,7 @@ function M.tab_enter()
end end
end end
view.open { focus_tree = false } view.open { focus_tree = false }
require("nvim-tree.renderer").draw() renderer.draw()
end end
end end
@ -103,7 +101,7 @@ function M.open_on_directory()
return return
end end
change_dir.force_dirchange(bufname, true) actions.root.change_dir.force_dirchange(bufname, true)
end end
function M.reset_highlight() function M.reset_highlight()
@ -154,11 +152,11 @@ end
---@param name string|nil ---@param name string|nil
function M.change_dir(name) function M.change_dir(name)
if name then if name then
change_dir.fn(name) actions.root.change_dir.fn(name)
end end
if _config.update_focused_file.enable then if _config.update_focused_file.enable then
find_file.fn() actions.tree.find_file.fn()
end end
end end
@ -191,7 +189,7 @@ local function setup_autocommands(opts)
create_nvim_tree_autocmd("BufWritePost", { create_nvim_tree_autocmd("BufWritePost", {
callback = function() callback = function()
if opts.auto_reload_on_write and not opts.filesystem_watchers.enable then if opts.auto_reload_on_write and not opts.filesystem_watchers.enable then
reloaders.reload_explorer() actions.reloaders.reload_explorer()
end end
end, end,
}) })
@ -201,7 +199,7 @@ local function setup_autocommands(opts)
-- update opened file buffers -- update opened file buffers
if (filters.config.filter_no_buffer or renderer.config.highlight_opened_files ~= "none") and vim.bo[data.buf].buftype == "" then if (filters.config.filter_no_buffer or renderer.config.highlight_opened_files ~= "none") and vim.bo[data.buf].buftype == "" then
utils.debounce("Buf:filter_buffer", opts.view.debounce_delay, function() utils.debounce("Buf:filter_buffer", opts.view.debounce_delay, function()
reloaders.reload_explorer() actions.reloaders.reload_explorer()
end) end)
end end
end, end,
@ -212,7 +210,7 @@ local function setup_autocommands(opts)
-- update opened file buffers -- update opened file buffers
if (filters.config.filter_no_buffer or renderer.config.highlight_opened_files ~= "none") and vim.bo[data.buf].buftype == "" then if (filters.config.filter_no_buffer or renderer.config.highlight_opened_files ~= "none") and vim.bo[data.buf].buftype == "" then
utils.debounce("Buf:filter_buffer", opts.view.debounce_delay, function() utils.debounce("Buf:filter_buffer", opts.view.debounce_delay, function()
reloaders.reload_explorer(nil, data.buf) actions.reloaders.reload_explorer(nil, data.buf)
end) end)
end end
end, end,
@ -222,7 +220,7 @@ local function setup_autocommands(opts)
pattern = { "FugitiveChanged", "NeogitStatusRefreshed" }, pattern = { "FugitiveChanged", "NeogitStatusRefreshed" },
callback = function() callback = function()
if not opts.filesystem_watchers.enable and opts.git.enable then if not opts.filesystem_watchers.enable and opts.git.enable then
reloaders.reload_git() actions.reloaders.reload_git()
end end
end, end,
}) })
@ -251,7 +249,7 @@ local function setup_autocommands(opts)
create_nvim_tree_autocmd("BufEnter", { create_nvim_tree_autocmd("BufEnter", {
callback = function() callback = function()
utils.debounce("BufEnter:find_file", opts.view.debounce_delay, function() utils.debounce("BufEnter:find_file", opts.view.debounce_delay, function()
find_file.fn() actions.tree.find_file.fn()
end) end)
end, end,
}) })
@ -266,7 +264,7 @@ local function setup_autocommands(opts)
callback = function() callback = function()
if utils.is_nvim_tree_buf(0) then if utils.is_nvim_tree_buf(0) then
if vim.fn.getcwd() ~= core.get_cwd() or (opts.reload_on_bufenter and not opts.filesystem_watchers.enable) then if vim.fn.getcwd() ~= core.get_cwd() or (opts.reload_on_bufenter and not opts.filesystem_watchers.enable) then
reloaders.reload_explorer() actions.reloaders.reload_explorer()
end end
end end
end, end,
@ -317,7 +315,7 @@ local function setup_autocommands(opts)
callback = function() callback = function()
utils.debounce("Buf:modified", opts.view.debounce_delay, function() utils.debounce("Buf:modified", opts.view.debounce_delay, function()
modified.reload() modified.reload()
reloaders.reload_explorer() actions.reloaders.reload_explorer()
end) end)
end, end,
}) })

View File

@ -0,0 +1,6 @@
local M = {}
M.find_file = require "nvim-tree.actions.finders.find-file"
M.search_node = require "nvim-tree.actions.finders.search-node"
return M

View File

@ -5,7 +5,7 @@ local core = require "nvim-tree.core"
local events = require "nvim-tree.events" local events = require "nvim-tree.events"
local notify = require "nvim-tree.notify" local notify = require "nvim-tree.notify"
local renderer = require "nvim-tree.renderer" local renderer = require "nvim-tree.renderer"
local reloaders = require "nvim-tree.actions.reloaders.reloaders" local reloaders = require "nvim-tree.actions.reloaders"
local HL_POSITION = require("nvim-tree.enum").HL_POSITION local HL_POSITION = require("nvim-tree.enum").HL_POSITION

View File

@ -0,0 +1,16 @@
local M = {}
M.copy_paste = require "nvim-tree.actions.fs.copy-paste"
M.create_file = require "nvim-tree.actions.fs.create-file"
M.remove_file = require "nvim-tree.actions.fs.remove-file"
M.rename_file = require "nvim-tree.actions.fs.rename-file"
M.trash = require "nvim-tree.actions.fs.trash"
function M.setup(opts)
M.copy_paste.setup(opts)
M.remove_file.setup(opts)
M.rename_file.setup(opts)
M.trash.setup(opts)
end
return M

View File

@ -112,7 +112,7 @@ function M.fn(node)
local function do_remove() local function do_remove()
M.remove(node) M.remove(node)
if not M.config.filesystem_watchers.enable then if not M.config.filesystem_watchers.enable then
require("nvim-tree.actions.reloaders.reloaders").reload_explorer() require("nvim-tree.actions.reloaders").reload_explorer()
end end
end end

View File

@ -102,7 +102,7 @@ function M.fn(default_modifier)
M.rename(node, prepend .. new_file_path .. append) M.rename(node, prepend .. new_file_path .. append)
if not M.config.filesystem_watchers.enable then if not M.config.filesystem_watchers.enable then
require("nvim-tree.actions.reloaders.reloaders").reload_explorer() require("nvim-tree.actions.reloaders").reload_explorer()
end end
find_file(utils.path_remove_trailing(new_file_path)) find_file(utils.path_remove_trailing(new_file_path))

View File

@ -1,5 +1,6 @@
local lib = require "nvim-tree.lib" local lib = require "nvim-tree.lib"
local notify = require "nvim-tree.notify" local notify = require "nvim-tree.notify"
local reloaders = require "nvim-tree.actions.reloaders"
local M = { local M = {
config = {}, config = {},
@ -59,7 +60,7 @@ function M.remove(node)
end end
events._dispatch_folder_removed(node.absolute_path) events._dispatch_folder_removed(node.absolute_path)
if not M.config.filesystem_watchers.enable then if not M.config.filesystem_watchers.enable then
require("nvim-tree.actions.reloaders.reloaders").reload_explorer() reloaders.reload_explorer()
end end
end) end)
else else
@ -72,7 +73,7 @@ function M.remove(node)
events._dispatch_file_removed(node.absolute_path) events._dispatch_file_removed(node.absolute_path)
clear_buffer(node.absolute_path) clear_buffer(node.absolute_path)
if not M.config.filesystem_watchers.enable then if not M.config.filesystem_watchers.enable then
require("nvim-tree.actions.reloaders.reloaders").reload_explorer() reloaders.reload_explorer()
end end
end) end)
end end

View File

@ -1,18 +1,18 @@
local M = {} local M = {}
M.finders = require "nvim-tree.actions.finders"
M.fs = require "nvim-tree.actions.fs"
M.moves = require "nvim-tree.actions.moves"
M.node = require "nvim-tree.actions.node"
M.reloaders = require "nvim-tree.actions.reloaders"
M.root = require "nvim-tree.actions.root"
M.tree = require "nvim-tree.actions.tree"
function M.setup(opts) function M.setup(opts)
require("nvim-tree.actions.fs.trash").setup(opts) M.fs.setup(opts)
require("nvim-tree.actions.node.system-open").setup(opts) M.node.setup(opts)
require("nvim-tree.actions.node.file-popup").setup(opts) M.root.setup(opts)
require("nvim-tree.actions.node.open-file").setup(opts) M.tree.setup(opts)
require("nvim-tree.actions.root.change-dir").setup(opts)
require("nvim-tree.actions.fs.rename-file").setup(opts)
require("nvim-tree.actions.fs.remove-file").setup(opts)
require("nvim-tree.actions.fs.copy-paste").setup(opts)
require("nvim-tree.actions.tree-modifiers.expand-all").setup(opts)
require("nvim-tree.actions.tree.find-file").setup(opts)
require("nvim-tree.actions.tree.open").setup(opts)
require("nvim-tree.actions.tree.toggle").setup(opts)
end end
return M return M

View File

@ -0,0 +1,7 @@
local M = {}
M.item = require "nvim-tree.actions.moves.item"
M.parent = require "nvim-tree.actions.moves.parent"
M.sibling = require "nvim-tree.actions.moves.sibling"
return M

View File

@ -0,0 +1,14 @@
local M = {}
M.file_popup = require "nvim-tree.actions.node.file-popup"
M.open_file = require "nvim-tree.actions.node.open-file"
M.run_command = require "nvim-tree.actions.node.run-command"
M.system_open = require "nvim-tree.actions.node.system-open"
function M.setup(opts)
require("nvim-tree.actions.node.system-open").setup(opts)
require("nvim-tree.actions.node.file-popup").setup(opts)
require("nvim-tree.actions.node.open-file").setup(opts)
end
return M

View File

@ -0,0 +1,10 @@
local M = {}
M.change_dir = require "nvim-tree.actions.root.change-dir"
M.dir_up = require "nvim-tree.actions.root.dir-up"
function M.setup(opts)
M.change_dir.setup(opts)
end
return M

View File

@ -0,0 +1,15 @@
local M = {}
M.find_file = require "nvim-tree.actions.tree.find-file"
M.modifiers = require "nvim-tree.actions.tree.modifiers"
M.open = require "nvim-tree.actions.tree.open"
M.toggle = require "nvim-tree.actions.tree.toggle"
function M.setup(opts)
M.find_file.setup(opts)
M.modifiers.setup(opts)
M.open.setup(opts)
M.toggle.setup(opts)
end
return M

View File

@ -0,0 +1,11 @@
local M = {}
M.collapse_all = require "nvim-tree.actions.tree.modifiers.collapse-all"
M.expand_all = require "nvim-tree.actions.tree.modifiers.expand-all"
M.toggles = require "nvim-tree.actions.tree.modifiers.toggles"
function M.setup(opts)
M.expand_all.setup(opts)
end
return M

View File

@ -1,7 +1,7 @@
local lib = require "nvim-tree.lib" local lib = require "nvim-tree.lib"
local utils = require "nvim-tree.utils" local utils = require "nvim-tree.utils"
local filters = require "nvim-tree.explorer.filters" local filters = require "nvim-tree.explorer.filters"
local reloaders = require "nvim-tree.actions.reloaders.reloaders" local reloaders = require "nvim-tree.actions.reloaders"
local M = {} local M = {}

View File

@ -1,3 +1,15 @@
local lib = require "nvim-tree.lib"
local view = require "nvim-tree.view"
local utils = require "nvim-tree.utils"
local actions = require "nvim-tree.actions"
local events = require "nvim-tree.events"
local live_filter = require "nvim-tree.live-filter"
local marks = require "nvim-tree.marks"
local marks_navigation = require "nvim-tree.marks.navigation"
local marks_bulk_delete = require "nvim-tree.marks.bulk-delete"
local marks_bulk_trash = require "nvim-tree.marks.bulk-trash"
local marks_bulk_move = require "nvim-tree.marks.bulk-move"
local keymap = require "nvim-tree.keymap"
local notify = require "nvim-tree.notify" local notify = require "nvim-tree.notify"
local Api = { local Api = {
@ -45,7 +57,7 @@ end
---@param fn function function to invoke ---@param fn function function to invoke
local function wrap_node(fn) local function wrap_node(fn)
return function(node, ...) return function(node, ...)
node = node or require("nvim-tree.lib").get_node_at_cursor() node = node or lib.get_node_at_cursor()
if node then if node then
fn(node, ...) fn(node, ...)
end end
@ -56,7 +68,7 @@ end
---@param fn function function to invoke ---@param fn function function to invoke
local function wrap_node_or_nil(fn) local function wrap_node_or_nil(fn)
return function(node, ...) return function(node, ...)
node = node or require("nvim-tree.lib").get_node_at_cursor() node = node or lib.get_node_at_cursor()
fn(node, ...) fn(node, ...)
end end
end end
@ -68,7 +80,8 @@ end
---@field find_file boolean|nil default false ---@field find_file boolean|nil default false
---@field update_root boolean|nil default false ---@field update_root boolean|nil default false
Api.tree.open = wrap(require("nvim-tree.actions.tree.open").fn) Api.tree.open = wrap(actions.tree.open.fn)
Api.tree.focus = Api.tree.open
---@class ApiTreeToggleOpts ---@class ApiTreeToggleOpts
---@field path string|nil ---@field path string|nil
@ -78,19 +91,11 @@ Api.tree.open = wrap(require("nvim-tree.actions.tree.open").fn)
---@field update_root boolean|nil default false ---@field update_root boolean|nil default false
---@field focus boolean|nil default true ---@field focus boolean|nil default true
Api.tree.toggle = wrap(require("nvim-tree.actions.tree.toggle").fn) Api.tree.toggle = wrap(actions.tree.toggle.fn)
Api.tree.close = wrap(view.close)
Api.tree.close = wrap(require("nvim-tree.view").close) Api.tree.close_in_this_tab = wrap(view.close_this_tab_only)
Api.tree.close_in_all_tabs = wrap(view.close_all_tabs)
Api.tree.close_in_this_tab = wrap(require("nvim-tree.view").close_this_tab_only) Api.tree.reload = wrap(actions.reloaders.reload_explorer)
Api.tree.close_in_all_tabs = wrap(require("nvim-tree.view").close_all_tabs)
Api.tree.focus = wrap(function()
Api.tree.open()
end)
Api.tree.reload = wrap(require("nvim-tree.actions.reloaders.reloaders").reload_explorer)
Api.tree.change_root = wrap(function(...) Api.tree.change_root = wrap(function(...)
require("nvim-tree").change_dir(...) require("nvim-tree").change_dir(...)
@ -98,17 +103,15 @@ end)
Api.tree.change_root_to_node = wrap_node(function(node) Api.tree.change_root_to_node = wrap_node(function(node)
if node.name == ".." then if node.name == ".." then
require("nvim-tree.actions.root.change-dir").fn ".." actions.root.change_dir.fn ".."
elseif node.nodes ~= nil then elseif node.nodes ~= nil then
require("nvim-tree.actions.root.change-dir").fn(require("nvim-tree.lib").get_last_group_node(node).absolute_path) actions.root.change_dir.fn(lib.get_last_group_node(node).absolute_path)
end end
end) end)
Api.tree.change_root_to_parent = wrap_node(require("nvim-tree.actions.root.dir-up").fn) Api.tree.change_root_to_parent = wrap_node(actions.root.dir_up.fn)
Api.tree.get_node_under_cursor = wrap(lib.get_node_at_cursor)
Api.tree.get_node_under_cursor = wrap(require("nvim-tree.lib").get_node_at_cursor) Api.tree.get_nodes = wrap(lib.get_nodes)
Api.tree.get_nodes = wrap(require("nvim-tree.lib").get_nodes)
---@class ApiTreeFindFileOpts ---@class ApiTreeFindFileOpts
---@field buf string|number|nil ---@field buf string|number|nil
@ -118,57 +121,46 @@ Api.tree.get_nodes = wrap(require("nvim-tree.lib").get_nodes)
---@field update_root boolean|nil default false ---@field update_root boolean|nil default false
---@field focus boolean|nil default false ---@field focus boolean|nil default false
Api.tree.find_file = wrap(require("nvim-tree.actions.tree.find-file").fn) Api.tree.find_file = wrap(actions.tree.find_file.fn)
Api.tree.search_node = wrap(actions.finders.search_node.fn)
Api.tree.search_node = wrap(require("nvim-tree.actions.finders.search-node").fn) Api.tree.collapse_all = wrap(actions.tree.modifiers.collapse_all.fn)
Api.tree.expand_all = wrap_node(actions.tree.modifiers.expand_all.fn)
Api.tree.collapse_all = wrap(require("nvim-tree.actions.tree-modifiers.collapse-all").fn) Api.tree.toggle_gitignore_filter = wrap(actions.tree.modifiers.toggles.git_ignored)
Api.tree.toggle_git_clean_filter = wrap(actions.tree.modifiers.toggles.git_clean)
Api.tree.expand_all = wrap_node(require("nvim-tree.actions.tree-modifiers.expand-all").fn) Api.tree.toggle_no_buffer_filter = wrap(actions.tree.modifiers.toggles.no_buffer)
Api.tree.toggle_custom_filter = wrap(actions.tree.modifiers.toggles.custom)
Api.tree.toggle_gitignore_filter = wrap(require("nvim-tree.actions.tree-modifiers.toggles").git_ignored) Api.tree.toggle_hidden_filter = wrap(actions.tree.modifiers.toggles.dotfiles)
Api.tree.toggle_no_bookmark_filter = wrap(actions.tree.modifiers.toggles.no_bookmark)
Api.tree.toggle_git_clean_filter = wrap(require("nvim-tree.actions.tree-modifiers.toggles").git_clean) Api.tree.toggle_help = wrap(actions.tree.modifiers.toggles.toggle)
Api.tree.is_tree_buf = wrap(utils.is_nvim_tree_buf)
Api.tree.toggle_no_buffer_filter = wrap(require("nvim-tree.actions.tree-modifiers.toggles").no_buffer)
Api.tree.toggle_custom_filter = wrap(require("nvim-tree.actions.tree-modifiers.toggles").custom)
Api.tree.toggle_hidden_filter = wrap(require("nvim-tree.actions.tree-modifiers.toggles").dotfiles)
Api.tree.toggle_no_bookmark_filter = wrap(require("nvim-tree.actions.tree-modifiers.toggles").no_bookmark)
Api.tree.toggle_help = wrap(require("nvim-tree.help").toggle)
Api.tree.is_tree_buf = wrap(require("nvim-tree.utils").is_nvim_tree_buf)
---@class ApiTreeIsVisibleOpts ---@class ApiTreeIsVisibleOpts
---@field tabpage number|nil ---@field tabpage number|nil
---@field any_tabpage boolean|nil default false ---@field any_tabpage boolean|nil default false
Api.tree.is_visible = wrap(require("nvim-tree.view").is_visible) Api.tree.is_visible = wrap(view.is_visible)
---@class ApiTreeWinIdOpts ---@class ApiTreeWinIdOpts
---@field tabpage number|nil default nil ---@field tabpage number|nil default nil
Api.tree.winid = wrap(require("nvim-tree.view").winid) Api.tree.winid = wrap(view.winid)
Api.fs.create = wrap_node_or_nil(require("nvim-tree.actions.fs.create-file").fn) Api.fs.create = wrap_node_or_nil(actions.fs.create_file.fn)
Api.fs.remove = wrap_node(require("nvim-tree.actions.fs.remove-file").fn) Api.fs.remove = wrap_node(actions.fs.remove_file.fn)
Api.fs.trash = wrap_node(require("nvim-tree.actions.fs.trash").fn) Api.fs.trash = wrap_node(actions.fs.trash.fn)
Api.fs.rename_node = wrap_node(require("nvim-tree.actions.fs.rename-file").fn ":t") Api.fs.rename_node = wrap_node(actions.fs.rename_file.fn ":t")
Api.fs.rename = wrap_node(require("nvim-tree.actions.fs.rename-file").fn ":t") Api.fs.rename = wrap_node(actions.fs.rename_file.fn ":t")
Api.fs.rename_sub = wrap_node(require("nvim-tree.actions.fs.rename-file").fn ":p:h") Api.fs.rename_sub = wrap_node(actions.fs.rename_file.fn ":p:h")
Api.fs.rename_basename = wrap_node(require("nvim-tree.actions.fs.rename-file").fn ":t:r") Api.fs.rename_basename = wrap_node(actions.fs.rename_file.fn ":t:r")
Api.fs.rename_full = wrap_node(require("nvim-tree.actions.fs.rename-file").fn ":p") Api.fs.rename_full = wrap_node(actions.fs.rename_file.fn ":p")
Api.fs.cut = wrap_node(require("nvim-tree.actions.fs.copy-paste").cut) Api.fs.cut = wrap_node(actions.fs.copy_paste.cut)
Api.fs.paste = wrap_node(require("nvim-tree.actions.fs.copy-paste").paste) Api.fs.paste = wrap_node(actions.fs.copy_paste.paste)
Api.fs.clear_clipboard = wrap(require("nvim-tree.actions.fs.copy-paste").clear_clipboard) Api.fs.clear_clipboard = wrap(actions.fs.copy_paste.clear_clipboard)
Api.fs.print_clipboard = wrap(require("nvim-tree.actions.fs.copy-paste").print_clipboard) Api.fs.print_clipboard = wrap(actions.fs.copy_paste.print_clipboard)
Api.fs.copy.node = wrap_node(require("nvim-tree.actions.fs.copy-paste").copy) Api.fs.copy.node = wrap_node(actions.fs.copy_paste.copy)
Api.fs.copy.absolute_path = wrap_node(require("nvim-tree.actions.fs.copy-paste").copy_absolute_path) Api.fs.copy.absolute_path = wrap_node(actions.fs.copy_paste.copy_absolute_path)
Api.fs.copy.filename = wrap_node(require("nvim-tree.actions.fs.copy-paste").copy_filename) Api.fs.copy.filename = wrap_node(actions.fs.copy_paste.copy_filename)
Api.fs.copy.relative_path = wrap_node(require("nvim-tree.actions.fs.copy-paste").copy_path) Api.fs.copy.relative_path = wrap_node(actions.fs.copy_paste.copy_path)
---@param mode string ---@param mode string
---@param node table ---@param node table
@ -177,7 +169,7 @@ local function edit(mode, node)
if node.link_to and not node.nodes then if node.link_to and not node.nodes then
path = node.link_to path = node.link_to
end end
require("nvim-tree.actions.node.open-file").fn(mode, path) actions.node.open_file.fn(mode, path)
end end
---@param mode string ---@param mode string
@ -185,9 +177,9 @@ end
local function open_or_expand_or_dir_up(mode) local function open_or_expand_or_dir_up(mode)
return function(node) return function(node)
if node.name == ".." then if node.name == ".." then
require("nvim-tree.actions.root.change-dir").fn ".." actions.root.change_dir.fn ".."
elseif node.nodes then elseif node.nodes then
require("nvim-tree.lib").expand_or_collapse(node) lib.expand_or_collapse(node)
else else
edit(mode, node) edit(mode, node)
end end
@ -205,54 +197,47 @@ Api.node.open.tab = wrap_node(open_or_expand_or_dir_up "tabnew")
Api.node.open.preview = wrap_node(open_or_expand_or_dir_up "preview") Api.node.open.preview = wrap_node(open_or_expand_or_dir_up "preview")
Api.node.open.preview_no_picker = wrap_node(open_or_expand_or_dir_up "preview_no_picker") Api.node.open.preview_no_picker = wrap_node(open_or_expand_or_dir_up "preview_no_picker")
Api.node.show_info_popup = wrap_node(require("nvim-tree.actions.node.file-popup").toggle_file_info) Api.node.show_info_popup = wrap_node(actions.node.file_popup.toggle_file_info)
Api.node.run.cmd = wrap_node(require("nvim-tree.actions.node.run-command").run_file_command) Api.node.run.cmd = wrap_node(actions.node.run_command.run_file_command)
Api.node.run.system = wrap_node(require("nvim-tree.actions.node.system-open").fn) Api.node.run.system = wrap_node(actions.node.system_open.fn)
Api.node.navigate.sibling.next = wrap_node(require("nvim-tree.actions.moves.sibling").fn "next")
Api.node.navigate.sibling.prev = wrap_node(require("nvim-tree.actions.moves.sibling").fn "prev")
Api.node.navigate.sibling.first = wrap_node(require("nvim-tree.actions.moves.sibling").fn "first")
Api.node.navigate.sibling.last = wrap_node(require("nvim-tree.actions.moves.sibling").fn "last")
Api.node.navigate.parent = wrap_node(require("nvim-tree.actions.moves.parent").fn(false))
Api.node.navigate.parent_close = wrap_node(require("nvim-tree.actions.moves.parent").fn(true))
Api.node.navigate.git.next = wrap_node(require("nvim-tree.actions.moves.item").fn { where = "next", what = "git" })
Api.node.navigate.git.prev = wrap_node(require("nvim-tree.actions.moves.item").fn { where = "prev", what = "git" })
-- stylua: ignore
Api.node.navigate.git.next_skip_gitignored = wrap_node(require("nvim-tree.actions.moves.item").fn { where = "next", what = "git", skip_gitignored = true })
-- stylua: ignore
Api.node.navigate.git.prev_skip_gitignored = wrap_node(require("nvim-tree.actions.moves.item").fn { where = "prev", what = "git", skip_gitignored = true })
Api.node.navigate.diagnostics.next = wrap_node(require("nvim-tree.actions.moves.item").fn { where = "next", what = "diag" })
Api.node.navigate.diagnostics.prev = wrap_node(require("nvim-tree.actions.moves.item").fn { where = "prev", what = "diag" })
Api.node.navigate.opened.next = wrap_node(require("nvim-tree.actions.moves.item").fn { where = "next", what = "opened" })
Api.node.navigate.opened.prev = wrap_node(require("nvim-tree.actions.moves.item").fn { where = "prev", what = "opened" })
Api.git.reload = wrap(require("nvim-tree.actions.reloaders.reloaders").reload_git) Api.node.navigate.sibling.next = wrap_node(actions.moves.sibling.fn "next")
Api.node.navigate.sibling.prev = wrap_node(actions.moves.sibling.fn "prev")
Api.node.navigate.sibling.first = wrap_node(actions.moves.sibling.fn "first")
Api.node.navigate.sibling.last = wrap_node(actions.moves.sibling.fn "last")
Api.node.navigate.parent = wrap_node(actions.moves.parent.fn(false))
Api.node.navigate.parent_close = wrap_node(actions.moves.parent.fn(true))
Api.node.navigate.git.next = wrap_node(actions.moves.item.fn { where = "next", what = "git" })
Api.node.navigate.git.next_skip_gitignored = wrap_node(actions.moves.item.fn { where = "next", what = "git", skip_gitignored = true })
Api.node.navigate.git.prev = wrap_node(actions.moves.item.fn { where = "prev", what = "git" })
Api.node.navigate.git.prev_skip_gitignored = wrap_node(actions.moves.item.fn { where = "prev", what = "git", skip_gitignored = true })
Api.node.navigate.diagnostics.next = wrap_node(actions.moves.item.fn { where = "next", what = "diag" })
Api.node.navigate.diagnostics.prev = wrap_node(actions.moves.item.fn { where = "prev", what = "diag" })
Api.node.navigate.opened.next = wrap_node(actions.moves.item.fn { where = "next", what = "opened" })
Api.node.navigate.opened.prev = wrap_node(actions.moves.item.fn { where = "prev", what = "opened" })
Api.events.subscribe = require("nvim-tree.events").subscribe Api.git.reload = wrap(actions.reloaders.reload_git)
Api.events.Event = require("nvim-tree.events").Event
Api.live_filter.start = wrap(require("nvim-tree.live-filter").start_filtering) Api.events.subscribe = events.subscribe
Api.live_filter.clear = wrap(require("nvim-tree.live-filter").clear_filter) Api.events.Event = events.Event
Api.marks.get = wrap_node(require("nvim-tree.marks").get_mark) Api.live_filter.start = wrap(live_filter.start_filtering)
Api.marks.list = wrap(require("nvim-tree.marks").get_marks) Api.live_filter.clear = wrap(live_filter.clear_filter)
Api.marks.toggle = wrap_node(require("nvim-tree.marks").toggle_mark)
Api.marks.clear = wrap(require("nvim-tree.marks").clear_marks)
Api.marks.bulk.delete = wrap(require("nvim-tree.marks.bulk-delete").bulk_delete)
Api.marks.bulk.trash = wrap(require("nvim-tree.marks.bulk-trash").bulk_trash)
Api.marks.bulk.move = wrap(require("nvim-tree.marks.bulk-move").bulk_move)
Api.marks.navigate.next = wrap(require("nvim-tree.marks.navigation").next)
Api.marks.navigate.prev = wrap(require("nvim-tree.marks.navigation").prev)
Api.marks.navigate.select = wrap(require("nvim-tree.marks.navigation").select)
Api.config.mappings.default_on_attach = require("nvim-tree.keymap").default_on_attach Api.marks.get = wrap_node(marks.get_mark)
Api.marks.list = wrap(marks.get_marks)
Api.marks.toggle = wrap_node(marks.toggle_mark)
Api.marks.clear = wrap(marks.clear_marks)
Api.marks.bulk.delete = wrap(marks_bulk_delete.bulk_delete)
Api.marks.bulk.trash = wrap(marks_bulk_trash.bulk_trash)
Api.marks.bulk.move = wrap(marks_bulk_move.bulk_move)
Api.marks.navigate.next = wrap(marks_navigation.next)
Api.marks.navigate.prev = wrap(marks_navigation.prev)
Api.marks.navigate.select = wrap(marks_navigation.select)
Api.config.mappings.get_keymap = wrap(function() Api.config.mappings.get_keymap = wrap(keymap.get_keymap)
return require("nvim-tree.keymap").get_keymap() Api.config.mappings.get_keymap_default = wrap(keymap.get_keymap_default)
end) Api.config.mappings.default_on_attach = keymap.default_on_attach
Api.config.mappings.get_keymap_default = wrap(function()
return require("nvim-tree.keymap").get_keymap_default()
end)
Api.commands.get = wrap(function() Api.commands.get = wrap(function()
return require("nvim-tree.commands").get() return require("nvim-tree.commands").get()

View File

@ -18,7 +18,7 @@ local function do_delete(nodes)
marks.clear_marks() marks.clear_marks()
if not M.config.filesystem_watchers.enable then if not M.config.filesystem_watchers.enable then
require("nvim-tree.actions.reloaders.reloaders").reload_explorer() require("nvim-tree.actions.reloaders").reload_explorer()
end end
end end

View File

@ -40,7 +40,7 @@ function M.bulk_move()
marks.clear_marks() marks.clear_marks()
if not M.config.filesystem_watchers.enable then if not M.config.filesystem_watchers.enable then
require("nvim-tree.actions.reloaders.reloaders").reload_explorer() require("nvim-tree.actions.reloaders").reload_explorer()
end end
end) end)
end end