Skip to content

Commit 037d89e

Browse files
authored
docs(#3243): renderer.hidden_display help documentation is generated (#3258)
1 parent c07ce43 commit 037d89e

File tree

4 files changed

+93
-62
lines changed

4 files changed

+93
-62
lines changed

doc/nvim-tree-lua.txt

Lines changed: 43 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1808,50 +1808,6 @@ highlight group is not, hard linking as follows: >
18081808
NvimTreeLspDiagnosticsHintFolderText NvimTreeDiagnosticHintFolderHL
18091809
<
18101810

1811-
==============================================================================
1812-
Hidden Display *nvim-tree-hidden-display*
1813-
1814-
Show a summary of hidden files below the tree highlighted with `NvimTreeHiddenDisplay
1815-
1816-
Configure via |nvim_tree.config.renderer| {hidden_display}
1817-
1818-
*nvim_tree.config.renderer.hidden_display*
1819-
`none`: disabled
1820-
`simple`: show how many hidden files are in a folder
1821-
`all`: show how many hidden and the number of hidden files by reason
1822-
• `fun(hidden_stats: table<string, integer>): string`: returns a summary of hidden stats
1823-
1824-
Example `"all"`:
1825-
If a folder has 14 hidden items for various reasons, the display might show: >
1826-
(14 total git: 5, dotfile: 9)
1827-
<
1828-
If a function is provided, it receives a table `hidden_stats` where keys are
1829-
reasons and values are the count of hidden files for that reason.
1830-
1831-
The `hidden_stats` argument is structured as follows, where <num> is the number
1832-
of hidden files related to the field: >
1833-
hidden_stats = {
1834-
bookmark = <num>,
1835-
buf = <num>,
1836-
custom = <num>,
1837-
dotfile = <num>,
1838-
git = <num>,
1839-
live_filter = <num>,
1840-
}
1841-
<
1842-
Example of function that can be passed: >lua
1843-
function(hidden_stats)
1844-
local total_count = 0
1845-
for reason, count in pairs(hidden_stats) do
1846-
total_count = total_count + count
1847-
end
1848-
1849-
if total_count > 0 then
1850-
return "(" .. tostring(total_count) .. " hidden)"
1851-
end
1852-
return nil
1853-
end
1854-
<
18551811

18561812
==============================================================================
18571813
Config *nvim-tree-config*
@@ -2104,6 +2060,19 @@ Config: renderer *nvim-tree-config-renderer*
21042060
end
21052061
<
21062062

2063+
{hidden_display} *nvim_tree.config.renderer.hidden_display*
2064+
2065+
Summary of hidden nodes, below the last node in the directory, highlighted
2066+
with `NvimTreeHiddenDisplay`.
2067+
`"none"`: disabled, default
2068+
`"simple"`: total number of hidden files e.g.
2069+
• (3 hidden)
2070+
`"all"`: total and by reason: the filter that hid the node e.g.
2071+
• (14 total git: 5, dotfile: 9)
2072+
• `(fun(hidden_stats: nvim_tree.config.renderer.hidden_stats): string)`
2073+
2074+
See |nvim_tree.config.renderer.hidden_stats| for details and example.
2075+
21072076
Fields: ~
21082077
• {add_trailing}? (`boolean`, default: `false`) Appends a
21092078
trailing slash to folder and symlink folder
@@ -2121,7 +2090,7 @@ Config: renderer *nvim-tree-config-renderer*
21212090
• {indent_width}? (`integer`, default: `2`) Number of spaces
21222091
for each tree nesting level. Minimum 1.
21232092
• {hidden_display}? (`nvim_tree.config.renderer.hidden_display`, default: `none`)
2124-
|nvim-tree-hidden-display|
2093+
|nvim_tree.config.renderer.hidden_display|
21252094
• {symlink_destination}? (`boolean`, default: `true`) Appends an
21262095
arrow followed by the target of the
21272096
symlink.
@@ -2150,6 +2119,35 @@ Config: renderer *nvim-tree-config-renderer*
21502119
{icons}? (`nvim_tree.config.renderer.icons`)
21512120
|nvim_tree.config.renderer.icons|
21522121

2122+
*nvim_tree.config.renderer.hidden_stats*
2123+
Number of hidden nodes in a directory by reason: the filter that hid the
2124+
node.
2125+
2126+
Passed to your |nvim_tree.config.renderer.hidden_display| function e.g. >lua
2127+
2128+
---@param hidden_stats nvim_tree.config.renderer.hidden_stats
2129+
---@return string? summary
2130+
local my_hidden_display = function(hidden_stats)
2131+
local total_count = 0
2132+
for reason, count in pairs(hidden_stats) do
2133+
total_count = total_count + count
2134+
end
2135+
2136+
if total_count > 0 then
2137+
return "(" .. tostring(total_count) .. " hidden)"
2138+
end
2139+
return nil
2140+
end
2141+
<
2142+
2143+
Fields: ~
2144+
{bookmark} (`integer`)
2145+
{buf} (`integer`)
2146+
{custom} (`integer`)
2147+
{dotfile} (`integer`)
2148+
{git} (`integer`)
2149+
• {live_filter} (`integer`)
2150+
21532151
*nvim_tree.config.renderer.icons*
21542152
Icons and separators
21552153

lua/nvim-tree/_meta/config/renderer.lua

Lines changed: 48 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,6 @@ error("Cannot require a meta file")
33

44

55

6-
---@alias nvim_tree.config.renderer.highlight "none"|"icon"|"name"|"all"
7-
8-
---@alias nvim_tree.config.renderer.hidden_display "none"|"simple"|"all"|(fun(hidden_stats: table<string, integer>): string)
9-
10-
---@alias nvim_tree.config.renderer.icons.placement "before"|"after"|"signcolumn"|"right_align"
11-
12-
13-
146
---Controls the appearance of the tree.
157
---
168
---See [nvim-tree-icons-highlighting] for {highlight_} and {decorators} fields.
@@ -24,6 +16,22 @@ error("Cannot require a meta file")
2416
--- return ".../" .. vim.fn.fnamemodify(path, ":t")
2517
---end
2618
---```
19+
---
20+
---{hidden_display} [nvim_tree.config.renderer.hidden_display]()
21+
---
22+
---Summary of hidden nodes, below the last node in the directory, highlighted with `NvimTreeHiddenDisplay`.
23+
---- `"none"`: disabled, default
24+
---- `"simple"`: total number of hidden files e.g.
25+
--- - (3 hidden)
26+
---- `"all"`: total and by reason: the filter that hid the node e.g.
27+
--- - (14 total git: 5, dotfile: 9)
28+
---- `(fun(hidden_stats: nvim_tree.config.renderer.hidden_stats): string)`
29+
---
30+
---See [nvim_tree.config.renderer.hidden_stats] for details and example.
31+
---@alias nvim_tree.config.renderer.hidden_display "none"|"simple"|"all"|(fun(hidden_stats: nvim_tree.config.renderer.hidden_stats): string?)
32+
---
33+
---@alias nvim_tree.config.renderer.highlight "none"|"icon"|"name"|"all"
34+
---
2735
---@class nvim_tree.config.renderer
2836
---
2937
---Appends a trailing slash to folder and symlink folder target names.
@@ -45,7 +53,7 @@ error("Cannot require a meta file")
4553
---(default: `2`)
4654
---@field indent_width? integer
4755
---
48-
---[nvim-tree-hidden-display]
56+
---[nvim_tree.config.renderer.hidden_display]
4957
---(default: `none`)
5058
---@field hidden_display? nvim_tree.config.renderer.hidden_display
5159
---
@@ -124,6 +132,9 @@ error("Cannot require a meta file")
124132
---Icons and separators
125133
---
126134
---See [nvim-tree-icons-highlighting] for: {_placement} fields.
135+
---
136+
---@alias nvim_tree.config.renderer.icons.placement "before"|"after"|"signcolumn"|"right_align"
137+
---
127138
---@class nvim_tree.config.renderer.icons
128139
---
129140
---(default: `before`)
@@ -301,3 +312,31 @@ error("Cannot require a meta file")
301312
---@field deleted? string
302313
---(default: `"◌"`)
303314
---@field ignored? string
315+
316+
---Number of hidden nodes in a directory by reason: the filter that hid the node.
317+
---
318+
---Passed to your [nvim_tree.config.renderer.hidden_display] function e.g.
319+
---```lua
320+
---
321+
------@param hidden_stats nvim_tree.config.renderer.hidden_stats
322+
------@return string? summary
323+
---local my_hidden_display = function(hidden_stats)
324+
--- local total_count = 0
325+
--- for reason, count in pairs(hidden_stats) do
326+
--- total_count = total_count + count
327+
--- end
328+
---
329+
--- if total_count > 0 then
330+
--- return "(" .. tostring(total_count) .. " hidden)"
331+
--- end
332+
--- return nil
333+
---end
334+
---```
335+
---
336+
---@class nvim_tree.config.renderer.hidden_stats
337+
---@field bookmark integer
338+
---@field buf integer
339+
---@field custom integer
340+
---@field dotfile integer
341+
---@field git integer
342+
---@field live_filter integer

lua/nvim-tree/_meta/config/sort.lua

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,6 @@ error("Cannot require a meta file")
33

44

55

6-
---@alias nvim_tree.config.sort.Sorter "name"|"case_sensitive"|"modification_time"|"extension"|"suffix"|"filetype"
7-
8-
9-
106
---Sort files within a directory.
117
---
128
---{sorter} presets [nvim_tree.config.sort.Sorter]()
@@ -16,6 +12,7 @@ error("Cannot require a meta file")
1612
---- `"extension"` uses all suffixes e.g. `foo.tar.gz` -> `.tar.gz`
1713
---- `"suffix"` uses the last e.g. `foo.tar.gz` -> `.gz`
1814
---- `"filetype"` [filetype]
15+
---@alias nvim_tree.config.sort.Sorter "name"|"case_sensitive"|"modification_time"|"extension"|"suffix"|"filetype"
1916
---
2017
---{sorter} may be a function that is passed a list of `nvim_tree.api.Node` to be sorted in place e.g.
2118
---```lua

lua/nvim-tree/_meta/config/view.lua

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,6 @@ error("Cannot require a meta file")
33

44

55

6-
---@alias nvim_tree.config.view.width.spec string|integer|(fun(): integer|string)
7-
8-
9-
106
---Configures the dimensions and appearance of the nvim-tree window.
117
---
128
---The window is "docked" at the left by default, however may be configured to float: [nvim_tree.config.view.float]
@@ -17,6 +13,7 @@ error("Cannot require a meta file")
1713
---- `string`: `x%` string e.g. `30%`
1814
---- `integer`: number of columns
1915
---- `function`: returns one of the above
16+
---@alias nvim_tree.config.view.width.spec string|integer|(fun(): integer|string)
2017
---
2118
---@class nvim_tree.config.view
2219
---

0 commit comments

Comments
 (0)