Skip to content

[pull] master from nvim-tree:master #18

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 19, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
10 changes: 1 addition & 9 deletions doc/nvim-tree-lua.txt
Original file line number Diff line number Diff line change
Expand Up @@ -638,6 +638,7 @@ Following is the default configuration. See |nvim-tree-opts| for details. >lua
},
},
experimental = {
multi_instance = false,
},
log = {
enable = false,
Expand Down Expand Up @@ -1514,11 +1515,6 @@ Configuration options for opening a file from nvim-tree.
Resizes the tree when opening a file.
Type: `boolean`, Default: `true`

*nvim-tree.experimental.actions.open_file.relative_path*
Buffers opened by nvim-tree will use with relative paths instead of
absolute.
Type: `boolean`, Default: `true`

*nvim-tree.actions.open_file.window_picker*
Window picker configuration.

Expand Down Expand Up @@ -3008,9 +3004,6 @@ Windows WSL and PowerShell
- Executable file detection is disabled as this is non-performant and can
freeze nvim
- Some filesystem watcher error related to permissions will not be reported
- Some users have reported unspecified issues with
|nvim-tree.experimental.actions.open_file.relative_path|. Please report any
issues or disable this feature.

==============================================================================
13. NETRW *nvim-tree-netrw*
Expand Down Expand Up @@ -3145,7 +3138,6 @@ highlight group is not, hard linking as follows: >
|nvim-tree.diagnostics.show_on_open_dirs|
|nvim-tree.disable_netrw|
|nvim-tree.experimental|
|nvim-tree.experimental.actions.open_file.relative_path|
|nvim-tree.filesystem_watchers.debounce_delay|
|nvim-tree.filesystem_watchers.enable|
|nvim-tree.filesystem_watchers.ignore_dirs|
Expand Down
47 changes: 10 additions & 37 deletions lua/nvim-tree.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
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 core = require("nvim-tree.core")
Expand Down Expand Up @@ -74,7 +73,8 @@ function M.change_root(path, bufnr)
end

function M.tab_enter()
if view.is_visible({ any_tabpage = true }) then
local explorer = core.get_explorer()
if explorer and explorer.view:is_visible({ any_tabpage = true }) then
local bufname = vim.api.nvim_buf_get_name(0)

local ft
Expand All @@ -89,17 +89,15 @@ function M.tab_enter()
return
end
end
view.open({ focus_tree = false })
explorer.view:open({ focus_tree = false })

local explorer = core.get_explorer()
if explorer then
explorer.renderer:draw()
end
explorer.renderer:draw()
end
end

function M.open_on_directory()
local should_proceed = _config.hijack_directories.auto_open or view.is_visible()
local explorer = core.get_explorer()
local should_proceed = _config.hijack_directories.auto_open or explorer and explorer.view:is_visible()
if not should_proceed then
return
end
Expand Down Expand Up @@ -150,21 +148,6 @@ local function setup_autocommands(opts)
vim.api.nvim_create_autocmd(name, vim.tbl_extend("force", default_opts, custom_opts))
end

-- prevent new opened file from opening in the same window as nvim-tree
create_nvim_tree_autocmd("BufWipeout", {
pattern = "NvimTree_*",
callback = function()
if not utils.is_nvim_tree_buf(0) then
return
end
if opts.actions.open_file.eject then
view._prevent_buffer_override()
else
view.abandon_current_window()
end
end,
})

if opts.tab.sync.open then
create_nvim_tree_autocmd("TabEnter", { callback = vim.schedule_wrap(M.tab_enter) })
end
Expand Down Expand Up @@ -226,17 +209,6 @@ local function setup_autocommands(opts)
})
end

if opts.view.float.enable and opts.view.float.quit_on_focus_loss then
create_nvim_tree_autocmd("WinLeave", {
pattern = "NvimTree_*",
callback = function()
if utils.is_nvim_tree_buf(0) then
view.close()
end
end,
})
end

