Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
207 commits
Select commit Hold shift + click to select a range
7eb61f5
doc(#2934): POC to use gen_vimdoc.lua for decorator meta
alex-courtis Jan 4, 2026
cbfffc6
doc(#2934): use injected gen_vimdoc.lua from nvim source, move decora…
alex-courtis Jan 4, 2026
a5a823b
doc(#2934): tidy and harden scripts
alex-courtis Jan 4, 2026
1960d3a
doc(#2934): add nvim_tree.Config meta classes, add nvim_tree.api. met…
alex-courtis Jan 5, 2026
02c3ecf
doc(#2934): add nvim_tree.Config to help
alex-courtis Jan 5, 2026
d14385f
doc(#2934): add nvim_tree.api classes to help
alex-courtis Jan 5, 2026
d733127
doc(#2934): tidy and correct nvim_tree.Config.UI and nvim_tree.Config…
alex-courtis Jan 5, 2026
4221d19
doc(#2934): tidy and correct nvim_tree.Config.HijackDirectories, form…
alex-courtis Jan 5, 2026
d14677d
doc(#2934): tidy and nvim_tree.Config top level
alex-courtis Jan 5, 2026
86bd8a6
doc(#2934): tidy and format nvim_tree.Config.LiveFilter, Modified, Ta…
alex-courtis Jan 5, 2026
a836f79
doc(#2934): tidy and format nvim_tree.Config.FilesystemWatchers, Log
alex-courtis Jan 5, 2026
b1adfad
doc(#2934): split nvim_tree.Config into files, Sort and HijackDirecto…
alex-courtis Jan 6, 2026
22c1f1b
doc(#2934): more generic gen_vimdoc_config module config
alex-courtis Jan 6, 2026
54dddc3
doc(#2934): tidy Config.HijackDirectories and Actions, move them into…
alex-courtis Jan 6, 2026
8f1f516
doc(#2934): tidy Config.Modified, move into place
alex-courtis Jan 6, 2026
b59183a
doc(#2934): tidy Config.LiveFilter, move into place
alex-courtis Jan 6, 2026
628e9bf
doc(#2934): tidy Config.FilesystemWatchers, move into place
alex-courtis Jan 6, 2026
a6142a2
doc(#2934): tidy Config.Trash, move into place
alex-courtis Jan 6, 2026
d1fd1d4
doc(#2934): tidy Config.Tab, move into place
alex-courtis Jan 6, 2026
b449929
doc(#2934): tidy Config.UI, move into place
alex-courtis Jan 6, 2026
d64aa2d
doc(#2934): tidy Config.Log, move into place
alex-courtis Jan 6, 2026
1aad39e
doc(#2934): tidy Config.Notify, move into place
alex-courtis Jan 6, 2026
1feb014
doc(#2934): tidy Config.SystemOpen, move into place
alex-courtis Jan 6, 2026
e690484
doc(#2934): tidy Config.Help, move into place
alex-courtis Jan 6, 2026
4727f9c
doc(#2934): tidy Config.Help, move into place
alex-courtis Jan 6, 2026
2384e2b
doc(#2934): tidy Config.Help, move into place
alex-courtis Jan 6, 2026
dbdf846
doc(#2934): tidy Config.Diagnostics, move into place
alex-courtis Jan 6, 2026
6faff06
doc(#2934): remove api/decorator as they are out of scope, revert api…
alex-courtis Jan 6, 2026
2554582
doc(#2934): tidy Config.Filters, move into place
alex-courtis Jan 6, 2026
3fea7f4
doc(#2934): tidy Config.FilesystemWatchers, move into place
alex-courtis Jan 6, 2026
1988d5e
doc(#2934): tidy Config.FilesystemWatchers, Git, move into place
alex-courtis Jan 9, 2026
2329508
doc(#2934): tidy Config.UpdateFocusedFile, move into place
alex-courtis Jan 9, 2026
c961bd4
doc(#2934): tidy Config.Sort, move into place
alex-courtis Jan 10, 2026
745fc54
doc(#2934): tidy Config.View, move into place
alex-courtis Jan 10, 2026
6f2744f
doc(#2934): tidy Config.View, move into place
alex-courtis Jan 10, 2026
fd92856
docs(#2934): type DEFAULT_OPTS, use bracketed references to keep lual…
alex-courtis Jan 10, 2026
453b31f
docs(#2934): tidy, inline some classes
alex-courtis Jan 10, 2026
1b21a08
docs(#2934): tidy Config.Renderer
alex-courtis Jan 10, 2026
93e3122
docs(#2934): remove problematic glyphs, tidy other glyphs
alex-courtis Jan 11, 2026
25d57bc
docs(#2934): tidy Config.Renderer, ensure functions are parenthesised…
alex-courtis Jan 11, 2026
3895114
docs(#2934): tidy Config.Renderer
alex-courtis Jan 12, 2026
53db2d0
docs(#2934): tidy Config.Renderer, move into place
alex-courtis Jan 12, 2026
795dde7
docs(#2934): tidy Config.Renderer
alex-courtis Jan 12, 2026
b60fa05
docs(#2934): tidy Config.FilesystemWatchers
alex-courtis Jan 12, 2026
f15aa33
docs(#2934): fix broken links
alex-courtis Jan 12, 2026
06fcb5e
docs(#2934): fix broken links
alex-courtis Jan 12, 2026
aa915c4
docs(#2934): fix broken links
alex-courtis Jan 12, 2026
5c133d3
docs(#2934): fix broken links
alex-courtis Jan 12, 2026
fd4c17d
docs(#2934): refer to nvim in help, not neovim, as this trips the lin…
alex-courtis Jan 12, 2026
e7ae9f0
docs(#2934): fix broken links
alex-courtis Jan 12, 2026
2fcf8a0
docs(#2934): add lintdoc.sh, fix some branding spelling
alex-courtis Jan 12, 2026
316f98b
docs(#2934): update old config links
alex-courtis Jan 12, 2026
d6e5d73
docs(#2934): remove 5. Opts, 8.2 Highlight: Overhaul, 15.1 Index: O…
alex-courtis Jan 12, 2026
2c27f24
docs(#2934): remove indices
alex-courtis Jan 13, 2026
8bfd76f
docs(#2934): add bookmarks, put long descriptions into @brief
alex-courtis Jan 13, 2026
bb53ccd
docs(#2934): move hidden display to verbatim new section
alex-courtis Jan 13, 2026
59d6946
docs(#2934): add config lsp examples, link setup
alex-courtis Jan 13, 2026
a66e30a
docs(#2934): normalise heading formatting, remove TOC
alex-courtis Jan 13, 2026
71c7ed4
docs(#2934): move all icon and highlight info into a table
alex-courtis Jan 14, 2026
531fb94
docs(#2934): move all icon and highlight info into a new section
alex-courtis Jan 14, 2026
5538e01
docs(#2934): normalise all icon and highlight
alex-courtis Jan 14, 2026
3713b69
docs(#2934): extract nvim_tree.Config field descriptions to class ove…
alex-courtis Jan 14, 2026
0a8b2ca
docs(#2934): consistent string formatting
alex-courtis Jan 14, 2026
e5f0c6f
docs(#2934): normalise all icon and highlight
alex-courtis Jan 14, 2026
e470cd1
docs(#2934): remove @briefs as they are shown above the class tag
alex-courtis Jan 14, 2026
6c0e683
docs(#2934): don't <pre> filters
alex-courtis Jan 14, 2026
20b2be1
docs(#2934): add experimental example
alex-courtis Jan 14, 2026
4b654db
docs(#2934): add gen_vimdoc.sh to CI
alex-courtis Jan 15, 2026
0a3df5e
docs(#2934): add gen_vimdoc.sh to CI
alex-courtis Jan 15, 2026
385cfb0
docs(#2934): add gen_vimdoc.sh to CI
alex-courtis Jan 15, 2026
350b590
docs(#2934): temporarily --ignore-blank-lines during help check
alex-courtis Jan 15, 2026
b39bb2b
docs(#2934): add lintdoc.sh to CI
alex-courtis Jan 15, 2026
c2b08fd
docs(#2934): add lintdoc.sh to CI
alex-courtis Jan 15, 2026
f0490bc
docs(#2934): add lintdoc.sh to CI
alex-courtis Jan 15, 2026
4be6efc
docs(#2934): move Nvim build and help-check to the end for faster tur…
alex-courtis Jan 15, 2026
56f486a
docs(#2934): use make lintdoc target directly
alex-courtis Jan 15, 2026
ada718b
docs(#2934): CONTRIBUTING.md updates for help generation and lint
alex-courtis Jan 15, 2026
cdb730d
docs(#2934): revert API opts classes changes
alex-courtis Jan 15, 2026
a0662de
Merge branch 'master' into 2934-gen_vimdoc
alex-courtis Jan 15, 2026
cddb56f
docs(#2934): harden gen and lint scripts, moving things out of nvim-t…
alex-courtis Jan 17, 2026
9627fb8
docs(#2934): harden gen and lint scripts, moving things out of nvim-t…
alex-courtis Jan 17, 2026
de9c62c
docs(#2934): fix lintdoc make target
alex-courtis Jan 17, 2026
2061b93
docs(#3088): extract api/tree.lua
alex-courtis Jan 17, 2026
c689008
docs(#3088): extract api/tree.lua
alex-courtis Jan 17, 2026
521e467
docs(#2934): move help diff check after lint
alex-courtis Jan 17, 2026
10be08b
docs(#3088): update api.tree references, remove old doc
alex-courtis Jan 17, 2026
060455e
docs(#3088): extract api/config/mappings.lua
alex-courtis Jan 17, 2026
4292f97
docs(#3088): api.config.mappings -> api.map
alex-courtis Jan 18, 2026
6f2551b
docs(#3088): extract api/filter.lua
alex-courtis Jan 18, 2026
2201bb0
docs(#3088): move api.git into api.tree
alex-courtis Jan 18, 2026
052d39f
docs(#3088): extract api/health.lua, tidy formatting
alex-courtis Jan 18, 2026
fdba900
docs(#3088): extract api/health.lua, tidy formatting
alex-courtis Jan 18, 2026
cdf1148
docs(#3088): remove command descriptions, show lua, link to api
alex-courtis Jan 18, 2026
8169547
docs(#3088): extract api/marks.lua
alex-courtis Jan 18, 2026
ac9424a
docs(#3088): remove completed legacy api.lua members
alex-courtis Jan 18, 2026
3a08fa2
docs(#3088): extract api/events.lua
alex-courtis Jan 18, 2026
219984a
docs(#3088): extract api/events.lua
alex-courtis Jan 18, 2026
0ad171b
docs(#3088): extract api/fs.lua
alex-courtis Jan 18, 2026
56e61c2
docs(#3088): extract api/commands.lua
alex-courtis Jan 18, 2026
3c65e3f
docs(#3088): extract api/node.lua functions, doc TODO
alex-courtis Jan 18, 2026
9a8fb71
docs(#3088): move all nvim-tree-api to generated doc
alex-courtis Jan 18, 2026
e9b5ca6
docs(#3088): old api is now impl, use new api
alex-courtis Jan 18, 2026
cbc97fe
docs(#3088): extract api/node.lua functions, doc WIP
alex-courtis Jan 20, 2026
46652cb
docs(#3088): extract api/node.lua functions, doc WIP
alex-courtis Jan 20, 2026
8853151
docs(#3088): extract api/node.lua functions, doc WIP
alex-courtis Jan 20, 2026
941f11f
docs(#3088): extract api/node.lua functions
alex-courtis Jan 20, 2026
db6d210
docs(#3088): move api into _meta
alex-courtis Jan 20, 2026
d8a5442
docs(#3088): move api-impl out of meta, restore it to its original st…
alex-courtis Jan 20, 2026
f1d1f1b
docs(#3088): remove old Api classes, rename impl Api -> api
alex-courtis Jan 20, 2026
506def5
docs(#3088): tidy migrated annotations
alex-courtis Jan 20, 2026
4f966c6
docs(#3088): format nvim_tree.api.commands
alex-courtis Jan 20, 2026
0170127
docs(#3088): separate api classes at the end
alex-courtis Jan 20, 2026
002b99d
docs(#3088): polish vimdoc config
alex-courtis Jan 20, 2026
29fec08
docs(#3088): format
alex-courtis Jan 20, 2026
dc536aa
docs(#2934): polish vimdoc config
alex-courtis Jan 20, 2026
94e23a5
Merge branch '2934-gen_vimdoc' into 3088-gen_vimdoc-api-3231-remove-a…
alex-courtis Jan 20, 2026
c51db1d
docs(#2934): snake case config class names
alex-courtis Jan 20, 2026
de68ae3
docs(#2934): snake case config alias names
alex-courtis Jan 20, 2026
c11308b
docs(#2934): note help tag prefixes
alex-courtis Jan 20, 2026
eb9f27d
docs(#2934): snake case config sections
alex-courtis Jan 21, 2026
411e3af
docs(#2934): move default config to end
alex-courtis Jan 21, 2026
ae58d2e
docs(#2934): move setup doc from config to quickstart and setup
alex-courtis Jan 21, 2026
0ed74d2
docs(#2934): index contributing
alex-courtis Jan 21, 2026
69ab5c7
Merge branch '2934-gen_vimdoc' into 3088-gen_vimdoc-api-3231-remove-a…
alex-courtis Jan 21, 2026
88fe257
Merge branch 'master' into 3088-gen_vimdoc-api-3231-remove-api-requires
alex-courtis Jan 22, 2026
0c78c27
docs(#3088): cleanup following merge
alex-courtis Jan 22, 2026
43fab32
docs(#3088): tidy section names
alex-courtis Jan 22, 2026
ae0a83a
docs(#3088): split node.navigate and open, move all filters into api.…
alex-courtis Jan 22, 2026
48de5e0
docs(#3088): hidden->custom toggle default desc
alex-courtis Jan 22, 2026
e47079e
docs(#3088): add legacy filter api mappings
alex-courtis Jan 22, 2026
98c3655
docs(#3088): tidy api meta
alex-courtis Jan 22, 2026
9d4a117
docs(#3088): always exclude meta from luacheck, it doesn't offer anyt…
alex-courtis Jan 22, 2026
6939619
docs(#3088): extract fs.copy, fix api node param optionality, move le…
alex-courtis Jan 23, 2026
02ce4fb
docs(#3088): correct optionality of nvim_tree.config.view.width fields
alex-courtis Jan 23, 2026
3bafec9
docs(#3088): hydrate API before setup with error functions, with some…
alex-courtis Jan 23, 2026
4cbe0d7
docs(#3088): remove api impl error wrap
alex-courtis Jan 23, 2026
6b38f1c
docs(#3088): split api pre and post, add more comments
alex-courtis Jan 24, 2026
ba4f507
docs(#3088): split api pre and post, add more comments
alex-courtis Jan 24, 2026
a79a495
docs(#3088): extract post impl functions, lazy some requires
alex-courtis Jan 24, 2026
28281aa
Merge branch 'master' into 3088-gen_vimdoc-api-3231-remove-api-requires
alex-courtis Jan 24, 2026
c6ea6c5
docs(#3088): lazy api impl requires
alex-courtis Jan 24, 2026
728e851
Revert "docs(#3088): lazy api impl requires"
alex-courtis Jan 24, 2026
49b0b80
docs(#3088): minimise api pre following tests
alex-courtis Jan 24, 2026
b3e8a63
docs(#3088): move node classes under api with logical order
alex-courtis Jan 24, 2026
9e6ce3a
docs(#3088): document node and git classes, namespace internal and ex…
alex-courtis Jan 25, 2026
8e9e73b
Merge remote-tracking branch 'origin/master' into 3088-gen_vimdoc-api…
alex-courtis Jan 25, 2026
f71ff50
docs(#3088): fix merge issue
alex-courtis Jan 25, 2026
11f96e1
docs(#3088): tidy pre comments
alex-courtis Jan 25, 2026
63e3679
docs(#3088): collapse node and fs submodules
alex-courtis Jan 25, 2026
338e95a
docs(#3088): move api help and classes back into api.lua
alex-courtis Jan 25, 2026
b4b9b20
docs(#3088): resize command calls api, not view
alex-courtis Jan 25, 2026
d8558bb
docs(#3088): tidy api map names
alex-courtis Jan 26, 2026
cbd6fa2
docs(#3088): revert api.git refactor, provide deprecated api meta
alex-courtis Jan 26, 2026
e460df4
docs(#3088): add deprecated api @see
alex-courtis Jan 27, 2026
534bcdf
Merge branch 'master' into 3088-gen_vimdoc-api-3231-remove-api-requires
alex-courtis Jan 27, 2026
ee06bf2
docs(#3088): class fixes following merge, disable luacheck on scripts
alex-courtis Jan 27, 2026
7785196
docs(#3088): Node:should_expand nops
alex-courtis Jan 27, 2026
ce74883
docs(#3088): fix _git return
alex-courtis Jan 27, 2026
86f0d81
docs(#3088): add meta for legacy api
alex-courtis Jan 27, 2026
23e59fd
docs(#3088): mark deprecated api modules, use proper namespacing for …
alex-courtis Jan 27, 2026
ff0184a
docs(#3088): gen_vimdoc now uses full paths, requires a patch for a F…
alex-courtis Jan 28, 2026
ebb9909
docs(#3088): add vim_gendoc patches
alex-courtis Jan 28, 2026
7846322
Revert "docs(#3088): add vim_gendoc patches"
alex-courtis Jan 28, 2026
4f7e35c
Revert "docs(#3088): gen_vimdoc now uses full paths, requires a patch…
alex-courtis Jan 28, 2026
a675266
docs(#3088): split gen_vimdoc_config into chunks to avoid filename cl…
alex-courtis Jan 29, 2026
c6c5286
docs(#3088): move legacy api into api.impl.legacy, fixes following te…
alex-courtis Jan 29, 2026
1a7457b
docs(#3088): remove merge leftover
alex-courtis Jan 29, 2026
1dd53f0
docs(#3088): tidy contrib
alex-courtis Jan 29, 2026
1853d32
docs(#3088): clarify backwards compatibility
alex-courtis Jan 29, 2026
984378f
docs(#3088): clarify help generation in contributing
alex-courtis Jan 30, 2026
9b962b5
docs(#3088): contributing index
alex-courtis Jan 30, 2026
6be2074
docs(#3088): help-update.sh -> help-defaults.sh now using a /tmp file…
alex-courtis Jan 30, 2026
7d277fe
docs(#3088): help-update.sh -> help-defaults.sh now using a /tmp file…
alex-courtis Jan 30, 2026
033bfd3
docs(#3088): CI runs make lintdoc to avoid muddying help-check with u…
alex-courtis Jan 30, 2026
d0a1426
docs(#3088): unify help and readme, clarify some wording
alex-courtis Jan 31, 2026
6cf83d7
docs(#3088): test a readme toc
alex-courtis Jan 31, 2026
c076f3f
docs(#3088): test a readme toc
alex-courtis Jan 31, 2026
b63b467
Merge remote-tracking branch 'origin/master' into 3088-gen_vimdoc-api…
alex-courtis Jan 31, 2026
8f30a4a
docs(#3088): unify help generation and lint into vimdoc.sh, generatio…
alex-courtis Feb 3, 2026
c104076
docs(#3241): namespace decorator types
alex-courtis Jan 31, 2026
469f795
docs(#3241): namespace decorator types
alex-courtis Jan 31, 2026
e81e6d5
docs(#3241): namespace decorator types
alex-courtis Feb 1, 2026
baa4b10
docs(#3241): api exposes nvim_tree.api.decorator.Decorator interface,…
alex-courtis Feb 1, 2026
973a9d8
docs(#3241): move decorator meta into place
alex-courtis Feb 1, 2026
32ac1e0
docs(#3241): generate decorator help
alex-courtis Feb 1, 2026
d61841e
docs(#3241): separate api and class generation configs, namespace cla…
alex-courtis Feb 1, 2026
58d4b2a
docs(#3241): fix potential bug in builder: passing a nil node to a us…
alex-courtis Feb 2, 2026
3e7b376
docs(#3241): nvim-tree-api-decorator brief
alex-courtis Feb 2, 2026
8e84f54
docs(#3241): Decorator class documentation
alex-courtis Feb 3, 2026
d06bccb
docs(#3241): add placholder to vimdoc.sh
alex-courtis Feb 3, 2026
7275609
docs(#3241): extract nvim_tree.config.renderer.decorator, add decorat…
alex-courtis Feb 3, 2026
958feb0
docs(#3241): use general nvim_tree.api.highlighted_string
alex-courtis Feb 3, 2026
c2d266e
docs(#3241): add nvim-tree-class-decorator-example
alex-courtis Feb 3, 2026
88e0a93
docs(#3241): move renderer alias doc to the class
alex-courtis Feb 3, 2026
e60d7a2
docs(#3241): Class -> nvim_tree.Class
alex-courtis Feb 3, 2026
4b2b584
docs(#3241): Class -> nvim_tree.Class
alex-courtis Feb 3, 2026
67a74f3
docs(#3241): document nvim_tree.Class
alex-courtis Feb 3, 2026
e7803aa
docs(#3241): fix help lua indentation
alex-courtis Feb 3, 2026
7c51988
docs(#3241): extract builtin decorator interface, partially complete
alex-courtis Feb 4, 2026
268a798
docs(#3241): extracted BuiltinDecorator
alex-courtis Feb 4, 2026
efc9fa1
docs(#3241): add BuiltinDecorator constructor
alex-courtis Feb 4, 2026
c74dc20
docs(#3241): revert api function changes
alex-courtis Feb 4, 2026
cebf53c
docs(#3241): revert api function changes
alex-courtis Feb 4, 2026
3d1a172
docs(#3241): vimdoc polish
alex-courtis Feb 4, 2026
8785496
docs(#3241): tidy
alex-courtis Feb 4, 2026
5585bfd
docs(#3241): tidy
alex-courtis Feb 4, 2026
e0ef05e
Merge branch 'master' into 3241-gen_vimdoc-decorators
alex-courtis Feb 12, 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
638 changes: 460 additions & 178 deletions doc/nvim-tree-lua.txt

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion lua/nvim-tree.lua
Original file line number Diff line number Diff line change
Expand Up @@ -813,7 +813,7 @@ function M.setup(conf)
vim.g.NvimTreeSetup = 1
vim.api.nvim_exec_autocmds("User", { pattern = "NvimTreeSetup" })

require("nvim-tree.api.impl.post")(api)
require("nvim-tree.api.impl.post").hydrate(api)
end

vim.g.NvimTreeRequired = 1
Expand Down
103 changes: 103 additions & 0 deletions lua/nvim-tree/_meta/api/decorator.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
---@meta

---@brief
---Highlighting and icons for nodes are provided by Decorators, see [nvim-tree-icons-highlighting] for an overview.
---
---Decorators are rendered in [nvim_tree.config.renderer] {decorators} order of additive precedence, with later decorators applying additively over earlier.
---
---You may provide your own in addition to the builtin decorators, see |nvim-tree-class-decorator-example|.
---
---Decorators may:
---- Add icons
---- Set a highlight group name for the name or icons
---- Override node icon
---
---To register your decorator:
---- Create a class that extends [nvim_tree.api.Decorator]
---- Register it by adding the class to [nvim_tree.config.renderer] {decorators}
---
---Your decorator will be constructed and executed each time the tree is rendered.
---
---Your class must:
---- [nvim_tree.Class:extend()] the interface [nvim_tree.api.Decorator]
---- Provide a no-arguments constructor [nvim_tree.Class:new()] that sets the mandatory fields:
--- - {enabled}
--- - {highlight_range}
--- - {icon_placement}
---- Call [nvim_tree.api.Decorator:define_sign()] in your constructor when {icon_placement} is `"signcolumn"`
---
---Your class may:
---- Implement methods to provide decorations:
--- - [nvim_tree.api.Decorator:highlight_group()]
--- - [nvim_tree.api.Decorator:icon_node()]
--- - [nvim_tree.api.Decorator:icons()]

local nvim_tree = { api = {} }

local Class = require("nvim-tree.classic")

---
---Text or glyphs with optional highlight group names to apply to it.
---
---@class nvim_tree.api.highlighted_string
---
---One or many glyphs/characters.
---@field str string
---
---Highlight group names to apply in order. Empty table for no highlighting.
---@field hl string[]


---
---Decorator interface
---
---@class nvim_tree.api.Decorator: nvim_tree.Class
---
---Enable this decorator.
---@field enabled boolean
---
---What to highlight: [nvim_tree.config.renderer.highlight]
---@field highlight_range nvim_tree.config.renderer.highlight
---
---Where to place the icons: [nvim_tree.config.renderer.icons.placement]
---@field icon_placement "none"|nvim_tree.config.renderer.icons.placement
---
local Decorator = Class:extend()
nvim_tree.api.Decorator = Decorator

---
---Icon to override for the node.
---
---Abstract, optional to implement.
---
---@param node nvim_tree.api.Node
---@return nvim_tree.api.highlighted_string? icon `nil` for no override
function Decorator:icon_node(node) end

---
---Icons to add to the node as per {icon_placement}
---
---Abstract, optional to implement.
---
---@param node nvim_tree.api.Node
---@return nvim_tree.api.highlighted_string[]? icons `nil` or empty table for no icons. Only the first glyph of {str} is used when {icon_placement} is `"signcolumn"`
function Decorator:icons(node) end

---
---One highlight group that applies additively to the {node} name for {highlight_range}.
---
---Abstract, optional to implement.
---
---@param node nvim_tree.api.Node
---@return string? highlight group name `nil` when no highlighting to apply to the node
function Decorator:highlight_group(node) end

---
---Defines a sign for an icon. This is mandatory and necessary only when {icon_placement} is `"signcolumn"`
---
---This must be called during your constructor for all icons that you will return from [nvim_tree.api.Decorator:icons()]
---
---@param icon nvim_tree.api.highlighted_string? does nothing if nil
function Decorator:define_sign(icon) end

return nvim_tree.api.Decorator
96 changes: 96 additions & 0 deletions lua/nvim-tree/_meta/api/decorator_example.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
---@meta
error("Cannot require a meta file")

---@brief
---
---A decorator class for nodes named "example", overriding all builtin decorators except for Cut.
---- Highlights node name with `IncSearch`
---- Creates two icons `"1"` and `"2"` placed after the node name, highlighted with `DiffAdd` and `DiffText`
---- Replaces the node icon with `"N"`, highlighted with `Error `
---
---Create a class file `~/.config/nvim/lua/my-decorator.lua`
---
---Require and register it during |nvim-tree-setup|:
---```lua
---
--- local MyDecorator = require("my-decorator")
---
--- require("nvim-tree").setup({
--- renderer = {
--- decorators = {
--- "Git",
--- "Open",
--- "Hidden",
--- "Modified",
--- "Bookmark",
--- "Diagnostics",
--- "Copied",
--- MyDecorator,
--- "Cut",
--- },
--- },
--- })
---```
---Contents of `my-decorator.lua`:
---```lua
---
--- ---@class (exact) MyDecorator: nvim_tree.api.Decorator
--- ---@field private my_icon1 nvim_tree.api.highlighted_string
--- ---@field private my_icon2 nvim_tree.api.highlighted_string
--- ---@field private my_icon_node nvim_tree.api.highlighted_string
--- ---@field private my_highlight_group string
--- local MyDecorator = require("nvim-tree.api").Decorator:extend()
---
--- ---Mandatory constructor :new() will be called once per tree render, with no arguments.
--- function MyDecorator:new()
--- self.enabled = true
--- self.highlight_range = "name"
--- self.icon_placement = "after"
---
--- -- create your icons and highlights once, applied to every node
--- self.my_icon1 = { str = "1", hl = { "DiffAdd" } }
--- self.my_icon2 = { str = "2", hl = { "DiffText" } }
--- self.my_icon_node = { str = "N", hl = { "Error" } }
--- self.my_highlight_group = "IncSearch"
---
--- -- Define the icon signs only once
--- -- Only needed if you are using icon_placement = "signcolumn"
--- -- self:define_sign(self.my_icon1)
--- -- self:define_sign(self.my_icon2)
--- end
---
--- ---Override node icon
--- ---@param node nvim_tree.api.Node
--- ---@return nvim_tree.api.highlighted_string? icon_node
--- function MyDecorator:icon_node(node)
--- if node.name == "example" then
--- return self.my_icon_node
--- else
--- return nil
--- end
--- end
---
--- ---Return two icons for DecoratorIconPlacement "after"
--- ---@param node nvim_tree.api.Node
--- ---@return nvim_tree.api.highlighted_string[]? icons
--- function MyDecorator:icons(node)
--- if node.name == "example" then
--- return { self.my_icon1, self.my_icon2, }
--- else
--- return nil
--- end
--- end
---
--- ---Exactly one highlight group for DecoratorHighlightRange "name"
--- ---@param node nvim_tree.api.Node
--- ---@return string? highlight_group
--- function MyDecorator:highlight_group(node)
--- if node.name == "example" then
--- return self.my_highlight_group
--- else
--- return nil
--- end
--- end
---
--- return MyDecorator
---```
6 changes: 6 additions & 0 deletions lua/nvim-tree/_meta/api/deprecated.lua
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,10 @@ nvim_tree.api.diagnostics = {}
---@deprecated use `nvim_tree.api.health.hi_test()`
function nvim_tree.api.diagnostics.hi_test() end

nvim_tree.api.decorator = {}

---@class nvim_tree.api.decorator.UserDecorator: nvim_tree.api.Decorator
---@deprecated use `nvim_tree.api.Decorator`
nvim_tree.api.decorator.UserDecorator = nvim_tree.api.Decorator

return nvim_tree.api
59 changes: 0 additions & 59 deletions lua/nvim-tree/_meta/api_decorator.lua

This file was deleted.

6 changes: 0 additions & 6 deletions lua/nvim-tree/_meta/classes.lua
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
---@meta
error("Cannot require a meta file")


-- TODO #2688
-- These node subclasses are not ready for public exposure as they are:
-- - not classic classes
-- - only used in a few locations: api.tree.get_nodes and UserDecorator

---
---File
---
Expand Down
14 changes: 7 additions & 7 deletions lua/nvim-tree/_meta/config/actions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,13 @@ error("Cannot require a meta file")
---
---{open_win_config} is passed to [nvim_open_win()], default:
---```lua
---{
--- col = 1,
--- row = 1,
--- relative = "cursor",
--- border = "shadow",
--- style = "minimal",
---}
--- {
--- col = 1,
--- row = 1,
--- relative = "cursor",
--- border = "shadow",
--- style = "minimal",
--- }
---```
---You shouldn't define {width} and {height} values here. They will be overridden to fit the file_popup content.
---@class nvim_tree.config.actions.file_popup
Expand Down
9 changes: 4 additions & 5 deletions lua/nvim-tree/_meta/config/default.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@
---
---```lua
---
------@type nvim_tree.config
---local config = {
---default-config-injection-placeholder
---}
--- ---@type nvim_tree.config
--- local config = {
--- default-config-injection-placeholder
--- }
---```
---
Loading
Loading