Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit e25eb7f

Browse files
evertonsealex-courtis
andauthoredAug 10, 2024··
feat(#2225): add renderer.hidden_display to show a summary of hidden files below the tree (#2856)
* feat(icon_placement): Allow right_align icon_placemente for decorator using ext_marks nvim api * feat(icon_placement): Allow right_align icon_placemente for decorator using ext_marks nvim api feat(icon_placement): Allow right_align icon_placemente for decorator using ext_marks nvim api * feat(icon_placement): consolidate doc * fix: extra namespace added to avoid colision between right_align and full_name features * feat(hidden_display): Allow fine grained rendering of hidden files in a folder * feat(hidden_display): update defaults in Builder to allow rendering * feat(hidden_display): Rename opts function name for the feature * feat(#2349): add "right_align" option for renderer.icons.*_placement (#2846) * feat(icon_placement): Allow right_align icon_placemente for decorator using ext_marks nvim api * feat(icon_placement): Allow right_align icon_placemente for decorator using ext_marks nvim api feat(icon_placement): Allow right_align icon_placemente for decorator using ext_marks nvim api * feat(icon_placement): consolidate doc * fix: extra namespace added to avoid colision between right_align and full_name features * style: rename namespace_id --------- Co-authored-by: Alexander Courtis <[email protected]> * docs: update docs * feat(hidden_display): Simplification and better performance by not sorting and grouping virtual lines * Update doc/nvim-tree-lua.txt Co-authored-by: Alexander Courtis <[email protected]> * style: hidden_stats is better * docs: change to hidden_stats * add separate namespace for virtual lines * help: add highlight group --------- Co-authored-by: Alexander Courtis <[email protected]>
1 parent 48d0e82 commit e25eb7f

File tree

14 files changed

+258
-10
lines changed

14 files changed

+258
-10
lines changed
 

‎doc/nvim-tree-lua.txt

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,7 @@ Following is the default configuration. See |nvim-tree-opts| for details.
423423
root_folder_label = ":~:s?$?/..?",
424424
indent_width = 2,
425425
special_files = { "Cargo.toml", "Makefile", "README.md", "readme.md" },
426+
hidden_display = "none",
426427
symlink_destination = true,
427428
highlight_git = "none",
428429
highlight_diagnostics = "none",
@@ -878,6 +879,49 @@ Number of spaces for an each tree nesting level. Minimum 1.
878879
A list of filenames that gets highlighted with `NvimTreeSpecialFile`.
879880
Type: `table`, Default: `{ "Cargo.toml", "Makefile", "README.md", "readme.md", }`
880881

882+
*nvim-tree.renderer.hidden_display*
883+
Show a summary of hidden files below the tree using `NvimTreeHiddenDisplay
884+
Type: `function | string`, Default: `"none"`
885+
886+
Possible string values are:
887+
- `"none"`: Doesn't inform anything about hidden files.
888+
- `"simple"`: Shows how many hidden files are in a folder.
889+
- `"all"`: Shows how many files are hidden and the number of hidden
890+
files per reason why they're hidden.
891+
892+
Example `"all"`:
893+
If a folder has 14 hidden items for various reasons, the display might
894+
show: >
895+
(14 total git: 5, dotfile: 9)
896+
<
897+
If a function is provided, it receives a table `hidden_stats` where keys are
898+
reasons and values are the count of hidden files for that reason.
899+
900+
The `hidden_stats` argument is structured as follows, where <num> is the
901+
number of hidden files related to the field: >
902+
hidden_stats = {
903+
bookmark = <num>,
904+
buf = <num>,
905+
custom = <num>,
906+
dotfile = <num>,
907+
git = <num>,
908+
live_filter = <num>,
909+
}
910+
<
911+
Example of function that can be passed: >
912+
function(hidden_stats)
913+
local total_count = 0
914+
for reason, count in pairs(hidden_stats) do
915+
total_count = total_count + count
916+
end
917+
918+
if total_count > 0 then
919+
return "(" .. tostring(total_count) .. " hidden)"
920+
end
921+
return nil
922+
end
923+
<
924+
881925
*nvim-tree.renderer.symlink_destination*
882926
Whether to show the destination of the symlink.
883927
Type: `boolean`, Default: `true`
@@ -2461,6 +2505,9 @@ Hidden: >
24612505
NvimTreeModifiedFileHL NvimTreeHiddenIcon
24622506
NvimTreeModifiedFolderHL NvimTreeHiddenFileHL
24632507
<
2508+
Hidden Display: >
2509+
NvimTreeHiddenDisplay Conceal
2510+
<
24642511
Opened: >
24652512
NvimTreeOpenedHL Special
24662513
<
@@ -2872,6 +2919,7 @@ highlight group is not, hard linking as follows: >
28722919
|nvim-tree.renderer.add_trailing|
28732920
|nvim-tree.renderer.full_name|
28742921
|nvim-tree.renderer.group_empty|
2922+
|nvim-tree.renderer.hidden_display|
28752923
|nvim-tree.renderer.highlight_bookmarks|
28762924
|nvim-tree.renderer.highlight_clipboard|
28772925
|nvim-tree.renderer.highlight_diagnostics|

‎lua/nvim-tree.lua

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,7 @@ local DEFAULT_OPTS = { -- BEGIN_DEFAULT_OPTS
398398
root_folder_label = ":~:s?$?/..?",
399399
indent_width = 2,
400400
special_files = { "Cargo.toml", "Makefile", "README.md", "readme.md" },
401+
hidden_display = "none",
401402
symlink_destination = true,
402403
highlight_git = "none",
403404
highlight_diagnostics = "none",
@@ -647,6 +648,7 @@ local ACCEPTED_TYPES = {
647648
},
648649
},
649650
renderer = {
651+
hidden_display = { "function", "string" },
650652
group_empty = { "boolean", "function" },
651653
root_folder_label = { "function", "string", "boolean" },
652654
},
@@ -680,6 +682,7 @@ local ACCEPTED_STRINGS = {
680682
signcolumn = { "yes", "no", "auto" },
681683
},
682684
renderer = {
685+
hidden_display = { "none", "simple", "all" },
683686
highlight_git = { "none", "icon", "name", "all" },
684687
highlight_opened_files = { "none", "icon", "name", "all" },
685688
highlight_modified = { "none", "icon", "name", "all" },

‎lua/nvim-tree/appearance/init.lua

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ M.HIGHLIGHT_GROUPS = {
1414
-- Standard
1515
{ group = "NvimTreeNormal", link = "Normal" },
1616
{ group = "NvimTreeNormalFloat", link = "NormalFloat" },
17+
{ group = "NvimTreeNormalFloatBorder", link = "FloatBorder" },
1718
{ group = "NvimTreeNormalNC", link = "NvimTreeNormal" },
1819

1920
{ group = "NvimTreeLineNr", link = "LineNr" },
@@ -81,6 +82,9 @@ M.HIGHLIGHT_GROUPS = {
8182
{ group = "NvimTreeHiddenFileHL", link = "NvimTreeHiddenIcon" },
8283
{ group = "NvimTreeHiddenFolderHL", link = "NvimTreeHiddenFileHL" },
8384

85+
-- Hidden Display
86+
{ group = "NvimTreeHiddenDisplay", link = "Conceal" },
87+
8488
-- Opened
8589
{ group = "NvimTreeOpenedHL", link = "Special" },
8690

‎lua/nvim-tree/enum.lua

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,15 @@ M.ICON_PLACEMENT = {
1919
right_align = 4,
2020
}
2121

22+
---Reason for filter in filter.lua
23+
---@enum FILTER_REASON
24+
M.FILTER_REASON = {
25+
none = 0, -- It's not filtered
26+
git = 1,
27+
buf = 2,
28+
dotfile = 4,
29+
custom = 8,
30+
bookmark = 16,
31+
}
32+
2233
return M

‎lua/nvim-tree/explorer/explore.lua

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ local git = require "nvim-tree.git"
55
local live_filter = require "nvim-tree.live-filter"
66
local log = require "nvim-tree.log"
77

8+
local FILTER_REASON = require("nvim-tree.enum").FILTER_REASON
89
local Watcher = require "nvim-tree.watcher"
910

1011
local M = {}
@@ -17,7 +18,17 @@ local M = {}
1718
local function populate_children(handle, cwd, node, git_status, parent)
1819
local node_ignored = explorer_node.is_git_ignored(node)
1920
local nodes_by_path = utils.bool_record(node.nodes, "absolute_path")
21+
2022
local filter_status = parent.filters:prepare(git_status)
23+
24+
node.hidden_stats = vim.tbl_deep_extend("force", node.hidden_stats or {}, {
25+
git = 0,
26+
buf = 0,
27+
dotfile = 0,
28+
custom = 0,
29+
bookmark = 0,
30+
})
31+
2132
while true do
2233
local name, t = vim.loop.fs_scandir_next(handle)
2334
if not name then
@@ -29,8 +40,8 @@ local function populate_children(handle, cwd, node, git_status, parent)
2940

3041
---@type uv.fs_stat.result|nil
3142
local stat = vim.loop.fs_stat(abs)
32-
33-
if not parent.filters:should_filter(abs, stat, filter_status) and not nodes_by_path[abs] and Watcher.is_fs_event_capable(abs) then
43+
local filter_reason = parent.filters:should_filter_as_reason(abs, stat, filter_status)
44+
if filter_reason == FILTER_REASON.none and not nodes_by_path[abs] and Watcher.is_fs_event_capable(abs) then
3445
local child = nil
3546
if t == "directory" and vim.loop.fs_access(abs, "R") then
3647
child = builders.folder(node, abs, name, stat)
@@ -47,6 +58,12 @@ local function populate_children(handle, cwd, node, git_status, parent)
4758
nodes_by_path[child.absolute_path] = true
4859
explorer_node.update_git_status(child, node_ignored, git_status)
4960
end
61+
else
62+
for reason, value in pairs(FILTER_REASON) do
63+
if filter_reason == value then
64+
node.hidden_stats[reason] = node.hidden_stats[reason] + 1
65+
end
66+
end
5067
end
5168

5269
log.profile_end(profile)

‎lua/nvim-tree/explorer/filters.lua

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
local utils = require "nvim-tree.utils"
2+
local FILTER_REASON = require("nvim-tree.enum").FILTER_REASON
23

34
---@class Filters to handle all opts.filters and related API
45
---@field config table hydrated user opts.filters
@@ -223,4 +224,33 @@ function Filters:should_filter(path, fs_stat, status)
223224
or bookmark(self, path, fs_stat and fs_stat.type, status.bookmarks)
224225
end
225226

227+
--- Check if the given path should be filtered, and provide the reason why it was
228+
---@param path string Absolute path
229+
---@param fs_stat uv.fs_stat.result|nil fs_stat of file
230+
---@param status table from prepare
231+
---@return FILTER_REASON
232+
function Filters:should_filter_as_reason(path, fs_stat, status)
233+
if not self.config.enable then
234+
return FILTER_REASON.none
235+
end
236+
237+
if is_excluded(self, path) then
238+
return FILTER_REASON.none
239+
end
240+
241+
if git(self, path, status.git_status) then
242+
return FILTER_REASON.git
243+
elseif buf(self, path, status.bufinfo) then
244+
return FILTER_REASON.buf
245+
elseif dotfile(self, path) then
246+
return FILTER_REASON.dotfile
247+
elseif custom(self, path) then
248+
return FILTER_REASON.custom
249+
elseif bookmark(self, path, fs_stat and fs_stat.type, status.bookmarks) then
250+
return FILTER_REASON.bookmark
251+
else
252+
return FILTER_REASON.none
253+
end
254+
end
255+
226256
return Filters

‎lua/nvim-tree/explorer/reload.lua

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ local live_filter = require "nvim-tree.live-filter"
55
local git = require "nvim-tree.git"
66
local log = require "nvim-tree.log"
77

8+
local FILTER_REASON = require("nvim-tree.enum").FILTER_REASON
89
local NodeIterator = require "nvim-tree.iterators.node-iterator"
910
local Watcher = require "nvim-tree.watcher"
1011

@@ -92,6 +93,16 @@ function M.reload(node, git_status)
9293
local node_ignored = explorer_node.is_git_ignored(node)
9394
---@type table<string, Node>
9495
local nodes_by_path = utils.key_by(node.nodes, "absolute_path")
96+
97+
-- To reset we must 'zero' everything that we use
98+
node.hidden_stats = vim.tbl_deep_extend("force", node.hidden_stats or {}, {
99+
git = 0,
100+
buf = 0,
101+
dotfile = 0,
102+
custom = 0,
103+
bookmark = 0,
104+
})
105+
95106
while true do
96107
local name, t = vim.loop.fs_scandir_next(handle)
97108
if not name then
@@ -102,7 +113,8 @@ function M.reload(node, git_status)
102113
---@type uv.fs_stat.result|nil
103114
local stat = vim.loop.fs_stat(abs)
104115

105-
if not explorer.filters:should_filter(abs, stat, filter_status) then
116+
local filter_reason = explorer.filters:should_filter_as_reason(abs, stat, filter_status)
117+
if filter_reason == FILTER_REASON.none then
106118
remain_childs[abs] = true
107119

108120
-- Recreate node if type changes.
@@ -139,6 +151,12 @@ function M.reload(node, git_status)
139151
n.fs_stat = stat
140152
end
141153
end
154+
else
155+
for reason, value in pairs(FILTER_REASON) do
156+
if filter_reason == value then
157+
node.hidden_stats[reason] = node.hidden_stats[reason] + 1
158+
end
159+
end
142160
end
143161
end
144162

‎lua/nvim-tree/live-filter.lua

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,17 @@ local function reset_filter(node_)
1818
return
1919
end
2020

21+
node_.hidden_stats = vim.tbl_deep_extend("force", node_.hidden_stats or {}, {
22+
live_filter = 0,
23+
})
24+
2125
Iterator.builder(node_.nodes)
2226
:hidden()
2327
:applier(function(node)
2428
node.hidden = false
29+
node.hidden_stats = vim.tbl_deep_extend("force", node.hidden_stats or {}, {
30+
live_filter = 0,
31+
})
2532
end)
2633
:iterate()
2734
end
@@ -79,6 +86,10 @@ function M.apply_filter(node_)
7986
local filtered_nodes = 0
8087
local nodes = node.group_next and { node.group_next } or node.nodes
8188

89+
node.hidden_stats = vim.tbl_deep_extend("force", node.hidden_stats or {}, {
90+
live_filter = 0,
91+
})
92+
8293
if nodes then
8394
for _, n in pairs(nodes) do
8495
iterate(n)
@@ -88,6 +99,8 @@ function M.apply_filter(node_)
8899
end
89100
end
90101

102+
node.hidden_stats.live_filter = filtered_nodes
103+
91104
local has_nodes = nodes and (M.always_show_folders or #nodes > filtered_nodes)
92105
local ok, is_match = pcall(matches, node)
93106
node.hidden = not (has_nodes or (ok and is_match))

‎lua/nvim-tree/node.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
---@field group_next Node|nil
2222
---@field nodes Node[]
2323
---@field open boolean
24+
---@field hidden_stats table -- Each field of this table is a key for source and value for count
2425

2526
---@class FileNode: BaseNode
2627
---@field extension string

‎lua/nvim-tree/renderer/builder.lua

Lines changed: 73 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ local M = {
4343
---@field lines string[] includes icons etc.
4444
---@field hl_args AddHighlightArgs[] line highlights
4545
---@field signs string[] line signs
46+
---@field extmarks table[] extra marks for right icon placement
47+
---@field virtual_lines table[] virtual lines for hidden count display
4648
---@field private root_cwd string absolute path
4749
---@field private index number
4850
---@field private depth number
@@ -62,6 +64,7 @@ function Builder:new()
6264
markers = {},
6365
signs = {},
6466
extmarks = {},
67+
virtual_lines = {},
6568
}
6669
setmetatable(o, self)
6770
self.__index = self
@@ -351,14 +354,39 @@ function Builder:build_line(node, idx, num_children)
351354
self.index = self.index + 1
352355

353356
node = require("nvim-tree.lib").get_last_group_node(node)
354-
355357
if node.open then
356358
self.depth = self.depth + 1
357359
self:build_lines(node)
358360
self.depth = self.depth - 1
359361
end
360362
end
361363

364+
---Add virtual lines for rendering hidden count information per node
365+
---@private
366+
function Builder:add_hidden_count_string(node, idx, num_children)
367+
if not node.open then
368+
return
369+
end
370+
local hidden_count_string = M.opts.renderer.hidden_display(node.hidden_stats)
371+
if hidden_count_string and hidden_count_string ~= "" then
372+
local indent_markers = pad.get_indent_markers(self.depth, idx or 0, num_children or 0, node, self.markers, 1)
373+
local indent_width = M.opts.renderer.indent_width
374+
375+
local indent_padding = string.rep(" ", indent_width)
376+
local indent_string = indent_padding .. indent_markers.str
377+
local line_nr = #self.lines - 1
378+
self.virtual_lines[line_nr] = self.virtual_lines[line_nr] or {}
379+
380+
-- NOTE: We are inserting in depth order because of current traversal
381+
-- if we change the traversal, we might need to sort by depth before rendering `self.virtual_lines`
382+
-- to maintain proper ordering of parent and child folder hidden count info.
383+
table.insert(self.virtual_lines[line_nr], {
384+
{ indent_string, indent_markers.hl },
385+
{ string.rep(indent_padding, (node.parent == nil and 0 or 1)) .. hidden_count_string, "NvimTreeHiddenDisplay" },
386+
})
387+
end
388+
end
389+
362390
---@private
363391
function Builder:get_nodes_number(nodes)
364392
if not live_filter.filter then
@@ -388,6 +416,7 @@ function Builder:build_lines(node)
388416
idx = idx + 1
389417
end
390418
end
419+
self:add_hidden_count_string(node)
391420
end
392421

393422
---@private
@@ -442,7 +471,50 @@ function Builder:build()
442471
return self
443472
end
444473

474+
---@param opts table
475+
local setup_hidden_display_function = function(opts)
476+
local hidden_display = opts.renderer.hidden_display
477+
-- options are already validated, so ´hidden_display´ can ONLY be `string` or `function` if type(hidden_display) == "string" then
478+
if type(hidden_display) == "string" then
479+
if hidden_display == "none" then
480+
opts.renderer.hidden_display = function()
481+
return nil
482+
end
483+
elseif hidden_display == "simple" then
484+
opts.renderer.hidden_display = function(hidden_stats)
485+
return utils.default_format_hidden_count(hidden_stats, true)
486+
end
487+
elseif hidden_display == "all" then
488+
opts.renderer.hidden_display = function(hidden_stats)
489+
return utils.default_format_hidden_count(hidden_stats, false)
490+
end
491+
end
492+
elseif type(hidden_display) == "function" then
493+
local safe_render = function(hidden_stats)
494+
-- In case of missing field such as live_filter we zero it, otherwise keep field as is
495+
hidden_stats = vim.tbl_deep_extend("force", {
496+
live_filter = 0,
497+
git = 0,
498+
buf = 0,
499+
dotfile = 0,
500+
custom = 0,
501+
bookmark = 0,
502+
}, hidden_stats or {})
503+
504+
local ok, result = pcall(hidden_display, hidden_stats)
505+
if not ok then
506+
notify.warn "Problem occurred in the function ``opts.renderer.hidden_display`` see nvim-tree.renderer.hidden_display on :h nvim-tree"
507+
return nil
508+
end
509+
return result
510+
end
511+
512+
opts.renderer.hidden_display = safe_render
513+
end
514+
end
515+
445516
function Builder.setup(opts)
517+
setup_hidden_display_function(opts)
446518
M.opts = opts
447519

448520
-- priority order

‎lua/nvim-tree/renderer/components/padding.lua

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,15 @@ local function check_siblings_for_folder(node, with_arrows)
1919
return false
2020
end
2121

22-
local function get_padding_indent_markers(depth, idx, nodes_number, markers, with_arrows, inline_arrows, node)
22+
local function get_padding_indent_markers(depth, idx, nodes_number, markers, with_arrows, inline_arrows, node, early_stop)
2323
local base_padding = with_arrows and (not node.nodes or depth > 0) and " " or ""
2424
local padding = (inline_arrows or depth == 0) and base_padding or ""
2525

2626
if depth > 0 then
2727
local has_folder_sibling = check_siblings_for_folder(node, with_arrows)
2828
local indent = string.rep(" ", M.config.indent_width - 1)
2929
markers[depth] = idx ~= nodes_number
30-
for i = 1, depth do
30+
for i = 1, depth - early_stop do
3131
local glyph
3232
if idx == nodes_number and i == depth then
3333
local bottom_width = M.config.indent_width - 2 + (with_arrows and not inline_arrows and has_folder_sibling and 2 or 0)
@@ -62,7 +62,7 @@ end
6262
---@param node table
6363
---@param markers table
6464
---@return HighlightedString[]
65-
function M.get_indent_markers(depth, idx, nodes_number, node, markers)
65+
function M.get_indent_markers(depth, idx, nodes_number, node, markers, early_stop)
6666
local str = ""
6767

6868
local show_arrows = M.config.icons.show.folder_arrow
@@ -71,7 +71,7 @@ function M.get_indent_markers(depth, idx, nodes_number, node, markers)
7171
local indent_width = M.config.indent_width
7272

7373
if show_markers then
74-
str = str .. get_padding_indent_markers(depth, idx, nodes_number, markers, show_arrows, inline_arrows, node)
74+
str = str .. get_padding_indent_markers(depth, idx, nodes_number, markers, show_arrows, inline_arrows, node, early_stop or 0)
7575
else
7676
str = str .. string.rep(" ", depth * indent_width)
7777
end

‎lua/nvim-tree/renderer/init.lua

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,13 @@ local SIGN_GROUP = "NvimTreeRendererSigns"
1414

1515
local namespace_highlights_id = vim.api.nvim_create_namespace "NvimTreeHighlights"
1616
local namespace_extmarks_id = vim.api.nvim_create_namespace "NvimTreeExtmarks"
17+
local namespace_virtual_lines_id = vim.api.nvim_create_namespace "NvimTreeVirtualLines"
1718

1819
---@param bufnr number
1920
---@param lines string[]
2021
---@param hl_args AddHighlightArgs[]
2122
---@param signs string[]
22-
local function _draw(bufnr, lines, hl_args, signs, extmarks)
23+
local function _draw(bufnr, lines, hl_args, signs, extmarks, virtual_lines)
2324
if vim.fn.has "nvim-0.10" == 1 then
2425
vim.api.nvim_set_option_value("modifiable", true, { buf = bufnr })
2526
else
@@ -50,6 +51,15 @@ local function _draw(bufnr, lines, hl_args, signs, extmarks)
5051
})
5152
end
5253
end
54+
55+
vim.api.nvim_buf_clear_namespace(bufnr, namespace_virtual_lines_id, 0, -1)
56+
for line_nr, vlines in pairs(virtual_lines) do
57+
vim.api.nvim_buf_set_extmark(bufnr, namespace_virtual_lines_id, line_nr, 0, {
58+
virt_lines = vlines,
59+
virt_lines_above = false,
60+
virt_lines_leftcol = true,
61+
})
62+
end
5363
end
5464

5565
function M.render_hl(bufnr, hl)
@@ -79,7 +89,7 @@ function M.draw()
7989

8090
local builder = Builder:new():build()
8191

82-
_draw(bufnr, builder.lines, builder.hl_args, builder.signs, builder.extmarks)
92+
_draw(bufnr, builder.lines, builder.hl_args, builder.signs, builder.extmarks, builder.virtual_lines)
8393

8494
if cursor and #builder.lines >= cursor[1] then
8595
vim.api.nvim_win_set_cursor(view.get_winnr() or 0, cursor)

‎lua/nvim-tree/utils.lua

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,26 @@ function M.get_parent_of_group(node)
181181
return node
182182
end
183183

184+
M.default_format_hidden_count = function(hidden_count, simple)
185+
local parts = {}
186+
local total_count = 0
187+
for reason, count in pairs(hidden_count) do
188+
total_count = total_count + count
189+
if count > 0 then
190+
table.insert(parts, reason .. ": " .. tostring(count))
191+
end
192+
end
193+
194+
local hidden_count_string = table.concat(parts, ", ") -- if empty then is "" (empty string)
195+
if simple then
196+
hidden_count_string = ""
197+
end
198+
if total_count > 0 then
199+
return "(" .. tostring(total_count) .. (simple and " hidden" or " total ") .. hidden_count_string .. ")"
200+
end
201+
return nil
202+
end
203+
184204
--- Return visible nodes indexed by line
185205
---@param nodes_all Node[]
186206
---@param line_start number

‎lua/nvim-tree/view.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ M.View = {
5050
"Normal:NvimTreeNormal",
5151
"NormalNC:NvimTreeNormalNC",
5252
"NormalFloat:NvimTreeNormalFloat",
53+
"FloatBorder:NvimTreeNormalFloatBorder",
5354
}, ","),
5455
},
5556
}

0 commit comments

Comments
 (0)
Please sign in to comment.