-- Handles event dispatch when tree is closed by `:q`
create_nvim_tree_autocmd("WinClosed", {
pattern = "*",
Expand Down Expand Up @@ -513,6 +485,7 @@ local DEFAULT_OPTS = { -- BEGIN_DEFAULT_OPTS
},
},
experimental = {
multi_instance = false,
},
log = {
enable = false,
Expand Down Expand Up @@ -692,10 +665,10 @@ local function localise_default_opts()
end

function M.purge_all_state()
view.close_all_tabs()
view.abandon_all_windows()
local explorer = core.get_explorer()
if explorer then
explorer.view:close_all_tabs()
explorer.view:abandon_all_windows("purge_all_state")
require("nvim-tree.git").purge_state()
explorer:destroy()
core.reset_explorer()
Expand Down Expand Up @@ -748,12 +721,12 @@ function M.setup(conf)
require("nvim-tree.explorer.watch").setup(opts)
require("nvim-tree.git").setup(opts)
require("nvim-tree.git.utils").setup(opts)
require("nvim-tree.view").setup(opts)
require("nvim-tree.lib").setup(opts)
require("nvim-tree.renderer.components").setup(opts)
require("nvim-tree.buffers").setup(opts)
require("nvim-tree.help").setup(opts)
require("nvim-tree.watcher").setup(opts)
require("nvim-tree.multi-instance-debug").setup(opts)

setup_autocommands(opts)

Expand Down
7 changes: 3 additions & 4 deletions lua/nvim-tree/actions/finders/find-file.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
local log = require("nvim-tree.log")
local view = require("nvim-tree.view")
local utils = require("nvim-tree.utils")
local core = require("nvim-tree.core")

Expand All @@ -14,7 +13,7 @@ local running = {}
---@param path string relative or absolute
function M.fn(path)
local explorer = core.get_explorer()
if not explorer or not view.is_visible() then
if not explorer or not explorer.view:is_visible() then
return
end

Expand Down Expand Up @@ -84,9 +83,9 @@ function M.fn(path)
end)
:iterate()

if found and view.is_visible() then
if found and explorer.view:is_visible() then
explorer.renderer:draw()
view.set_cursor({ line, 0 })
explorer.view:set_cursor({ line, 0 })
end

running[path_real] = false
Expand Down
6 changes: 6 additions & 0 deletions lua/nvim-tree/actions/fs/clipboard.lua
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ local Clipboard = Class:extend()
---@protected
---@param args ClipboardArgs
function Clipboard:new(args)
args.explorer:log_new("Clipboard")

self.explorer = args.explorer

self.data = {
Expand All @@ -42,6 +44,10 @@ function Clipboard:new(args)
self.reg = self.explorer.opts.actions.use_system_clipboard and "+" or "1"
end

function Clipboard:destroy()
self.explorer:log_destroy("Clipboard")
end

---@param source string
---@param destination string
---@return boolean
Expand Down
10 changes: 6 additions & 4 deletions lua/nvim-tree/actions/fs/remove-file.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
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")

Expand All @@ -14,10 +13,12 @@ local M = {

---@param windows integer[]
local function close_windows(windows)
local explorer = core.get_explorer()

-- Prevent from closing when the win count equals 1 or 2,
-- where the win to remove could be the last opened.
-- For details see #2503.
if view.View.float.enable and #vim.api.nvim_list_wins() < 3 then
if explorer and explorer.view.float.enable and #vim.api.nvim_list_wins() < 3 then
return
end

Expand All @@ -30,16 +31,17 @@ end

---@param absolute_path string
local function clear_buffer(absolute_path)
local explorer = core.get_explorer()
local bufs = vim.fn.getbufinfo({ bufloaded = 1, buflisted = 1 })
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 explorer and explorer.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 explorer and not explorer.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
Expand Down
9 changes: 4 additions & 5 deletions lua/nvim-tree/actions/moves/item.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
local utils = require("nvim-tree.utils")
local view = require("nvim-tree.view")
local core = require("nvim-tree.core")
local diagnostics = require("nvim-tree.diagnostics")

Expand Down Expand Up @@ -67,9 +66,9 @@ local function move(explorer, where, what, skip_gitignored)
end

if nex then
view.set_cursor({ nex, 0 })
explorer.view:set_cursor({ nex, 0 })
elseif vim.o.wrapscan and first then
view.set_cursor({ first, 0 })
explorer.view:set_cursor({ first, 0 })
end
end

Expand Down Expand Up @@ -189,13 +188,13 @@ local function move_prev_recursive(explorer, what, skip_gitignored)

-- 4.3)
if node_init.name == ".." then -- root node
view.set_cursor({ 1, 0 }) -- move to root node (position 1)
explorer.view:set_cursor({ 1, 0 }) -- move to root node (position 1)
else
local node_init_line = utils.find_node_line(node_init)
if node_init_line < 0 then
return
end
view.set_cursor({ node_init_line, 0 })
explorer.view:set_cursor({ node_init_line, 0 })
end

-- 4.4)
Expand Down
5 changes: 2 additions & 3 deletions lua/nvim-tree/actions/moves/parent.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
local view = require("nvim-tree.view")
local utils = require("nvim-tree.utils")

local DirectoryNode = require("nvim-tree.node.directory")
Expand All @@ -25,15 +24,15 @@ function M.fn(should_close)
local parent = (node:get_parent_of_group() or node).parent

if not parent or not parent.parent then
view.set_cursor({ 1, 0 })
node.explorer.view:set_cursor({ 1, 0 })
return
end

local _, line = utils.find_node(parent.explorer.nodes, function(n)
return n.absolute_path == parent.absolute_path
end)

view.set_cursor({ line + 1, 0 })
node.explorer.view:set_cursor({ line + 1, 0 })
if should_close then
parent.open = false
parent.explorer.renderer:draw()
Expand Down
Loading
Loading