Skip to content

Commit 76186fa

Browse files
committed
Merge remote-tracking branch 'origin/master' into 2826-multi-instance-view-amc
2 parents e075988 + d87b41c commit 76186fa

File tree

21 files changed

+242
-89
lines changed

21 files changed

+242
-89
lines changed

.hooks/pre-commit.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
#!/bin/sh
1+
#!/usr/bin/env sh
22

33
make

.release-please-manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
".": "1.12.0"
2+
".": "1.13.0"
33
}

CHANGELOG.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,28 @@
11
# Changelog
22

3+
## [1.13.0](https://github.com/nvim-tree/nvim-tree.lua/compare/nvim-tree-v1.12.0...nvim-tree-v1.13.0) (2025-06-14)
4+
5+
6+
### Features
7+
8+
* **#3113:** add renderer.icons.folder_arrow_padding ([#3114](https://github.com/nvim-tree/nvim-tree.lua/issues/3114)) ([ea5097a](https://github.com/nvim-tree/nvim-tree.lua/commit/ea5097a1e2702b4827cb7380e7fa0bd6da87699c))
9+
* **#3132:** add api.node.expand and api.node.collapse ([#3133](https://github.com/nvim-tree/nvim-tree.lua/issues/3133)) ([ae59561](https://github.com/nvim-tree/nvim-tree.lua/commit/ae595611fb2225f2041996c042aa4e4b8663b41e))
10+
11+
12+
### Bug Fixes
13+
14+
* "Invalid buffer id" on closing nvim-tree window ([#3129](https://github.com/nvim-tree/nvim-tree.lua/issues/3129)) ([25d16aa](https://github.com/nvim-tree/nvim-tree.lua/commit/25d16aab7d29ca940a9feb92e6bb734697417009))
15+
* **#2746:** background and right aligned icons in floating windows ([#3128](https://github.com/nvim-tree/nvim-tree.lua/issues/3128)) ([cbc3165](https://github.com/nvim-tree/nvim-tree.lua/commit/cbc3165e08893bb499da035c6f6f9d1512b57664))
16+
* **#3117:** allow changing filename's casing ([bd54d1d](https://github.com/nvim-tree/nvim-tree.lua/commit/bd54d1d33c20d8630703b9842480291588dbad07))
17+
* **#3117:** windows: change file/dir case ([#3135](https://github.com/nvim-tree/nvim-tree.lua/issues/3135)) ([bd54d1d](https://github.com/nvim-tree/nvim-tree.lua/commit/bd54d1d33c20d8630703b9842480291588dbad07))
18+
* **#3122:** remove redundant vim.validate ([#3123](https://github.com/nvim-tree/nvim-tree.lua/issues/3123)) ([e7d1b7d](https://github.com/nvim-tree/nvim-tree.lua/commit/e7d1b7dadc62fe2eccc17d814354b0a5688621ce))
19+
* **#3124:** fix icon padding for "right_align" placements, notably for dotfiles ([#3125](https://github.com/nvim-tree/nvim-tree.lua/issues/3125)) ([e4cd856](https://github.com/nvim-tree/nvim-tree.lua/commit/e4cd856ebf4fec51db10c69d63e43224b701cbce))
20+
* **#3124:** prevent empty icons_right_align response from breaking padding ([e4cd856](https://github.com/nvim-tree/nvim-tree.lua/commit/e4cd856ebf4fec51db10c69d63e43224b701cbce))
21+
* **#3134:** setting one glyph to "" no longer disables others ([#3136](https://github.com/nvim-tree/nvim-tree.lua/issues/3136)) ([ebcaccd](https://github.com/nvim-tree/nvim-tree.lua/commit/ebcaccda1c575fa19a8087445276e6671e2b9b37))
22+
* **#3143:** actions.open_file.window_picker.exclude applies when not using window picker ([#3144](https://github.com/nvim-tree/nvim-tree.lua/issues/3144)) ([05d8172](https://github.com/nvim-tree/nvim-tree.lua/commit/05d8172ebf9cdb2d140cf25b75625374fbc3df7f))
23+
* fixes [#3134](https://github.com/nvim-tree/nvim-tree.lua/issues/3134) ([ebcaccd](https://github.com/nvim-tree/nvim-tree.lua/commit/ebcaccda1c575fa19a8087445276e6671e2b9b37))
24+
* invalid buffer issue ([25d16aa](https://github.com/nvim-tree/nvim-tree.lua/commit/25d16aab7d29ca940a9feb92e6bb734697417009))
25+
326
## [1.12.0](https://github.com/nvim-tree/nvim-tree.lua/compare/nvim-tree-v1.11.0...nvim-tree-v1.12.0) (2025-04-20)
427

528

doc/nvim-tree-lua.txt

Lines changed: 47 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ Show the mappings: `g?`
206206
`S` Search |nvim-tree-api.tree.search_node()|
207207
`u` Rename: Full Path |nvim-tree-api.fs.rename_full()|
208208
`U` Toggle Filter: Hidden |nvim-tree-api.tree.toggle_custom_filter()|
209-
`W` Collapse |nvim-tree-api.tree.collapse_all()|
209+
`W` Collapse All |nvim-tree-api.tree.collapse_all()|
210210
`x` Cut |nvim-tree-api.fs.cut()|
211211
`y` Copy Name |nvim-tree-api.fs.copy.filename()|
212212
`Y` Copy Relative Path |nvim-tree-api.fs.copy.relative_path()|
@@ -341,7 +341,7 @@ See |nvim-tree-highlight| for details.
341341

342342
See |nvim-tree-api.tree.collapse_all()|
343343

344-
Calls: `api.tree.collapse_all(false)`
344+
Calls: `api.tree.collapse_all({ keep_buffers = false })`
345345

346346
*:NvimTreeCollapseKeepBuffers*
347347

@@ -350,7 +350,7 @@ See |nvim-tree-highlight| for details.
350350

351351
See |nvim-tree-api.tree.collapse_all()|
352352

353-
Calls: `api.tree.collapse_all(true)`
353+
Calls: `api.tree.collapse_all({ keep_buffers = true })`
354354

355355
*:NvimTreeHiTest*
356356

@@ -462,7 +462,10 @@ Following is the default configuration. See |nvim-tree-opts| for details. >lua
462462
hidden_placement = "after",
463463
diagnostics_placement = "signcolumn",
464464
bookmarks_placement = "signcolumn",
465-
padding = " ",
465+
padding = {
466+
icon = " ",
467+
folder_arrow = " ",
468+
},
466469
symlink_arrow = " ➛ ",
467470
show = {
468471
file = true,
@@ -1065,10 +1068,14 @@ Configuration options for icons.
10651068
Bookmark icon placement.
10661069
Type: `string`, Default: `signcolumn`
10671070

1068-
*nvim-tree.renderer.icons.padding*
1071+
*nvim-tree.renderer.icons.padding.icon*
10691072
Inserted between icon and filename.
10701073
Type: `string`, Default: `" "`
10711074

1075+
*nvim-tree.renderer.icons.padding.folder_arrow*
1076+
Inserted between folder arrow icon and file/folder icon.
1077+
Type: `string`, Default: `" "`
1078+
10721079
*nvim-tree.renderer.icons.symlink_arrow*
10731080
Used as a separator between symlinks' source and target.
10741081
Type: `string`, Default: `" ➛ "`
@@ -1463,7 +1470,8 @@ vim |current-directory| behaviour.
14631470
Type: `boolean`, Default: `false`
14641471

14651472
*nvim-tree.actions.expand_all*
1466-
Configuration for expand_all behaviour.
1473+
Configuration for |nvim-tree-api.tree.expand_all()| and
1474+
|nvim-tree-api.node.expand()|
14671475

14681476
*nvim-tree.actions.expand_all.max_folder_discovery*
14691477
Limit the number of folders being explored when expanding every folders.
@@ -1516,7 +1524,8 @@ Configuration options for opening a file from nvim-tree.
15161524

15171525
*nvim-tree.actions.open_file.window_picker.enable*
15181526
Enable the feature. If the feature is not enabled, files will open in
1519-
window from which you last opened the tree.
1527+
window from which you last opened the tree, obeying
1528+
|nvim-tree.actions.open_file.window_picker.exclude|
15201529
Type: `boolean`, Default: `true`
15211530

15221531
*nvim-tree.actions.open_file.window_picker.picker*
@@ -1535,9 +1544,10 @@ Configuration options for opening a file from nvim-tree.
15351544
Type: `string`, Default: `"ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890"`
15361545

15371546
*nvim-tree.actions.open_file.window_picker.exclude*
1538-
Table of buffer option names mapped to a list of option values that
1539-
indicates to the picker that the buffer's window should not be
1540-
selectable.
1547+
Table of buffer option names mapped to a list of option values.
1548+
Windows containing matching buffers will not be:
1549+
- available when using a window picker
1550+
- selected when not using a window picker
15411551
Type: `table`, Default: >lua
15421552
{
15431553
filetype = {
@@ -1822,10 +1832,13 @@ tree.find_file({opts}) *nvim-tree-api.tree.find_file()*
18221832
tree.search_node() *nvim-tree-api.tree.search_node()*
18231833
Open the search dialogue as per the search_node action.
18241834

1825-
tree.collapse_all({keep_buffers}) *nvim-tree-api.tree.collapse_all()*
1835+
tree.collapse_all({opts}) *nvim-tree-api.tree.collapse_all()*
18261836
Collapse the tree.
18271837

18281838
Parameters: ~
1839+
{opts} (table) optional parameters
1840+
1841+
Options: ~
18291842
• {keep_buffers} (boolean) do not collapse nodes with open buffers.
18301843

18311844
tree.expand_all({node}) *nvim-tree-api.tree.expand_all()*
@@ -2266,6 +2279,23 @@ node.buffer.wipe({node}, {opts}) *nvim-tree-api.node.buffer.wipe()*
22662279
Options: ~
22672280
{force} (boolean) wipe even if buffer is modified, default false
22682281

2282+
node.expand({node}) *nvim-tree-api.node.expand()*
2283+
Recursively expand all nodes under a directory or a file's parent
2284+
directory.
2285+
2286+
Parameters: ~
2287+
{node} (Node|nil) file or folder
2288+
2289+
node.collapse({node}, {opts}) *nvim-tree-api.node.collapse()*
2290+
Collapse the tree under a directory or a file's parent directory.
2291+
2292+
Parameters: ~
2293+
{node} (Node|nil) file or folder
2294+
{opts} (table) optional parameters
2295+
2296+
Options: ~
2297+
• {keep_buffers} (boolean) do not collapse nodes with open buffers.
2298+
22692299
==============================================================================
22702300
6.4 API GIT *nvim-tree-api.git*
22712301

@@ -2520,7 +2550,7 @@ You are encouraged to copy these to your own |nvim-tree.on_attach| function. >lu
25202550
vim.keymap.set("n", "S", api.tree.search_node, opts("Search"))
25212551
vim.keymap.set("n", "u", api.fs.rename_full, opts("Rename: Full Path"))
25222552
vim.keymap.set("n", "U", api.tree.toggle_custom_filter, opts("Toggle Filter: Hidden"))
2523-
vim.keymap.set("n", "W", api.tree.collapse_all, opts("Collapse"))
2553+
vim.keymap.set("n", "W", api.tree.collapse_all, opts("Collapse All"))
25242554
vim.keymap.set("n", "x", api.fs.cut, opts("Cut"))
25252555
vim.keymap.set("n", "y", api.fs.copy.filename, opts("Copy Name"))
25262556
vim.keymap.set("n", "Y", api.fs.copy.relative_path, opts("Copy Relative Path"))
@@ -3027,6 +3057,7 @@ needed.
30273057
`sort_by` |nvim-tree.sort.sorter|
30283058
`git.ignore` |nvim-tree.filters.git_ignored|
30293059
`renderer.icons.webdev_colors` |nvim-tree.renderer.icons.web_devicons.file.color|
3060+
`renderer.icons.padding` |nvim-tree.renderer.icons.padding.icon|
30303061

30313062
==============================================================================
30323063
14.2 LEGACY: HIGHLIGHT *nvim-tree-legacy-highlight*
@@ -3183,7 +3214,8 @@ highlight group is not, hard linking as follows: >
31833214
|nvim-tree.renderer.icons.glyphs.symlink|
31843215
|nvim-tree.renderer.icons.hidden_placement|
31853216
|nvim-tree.renderer.icons.modified_placement|
3186-
|nvim-tree.renderer.icons.padding|
3217+
|nvim-tree.renderer.icons.padding.folder_arrow|
3218+
|nvim-tree.renderer.icons.padding.icon|
31873219
|nvim-tree.renderer.icons.show|
31883220
|nvim-tree.renderer.icons.show.bookmarks|
31893221
|nvim-tree.renderer.icons.show.diagnostics|
@@ -3290,6 +3322,8 @@ highlight group is not, hard linking as follows: >
32903322
|nvim-tree-api.marks.toggle()|
32913323
|nvim-tree-api.node.buffer.delete()|
32923324
|nvim-tree-api.node.buffer.wipe()|
3325+
|nvim-tree-api.node.collapse()|
3326+
|nvim-tree-api.node.expand()|
32933327
|nvim-tree-api.node.navigate.diagnostics.next()|
32943328
|nvim-tree-api.node.navigate.diagnostics.next_recursive()|
32953329
|nvim-tree-api.node.navigate.diagnostics.prev()|

lua/nvim-tree.lua

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,9 @@ local function setup_autocommands(opts)
214214
pattern = "*",
215215
---@param ev vim.api.keyset.create_autocmd.callback_args
216216
callback = function(ev)
217+
if not vim.api.nvim_buf_is_valid(ev.buf) then
218+
return
219+
end
217220
if vim.api.nvim_get_option_value("filetype", { buf = ev.buf }) == "NvimTree" then
218221
require("nvim-tree.events")._dispatch_on_tree_close()
219222
end
@@ -306,7 +309,10 @@ local DEFAULT_OPTS = { -- BEGIN_DEFAULT_OPTS
306309
hidden_placement = "after",
307310
diagnostics_placement = "signcolumn",
308311
bookmarks_placement = "signcolumn",
309-
padding = " ",
312+
padding = {
313+
icon = " ",
314+
folder_arrow = " ",
315+
},
310316
symlink_arrow = "",
311317
show = {
312318
file = true,

lua/nvim-tree/actions/node/open-file.lua

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -40,21 +40,10 @@ local function usable_win_ids()
4040
end
4141

4242
local win_config = vim.api.nvim_win_get_config(id)
43-
return id ~= tree_winid and win_config.focusable and not win_config.external or false
43+
return id ~= tree_winid and win_config.focusable and not win_config.hide and not win_config.external or false
4444
end, win_ids)
4545
end
4646

47-
---Find the first window in the tab that is not NvimTree.
48-
---@return integer -1 if none available
49-
local function first_win_id()
50-
local selectable = usable_win_ids()
51-
if #selectable > 0 then
52-
return selectable[1]
53-
else
54-
return -1
55-
end
56-
end
57-
5847
---Get user to pick a window in the tab that is not NvimTree.
5948
---@return integer|nil -- If a valid window was picked, return its id. If an
6049
--- invalid window was picked / user canceled, return nil. If there are
@@ -259,9 +248,14 @@ local function get_target_winid(mode)
259248
local target_winid
260249
if not M.window_picker.enable or string.find(mode, "no_picker") then
261250
target_winid = lib.target_winid
262-
-- first available window
263-
if not vim.tbl_contains(vim.api.nvim_tabpage_list_wins(0), target_winid) then
264-
target_winid = first_win_id()
251+
local usable_wins = usable_win_ids()
252+
-- first available usable window
253+
if not vim.tbl_contains(usable_wins, target_winid) then
254+
if #usable_wins > 0 then
255+
target_winid = usable_wins[1]
256+
else
257+
target_winid = -1
258+
end
265259
end
266260
else
267261
-- pick a window

lua/nvim-tree/actions/tree/modifiers/collapse-all.lua renamed to lua/nvim-tree/actions/tree/modifiers/collapse.lua

Lines changed: 31 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ local utils = require("nvim-tree.utils")
22
local core = require("nvim-tree.core")
33
local Iterator = require("nvim-tree.iterators.node-iterator")
44

5+
local FileNode = require("nvim-tree.node.file")
56
local DirectoryNode = require("nvim-tree.node.directory")
67

78
local M = {}
@@ -23,26 +24,30 @@ local function buf_match()
2324
end
2425
end
2526

26-
---@param keep_buffers boolean
27-
function M.fn(keep_buffers)
27+
---Collapse a node, root if nil
28+
---@param node Node?
29+
---@param opts ApiCollapseOpts
30+
local function collapse(node, opts)
2831
local explorer = core.get_explorer()
2932
if not explorer then
3033
return
3134
end
3235

33-
local node = explorer:get_node_at_cursor()
34-
if not node then
36+
node = node or explorer
37+
38+
local node_at_cursor = explorer:get_node_at_cursor()
39+
if not node_at_cursor then
3540
return
3641
end
3742

3843
local matches = buf_match()
3944

40-
Iterator.builder(explorer.nodes)
45+
Iterator.builder({ node:is(FileNode) and node.parent or node:as(DirectoryNode) })
4146
:hidden()
4247
:applier(function(n)
4348
local dir = n:as(DirectoryNode)
4449
if dir then
45-
dir.open = keep_buffers and matches(dir.absolute_path)
50+
dir.open = opts.keep_buffers == true and matches(dir.absolute_path)
4651
end
4752
end)
4853
:recursor(function(n)
@@ -51,7 +56,26 @@ function M.fn(keep_buffers)
5156
:iterate()
5257

5358
explorer.renderer:draw()
54-
utils.focus_node_or_parent(node)
59+
utils.focus_node_or_parent(node_at_cursor)
60+
end
61+
62+
63+
---@param opts ApiCollapseOpts|boolean|nil legacy -> opts.keep_buffers
64+
function M.all(opts)
65+
-- legacy arguments
66+
if type(opts) == "boolean" then
67+
opts = {
68+
keep_buffers = opts,
69+
}
70+
end
71+
72+
collapse(nil, opts or {})
73+
end
74+
75+
---@param node Node
76+
---@param opts ApiCollapseOpts?
77+
function M.node(node, opts)
78+
collapse(node, opts or {})
5579
end
5680

5781
return M

lua/nvim-tree/actions/tree/modifiers/expand-all.lua renamed to lua/nvim-tree/actions/tree/modifiers/expand.lua

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ local core = require("nvim-tree.core")
22
local Iterator = require("nvim-tree.iterators.node-iterator")
33
local notify = require("nvim-tree.notify")
44

5+
local FileNode = require("nvim-tree.node.file")
56
local DirectoryNode = require("nvim-tree.node.directory")
67

78
local M = {}
@@ -70,23 +71,38 @@ local function gen_iterator()
7071
end
7172
end
7273

73-
---Expand the directory node or the root
74-
---@param node Node
75-
function M.fn(node)
76-
local explorer = core.get_explorer()
77-
local parent = node:as(DirectoryNode) or explorer
78-
if not parent then
74+
---@param node Node?
75+
local function expand_node(node)
76+
if not node then
7977
return
8078
end
8179

82-
if gen_iterator()(parent) then
80+
if gen_iterator()(node) then
8381
notify.warn("expansion iteration was halted after " .. M.MAX_FOLDER_DISCOVERY .. " discovered folders")
8482
end
83+
84+
local explorer = core.get_explorer()
8585
if explorer then
8686
explorer.renderer:draw()
8787
end
8888
end
8989

90+
---Expand the directory node or the root
91+
---@param node Node
92+
function M.all(node)
93+
expand_node(node and node:as(DirectoryNode) or core.get_explorer())
94+
end
95+
96+
---Expand the directory node or parent node
97+
---@param node Node
98+
function M.node(node)
99+
if not node then
100+
return
101+
end
102+
103+
expand_node(node:is(FileNode) and node.parent or node:as(DirectoryNode))
104+
end
105+
90106
function M.setup(opts)
91107
M.MAX_FOLDER_DISCOVERY = opts.actions.expand_all.max_folder_discovery
92108
M.EXCLUDE = to_lookup_table(opts.actions.expand_all.exclude)

0 commit comments

Comments
 (0)