Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
30a26ac
perf(#3257): remove remove-file setup
alex-courtis Mar 24, 2026
85d3291
perf(#3257): remove rename-file setup
alex-courtis Mar 24, 2026
426e272
perf(#3257): remove trash setup
alex-courtis Mar 24, 2026
c14dca3
perf(#3257): remove actions.fs init
alex-courtis Mar 24, 2026
0b6a1a5
perf(#3257): remove file-popup setup
alex-courtis Mar 24, 2026
364035b
perf(#3257): remove open-file setup
alex-courtis Mar 24, 2026
6bb2d7f
perf(#3257): remove system-open setup
alex-courtis Mar 24, 2026
e416f4b
perf(#3257): remove open-file setup
alex-courtis Mar 24, 2026
730682a
perf(#3257): remove actions.node init
alex-courtis Mar 24, 2026
adc4c02
perf(#3257): remove change-dir setup
alex-courtis Mar 24, 2026
575ff6d
perf(#3257): remove find-file setup
alex-courtis Mar 24, 2026
fd410a0
perf(#3257): remove open setup
alex-courtis Mar 24, 2026
d3394d3
perf(#3257): remove toggle setup
alex-courtis Mar 24, 2026
0245796
perf(#3257): remove resize setup
alex-courtis Mar 24, 2026
32c7594
perf(#3257): remove finders init
alex-courtis Mar 24, 2026
da10b22
perf(#3257): remove moves init
alex-courtis Mar 24, 2026
cbfd047
perf(#3257): remove tree init
alex-courtis Mar 24, 2026
722dee2
perf(#3257): remove explorer setup
alex-courtis Mar 24, 2026
05f7cbd
perf(#3257): view uses config.g
alex-courtis Mar 24, 2026
1784b98
perf(#3257): move os from utils to config, removing requires
alex-courtis Mar 25, 2026
ff4b190
perf(#3257): move os from utils to config, removing requires
alex-courtis Mar 25, 2026
e5cb2a0
perf(#3257): move os from utils to config, removing requires
alex-courtis Mar 25, 2026
697a42b
perf(#3257): remove watch setup
alex-courtis Mar 26, 2026
5d47b64
perf(#3257): remove notify setup
alex-courtis Mar 26, 2026
857e137
perf(#3257): remove full-name setup
alex-courtis Mar 26, 2026
862db03
perf(#3257): remove padding setup
alex-courtis Mar 26, 2026
95aadff
Revert "perf(#3257): remove padding setup"
alex-courtis Mar 27, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions lua/nvim-tree.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ local api = require("nvim-tree.api")
local log = require("nvim-tree.log")
local view = require("nvim-tree.view")
local utils = require("nvim-tree.utils")
local actions = require("nvim-tree.actions")
local find_file = require("nvim-tree.actions.tree.find-file")
local change_dir = require("nvim-tree.actions.tree.change-dir")
local full_name = require("nvim-tree.renderer.components.full-name")
local core = require("nvim-tree.core")
local notify = require("nvim-tree.notify")
local config = require("nvim-tree.config")
Expand Down Expand Up @@ -169,7 +171,7 @@ local function setup_autocommands()
if config.g.sync_root_with_cwd then
create_nvim_tree_autocmd("DirChanged", {
callback = function()
actions.tree.change_dir.fn(vim.loop.cwd())
change_dir.fn(vim.loop.cwd())
end,
})
end
Expand All @@ -181,7 +183,7 @@ local function setup_autocommands()
return
end
utils.debounce("BufEnter:find_file", config.g.view.debounce_delay, function()
actions.tree.find_file.fn()
find_file.fn()
end)
end,
})
Expand Down Expand Up @@ -248,6 +250,9 @@ local function setup_autocommands()
end
end,
})

-- renderer.full name
full_name.setup_autocommands()
end

function M.purge_all_state()
Expand Down Expand Up @@ -276,18 +281,14 @@ function M.setup(config_user)

manage_netrw()

require("nvim-tree.notify").setup(config.g)
require("nvim-tree.log").setup(config.g)

if log.enabled("config") then
log.line("config", "default config + user")
log.raw("config", "%s\n", vim.inspect(config.g))
end

require("nvim-tree.actions").setup(config.g)
require("nvim-tree.appearance").setup()
require("nvim-tree.explorer"):setup(config.g)
require("nvim-tree.explorer.watch").setup(config.g)
require("nvim-tree.view").setup(config.g)
require("nvim-tree.renderer.components").setup(config.g)

Expand Down
6 changes: 0 additions & 6 deletions lua/nvim-tree/actions/finders/init.lua

This file was deleted.

14 changes: 0 additions & 14 deletions lua/nvim-tree/actions/fs/init.lua

This file was deleted.

32 changes: 13 additions & 19 deletions lua/nvim-tree/actions/fs/remove-file.lua
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
local core = require("nvim-tree.core")
local utils = require("nvim-tree.utils")
local events = require("nvim-tree.events")
local view = require("nvim-tree.view")
local lib = require("nvim-tree.lib")
local notify = require("nvim-tree.notify")
local config = require("nvim-tree.config")

local DirectoryLinkNode = require("nvim-tree.node.directory-link")
local DirectoryNode = require("nvim-tree.node.directory")
Expand All @@ -18,7 +18,7 @@ local M = {
local function close_windows(windows)
-- When floating, prevent closing the last non-floating window.
-- For details see #2503, #3187.
if view.View.float.enable then
if config.g.view.float.enable then
local non_float_count = 0
for _, win in ipairs(vim.api.nvim_list_wins()) do
if vim.api.nvim_win_get_config(win).relative == "" then
Expand All @@ -43,15 +43,15 @@ local function clear_buffer(absolute_path)
for _, buf in pairs(bufs) do
if buf.name == absolute_path then
local tree_winnr = vim.api.nvim_get_current_win()
if buf.hidden == 0 and (#bufs > 1 or view.View.float.enable) then
if buf.hidden == 0 and (#bufs > 1 or config.g.view.float.enable) then
vim.api.nvim_set_current_win(buf.windows[1])
vim.cmd(":bn")
end
vim.api.nvim_buf_delete(buf.bufnr, { force = true })
if not view.View.float.quit_on_focus_loss then
if not config.g.view.float.quit_on_focus_loss then
vim.api.nvim_set_current_win(tree_winnr)
end
if M.config.actions.remove_file.close_window then
if config.g.actions.remove_file.close_window then
close_windows(buf.windows)
end
return
Expand Down Expand Up @@ -141,18 +141,18 @@ local function remove_one(node)
notify.info(notify.render_path(node.absolute_path) .. " was properly removed.")
end
local explorer = core.get_explorer()
if not M.config.filesystem_watchers.enable and explorer then
if not config.g.filesystem_watchers.enable and explorer then
explorer:reload_explorer()
end
end

if M.config.ui.confirm.remove then
if config.g.ui.confirm.remove then
local prompt_select = "Remove " .. node.name .. "?"
local prompt_input, items_short, items_long = utils.confirm_prompt(prompt_select, M.config.ui.confirm.default_yes)
local prompt_input, items_short, items_long = utils.confirm_prompt(prompt_select, config.g.ui.confirm.default_yes)

lib.prompt(prompt_input, prompt_select, items_short, items_long, "nvimtree_remove", function(item_short)
utils.clear_prompt()
if item_short == "y" or item_short == (M.config.ui.confirm.default_yes and "") then
if item_short == "y" or item_short == (config.g.ui.confirm.default_yes and "") then
do_remove()
end
end)
Expand Down Expand Up @@ -181,18 +181,18 @@ local function remove_many(nodes)
notify.info(string.format("%d nodes properly removed.", removed))
end
local explorer = core.get_explorer()
if not M.config.filesystem_watchers.enable and explorer then
if not config.g.filesystem_watchers.enable and explorer then
explorer:reload_explorer()
end
end

if M.config.ui.confirm.remove then
if config.g.ui.confirm.remove then
local prompt_select = string.format("Remove %d selected?", #nodes)
local prompt_input, items_short, items_long = utils.confirm_prompt(prompt_select, M.config.ui.confirm.default_yes)
local prompt_input, items_short, items_long = utils.confirm_prompt(prompt_select, config.g.ui.confirm.default_yes)

lib.prompt(prompt_input, prompt_select, items_short, items_long, "nvimtree_remove", function(item_short)
utils.clear_prompt()
if item_short == "y" or item_short == (M.config.ui.confirm.default_yes and "") then
if item_short == "y" or item_short == (config.g.ui.confirm.default_yes and "") then
execute()
end
end)
Expand All @@ -210,10 +210,4 @@ function M.fn(node_or_nodes)
end
end

function M.setup(opts)
M.config.ui = opts.ui
M.config.actions = opts.actions
M.config.filesystem_watchers = opts.filesystem_watchers
end

return M
7 changes: 4 additions & 3 deletions lua/nvim-tree/actions/fs/rename-file.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ local core = require("nvim-tree.core")
local utils = require("nvim-tree.utils")
local events = require("nvim-tree.events")
local notify = require("nvim-tree.notify")
local config = require("nvim-tree.config")

local find_file = require("nvim-tree.actions.finders.find-file").fn

Expand Down Expand Up @@ -33,7 +34,7 @@ local function err_fmt(from, to, reason)
end

local function rename_file_exists(node, to)
if not utils.is_macos then
if not config.os.macos then
return utils.file_exists(to)
end

Expand Down Expand Up @@ -163,7 +164,7 @@ local function prompt_to_rename(node, modifier)
local full_new_path = prepend .. new_file_path .. append

M.rename(node, full_new_path)
if not M.config.filesystem_watchers.enable then
if not config.g.filesystem_watchers.enable then
explorer:reload_explorer()
end

Expand Down Expand Up @@ -192,7 +193,7 @@ function M.rename_full(node)
end

function M.setup(opts)
M.config.filesystem_watchers = opts.filesystem_watchers
config.g.filesystem_watchers = opts.filesystem_watchers
end

return M
31 changes: 13 additions & 18 deletions lua/nvim-tree/actions/fs/trash.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ local lib = require("nvim-tree.lib")
local notify = require("nvim-tree.notify")
local utils = require("nvim-tree.utils")
local events = require("nvim-tree.events")
local config = require("nvim-tree.config")

local DirectoryLinkNode = require("nvim-tree.node.directory-link")
local DirectoryNode = require("nvim-tree.node.directory")
Expand Down Expand Up @@ -32,9 +33,9 @@ end

---@param node Node
function M.remove(node)
local binary = M.config.trash.cmd:gsub(" .*$", "")
local binary = config.g.trash.cmd:gsub(" .*$", "")
if vim.fn.executable(binary) == 0 then
notify.warn(string.format("trash.cmd '%s' is not an executable.", M.config.trash.cmd))
notify.warn(string.format("trash.cmd '%s' is not an executable.", config.g.trash.cmd))
return
end

Expand All @@ -45,8 +46,8 @@ function M.remove(node)

-- trashes a path (file or folder)
local function trash_path(on_exit)
local need_sync_wait = utils.is_windows
local job = vim.fn.jobstart(M.config.trash.cmd .. " " .. vim.fn.shellescape(node.absolute_path), {
local need_sync_wait = config.os.windows
local job = vim.fn.jobstart(config.g.trash.cmd .. " " .. vim.fn.shellescape(node.absolute_path), {
detach = not need_sync_wait,
on_exit = on_exit,
on_stderr = on_stderr,
Expand All @@ -65,7 +66,7 @@ function M.remove(node)
return
end
events._dispatch_folder_removed(node.absolute_path)
if not M.config.filesystem_watchers.enable and explorer then
if not config.g.filesystem_watchers.enable and explorer then
explorer:reload_explorer()
end
end)
Expand All @@ -78,7 +79,7 @@ function M.remove(node)
end
events._dispatch_file_removed(node.absolute_path)
clear_buffer(node.absolute_path)
if not M.config.filesystem_watchers.enable and explorer then
if not config.g.filesystem_watchers.enable and explorer then
explorer:reload_explorer()
end
end)
Expand All @@ -96,13 +97,13 @@ local function trash_one(node)
M.remove(node)
end

if M.config.ui.confirm.trash then
if config.g.ui.confirm.trash then
local prompt_select = "Trash " .. node.name .. "?"
local prompt_input, items_short, items_long = utils.confirm_prompt(prompt_select, M.config.ui.confirm.default_yes)
local prompt_input, items_short, items_long = utils.confirm_prompt(prompt_select, config.g.ui.confirm.default_yes)

lib.prompt(prompt_input, prompt_select, items_short, items_long, "nvimtree_trash", function(item_short)
utils.clear_prompt()
if item_short == "y" or item_short == (M.config.ui.confirm.default_yes and "") then
if item_short == "y" or item_short == (config.g.ui.confirm.default_yes and "") then
do_trash()
end
end)
Expand All @@ -128,13 +129,13 @@ local function trash_many(nodes)
end
end

if M.config.ui.confirm.trash then
if config.g.ui.confirm.trash then
local prompt_select = string.format("Trash %d selected?", #nodes)
local prompt_input, items_short, items_long = utils.confirm_prompt(prompt_select, M.config.ui.confirm.default_yes)
local prompt_input, items_short, items_long = utils.confirm_prompt(prompt_select, config.g.ui.confirm.default_yes)

lib.prompt(prompt_input, prompt_select, items_short, items_long, "nvimtree_trash", function(item_short)
utils.clear_prompt()
if item_short == "y" or item_short == (M.config.ui.confirm.default_yes and "") then
if item_short == "y" or item_short == (config.g.ui.confirm.default_yes and "") then
execute()
end
end)
Expand All @@ -152,10 +153,4 @@ function M.fn(node_or_nodes)
end
end

function M.setup(opts)
M.config.ui = opts.ui
M.config.trash = opts.trash
M.config.filesystem_watchers = opts.filesystem_watchers
end

return M
15 changes: 0 additions & 15 deletions lua/nvim-tree/actions/init.lua

This file was deleted.

7 changes: 0 additions & 7 deletions lua/nvim-tree/actions/moves/init.lua

This file was deleted.

7 changes: 2 additions & 5 deletions lua/nvim-tree/actions/node/file-popup.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
local utils = require("nvim-tree.utils")
local config = require("nvim-tree.config")

local M = {}

Expand Down Expand Up @@ -38,7 +39,7 @@ local function setup_window(node)
local max_width = vim.fn.max(vim.tbl_map(function(n)
return #n
end, lines))
local open_win_config = vim.tbl_extend("force", M.open_win_config, {
local open_win_config = vim.tbl_extend("force", config.g.actions.file_popup.open_win_config, {
width = max_width + 1,
height = #lines,
noautocmd = true,
Expand Down Expand Up @@ -89,8 +90,4 @@ function M.toggle_file_info(node)
})
end

function M.setup(opts)
M.open_win_config = opts.actions.file_popup.open_win_config
end

return M
15 changes: 0 additions & 15 deletions lua/nvim-tree/actions/node/init.lua

This file was deleted.

Loading
Loading