Skip to content

Commit 7275609

Browse files
committed
docs(#3241): extract nvim_tree.config.renderer.decorator, add decorators to hl help section
1 parent d06bccb commit 7275609

4 files changed

Lines changed: 41 additions & 36 deletions

File tree

doc/nvim-tree-lua.txt

Lines changed: 36 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -482,15 +482,25 @@ Icons And Highlighting *nvim-tree-icons-highlighting*
482482
Icons may be displayed before files and directories.
483483

484484
Additional icons and highlighting may be displayed to indicate various states
485-
for files and and directories.
486-
487-
Highlighting is additive, with higher precedence overriding lower.
488-
489-
|nvim_tree.config.renderer| {decorators} controls which highlighting is
490-
applied and its precedence. See |nvim-tree-api-decorator| for information on
491-
creating custom decorators.
492-
<
493-
`ICON`
485+
for files and and directories. Highlighting is additive.
486+
487+
Decorators are responsible for providing the icons and highlighting.
488+
|nvim_tree.config.renderer| {decorators} configures the decorators used,
489+
in ascending order of precedence.
490+
491+
`DECORATOR` *nvim_tree.config.renderer.decorator*
492+
A builtin decorator name or |nvim_tree.api.Decorator| class.
493+
Builtin decorators in default order:
494+
`"Git"`
495+
`"Open"`
496+
`"Hidden"`
497+
`"Modified"`
498+
`"Bookmark"`
499+
`"Diagnostics"`
500+
`"Copied"`
501+
`"Cut"`
502+
503+
`ICON?`
494504
Enable via |nvim_tree.config.renderer.icons.show
495505

496506
`REQUIRES`
@@ -510,7 +520,7 @@ creating custom decorators.
510520
`name`: name only
511521
`all`: icon and name
512522

513-
`DEVICONS`
523+
`DEVICONS?`
514524
Glyphs and their colors will be overridden by optional plugin:
515525
`nvim-tree/nvim-web-devicons` |nvim_tree.config.renderer.icons.web_devicons|
516526

@@ -520,18 +530,19 @@ creating custom decorators.
520530
`GROUPS`
521531
Applicable highlight groups: |nvim-tree-highlight-groups|
522532

523-
Some defaults noted. In ascending order of default highlight precedence:
533+
Some defaults noted. In ascending order of default decorator precedence:
524534

525-
`WHAT ICON REQUIRES PLACEMENT HIGHLIGHT GLYPHS DEVICONS GROUPS`
526-
File Icon {file} Y - - - |nvim_tree.config.renderer.icons.glyphs| {default} Y `NvimTreeNormal`, `NvimTreeFileIcon`
527-
Folder Icon {folder} Y - - - |nvim_tree.config.renderer.icons.glyphs.folder| Y `NvimTree*FolderName`, `NvimTree*FolderIcon`
528-
Git Status {git} Y |nvim_tree.config.git| {git_placement} `"before"` {highlight_git} `"none"` |nvim_tree.config.renderer.icons.glyphs.git| N `NvimTreeGit*`
529-
|bufloaded()| - - - {highlight_opened_files}`"none"` - N ` NvimTreeOpened*`
530-
Dotfiles {hidden} N - {hidden_placement} `"after"` {highlight_hidden} `"none"` |nvim_tree.config.renderer.icons.glyphs| {hidden} N `NvimTreeHidden*`
531-
|'modified'| {modified} Y |nvim_tree.config.modified| {modified_placement} `"after"` {highlight_modified} `"none"` |nvim_tree.config.renderer.icons.glyphs| {modified} N `NvimTreeModified*`
532-
Bookmarked {bookmarks} Y - {bookmarks_placement} `"signcolumn"` {highlight_bookmarks} `"none"` |nvim_tree.config.renderer.icons.glyphs| {bookmark} N `NvimTreeBookmark*`
533-
Diag Status {diagnostics}Y |nvim_tree.config.diagnostics| {diagnostics_placement}`"signcolumn"` {highlight_diagnostics} `"none" ` |nvim_tree.config.diagnostics.icons| N `NvimTreeDiagnostic*`
534-
Cut/Copied - - - {highlight_clipboard} `"name"` - N `NvimTreeCutHL`, `NvimTreeCopiedHL`
535+
`WHAT DECORATOR ICON? REQUIRES PLACEMENT HIGHLIGHT GLYPHS DEVICONS? GROUPS`
536+
File Icon - {file} Y - - - |nvim_tree.config.renderer.icons.glyphs| {default} Y `NvimTreeNormal`, `NvimTreeFileIcon`
537+
Folder Icon - {folder} Y - - - |nvim_tree.config.renderer.icons.glyphs.folder| Y `NvimTree*FolderName`, `NvimTree*FolderIcon`
538+
Git Status `"Git"` {git} Y |nvim_tree.config.git| {git_placement} `"before"` {highlight_git} `"none"` |nvim_tree.config.renderer.icons.glyphs.git| N `NvimTreeGit*`
539+
|bufloaded()| `"Open"` - - - {highlight_opened_files}`"none"` - N ` NvimTreeOpened*`
540+
Dotfiles `"Hidden"` {hidden} N - {hidden_placement} `"after"` {highlight_hidden} `"none"` |nvim_tree.config.renderer.icons.glyphs| {hidden} N `NvimTreeHidden*`
541+
|'modified'| `"Modified"` {modified} Y |nvim_tree.config.modified| {modified_placement} `"after"` {highlight_modified} `"none"` |nvim_tree.config.renderer.icons.glyphs| {modified} N `NvimTreeModified*`
542+
Bookmarked `"Bookmark"` {bookmarks} Y - {bookmarks_placement} `"signcolumn"` {highlight_bookmarks} `"none"` |nvim_tree.config.renderer.icons.glyphs| {bookmark} N `NvimTreeBookmark*`
543+
Diag Status ` "Diagnostics"` {diagnostics}Y |nvim_tree.config.diagnostics| {diagnostics_placement}`"signcolumn"` {highlight_diagnostics} `"none" ` |nvim_tree.config.diagnostics.icons| N `NvimTreeDiagnostic*`
544+
Copied `"Copied"` - - - {highlight_clipboard} `"name"` - N `NvimTreeCopiedHL`
545+
Cut `"Cut"` - - - {highlight_clipboard} `"name"` - N `NvimTreeCutHL`
535546

536547

537548
==============================================================================
@@ -1366,10 +1377,10 @@ Config: renderer *nvim-tree-config-renderer*
13661377
• {symlink_destination}? (`boolean`, default: `true`) Appends an
13671378
arrow followed by the target of the
13681379
symlink.
1369-
{decorators}? (`(string|nvim_tree.api.Decorator)[]`, default: `{ "Git", "Open", "Hidden", "Modified", "Bookmark", "Diagnostics", "Copied", "Cut", }`)
1370-
Ordered list of builtin and user decorators
1371-
to enable, see |nvim-tree-api-decorator|
1372-
and |nvim-tree-icons-highlighting|
1380+
{decorators}? (`nvim_tree.config.renderer.decorator[]`, default: `{ "Git", "Open", "Hidden", "Modified", "Bookmark", "Diagnostics", "Copied", "Cut", }`)
1381+
Ordered list of builtin
1382+
|nvim_tree.config.renderer.decorator| names
1383+
and |nvim_tree.api.Decorator| classes.
13731384
• {highlight_git}? (`nvim_tree.config.renderer.highlight`)
13741385
(default: `"none"`)
13751386
• {highlight_opened_files}? (`nvim_tree.config.renderer.highlight`)

lua/nvim-tree/_meta/api/decorator.lua

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,6 @@ local nvim_tree = { api = {} }
3434

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

37-
---
38-
---TODO #3241 add this to config
39-
---
40-
---Names of builtin decorators or your decorator classes. Builtins are ordered lowest to highest priority.
41-
---
42-
---@alias nvim_tree.api.decorator.types nvim_tree.api.Decorator|"Git"|"Opened"|"Hidden"|"Modified"|"Bookmarks"|"Diagnostics"|"Copied"|"Cut"
43-
44-
4537
---
4638
---Text or glyphs with optional highlight group names to apply to it.
4739
---

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ error("Cannot require a meta file")
3232
---
3333
---@alias nvim_tree.config.renderer.highlight "none"|"icon"|"name"|"all"
3434
---
35+
---@alias nvim_tree.config.renderer.decorator nvim_tree.api.Decorator|"Git"|"Open"|"Hidden"|"Modified"|"Bookmark"|"Diagnostics"|"Copied"|"Cut"
36+
---
3537
---@class nvim_tree.config.renderer
3638
---
3739
---Appends a trailing slash to folder and symlink folder target names.
@@ -61,9 +63,9 @@ error("Cannot require a meta file")
6163
---(default: `true`)
6264
---@field symlink_destination? boolean
6365
---
64-
---Ordered list of builtin and user decorators to enable, see [nvim-tree-api-decorator] and [nvim-tree-icons-highlighting]
66+
---Ordered list of builtin [nvim_tree.config.renderer.decorator] names and |nvim_tree.api.Decorator| classes.
6567
---(default: `{ "Git", "Open", "Hidden", "Modified", "Bookmark", "Diagnostics", "Copied", "Cut", }`)
66-
---@field decorators? (string|nvim_tree.api.Decorator)[]
68+
---@field decorators? nvim_tree.config.renderer.decorator[]
6769
---
6870
---(default: `"none"`)
6971
---@field highlight_git? nvim_tree.config.renderer.highlight

lua/nvim-tree/renderer/builder.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ local pad = require("nvim-tree.renderer.components.padding")
2121
---TODO #3241 add an alias for builtins or document the enum
2222

2323
-- Builtin Decorators
24-
---@type table<nvim_tree.api.decorator.types, Decorator>
24+
---@type table<nvim_tree.config.renderer.decorator, Decorator>
2525
local BUILTIN_DECORATORS = {
2626
Git = GitDecorator,
2727
Open = OpenDecorator,

0 commit comments

Comments
 (0)