@@ -52,14 +52,16 @@ CONTENTS *nvim-tree*
52
52
8.2 Highlight: Overhaul | nvim-tree-highlight-overhaul |
53
53
9. Events | nvim-tree-events |
54
54
10. Prompts | nvim-tree-prompts |
55
- 11. OS Specific Restrictions | nvim-tree-os-specific |
56
- 12. Netrw | nvim-tree-netrw |
57
- 13. Legacy | nvim-tree-legacy |
58
- 13.1 Legacy: Opts | nvim-tree-legacy-opts |
59
- 13.2 Legacy: Highlight | nvim-tree-legacy-highlight |
60
- 14. Index | nvim-tree-index |
61
- 14.1 Index: Opts | nvim-tree-index-opts |
62
- 14.2 Index: API | nvim-tree-index-api |
55
+ 11. Decorators | nvim-tree-decorators |
56
+ 11.1 Decorator Example | nvim-tree-decorator-example |
57
+ 12. OS Specific Restrictions | nvim-tree-os-specific |
58
+ 13. Netrw | nvim-tree-netrw |
59
+ 14. Legacy | nvim-tree-legacy |
60
+ 14.1 Legacy: Opts | nvim-tree-legacy-opts |
61
+ 14.2 Legacy: Highlight | nvim-tree-legacy-highlight |
62
+ 15. Index | nvim-tree-index |
63
+ 15.1 Index: Opts | nvim-tree-index-opts |
64
+ 15.2 Index: API | nvim-tree-index-api |
63
65
64
66
==============================================================================
65
67
1. INTRODUCTION *nvim-tree-introduction*
@@ -425,6 +427,7 @@ Following is the default configuration. See |nvim-tree-opts| for details. >lua
425
427
special_files = { "Cargo.toml", "Makefile", "README.md", "readme.md" },
426
428
hidden_display = "none",
427
429
symlink_destination = true,
430
+ decorators = { "Git", "Open", "Hidden", "Modified", "Bookmark", "Diagnostics", "Copied", "Cut", },
428
431
highlight_git = "none",
429
432
highlight_diagnostics = "none",
430
433
highlight_opened_files = "none",
@@ -842,9 +845,6 @@ Use nvim-tree in a floating window.
842
845
==============================================================================
843
846
5.3 OPTS: RENDERER *nvim-tree-opts-renderer*
844
847
845
- Highlight precedence, additive:
846
- git < opened < modified < bookmarked < diagnostics < copied < cut
847
-
848
848
*nvim-tree.renderer.add_trailing*
849
849
Appends a trailing slash to folder names.
850
850
Type: `boolean ` , Default: `false`
@@ -927,6 +927,22 @@ Show a summary of hidden files below the tree using `NvimTreeHiddenDisplay
927
927
Whether to show the destination of the symlink.
928
928
Type: `boolean ` , Default: `true`
929
929
930
+ *nvim-tree.renderer.decorators*
931
+ Highlighting and icons for the nodes, in increasing order of precedence.
932
+ Uses strings to specify builtin decorators otherwise specify your
933
+ `nvim_tree.api.decorator.UserDecorator` class.
934
+ Type: `nvim_tree.api.decorator.Name[]` , Default: >lua
935
+ {
936
+ "Git",
937
+ "Open",
938
+ "Hidden",
939
+ "Modified",
940
+ "Bookmark",
941
+ "Diagnostics",
942
+ "Copied",
943
+ "Cut",
944
+ }
945
+ <
930
946
*nvim-tree.renderer.highlight_git*
931
947
Enable highlight for git attributes using `NvimTreeGit* HL` highlight groups.
932
948
Requires | nvim-tree.git.enable |
@@ -996,9 +1012,6 @@ Configuration options for tree indent markers.
996
1012
*nvim-tree.renderer.icons*
997
1013
Configuration options for icons.
998
1014
999
- Icon order and sign column precedence:
1000
- git < hidden < modified < bookmarked < diagnostics
1001
-
1002
1015
`renderer.icons.* _placement` options may be:
1003
1016
- `" before" ` : before file/folder, after the file/folders icons
1004
1017
- `" after" ` : after file/folder
@@ -2755,7 +2768,90 @@ configurations for different types of prompts.
2755
2768
send all bookmarked to trash during | nvim-tree-api.marks.bulk.trash() |
2756
2769
2757
2770
==============================================================================
2758
- 11. OS SPECIFIC RESTRICTIONS *nvim-tree-os-specific*
2771
+ 11. DECORATORS *nvim-tree-decorators*
2772
+
2773
+ Highlighting and icons for nodes are provided by Decorators. You may provide
2774
+ your own in addition to the builtin decorators.
2775
+
2776
+ Decorators may:
2777
+ - Add icons
2778
+ - Set highlight group for the name or icons
2779
+ - Override node icon
2780
+
2781
+ Specify decorators and their precedence via | nvim-tree.renderer.decorators |
2782
+ e.g. defaults with a user decorator class being overridden only by Cut: >lua
2783
+ {
2784
+ "Git",
2785
+ "Open",
2786
+ "Hidden",
2787
+ "Modified",
2788
+ "Bookmark",
2789
+ "Diagnostics",
2790
+ "Copied",
2791
+ MyDecorator,
2792
+ "Cut",
2793
+ }
2794
+
2795
+ See `nvim- tree/_meta/ api_decorator.lua ` for full
2796
+ `nvim_tree.api.decorator.UserDecorator` class documentation.
2797
+ <
2798
+ ==============================================================================
2799
+ 11.1. DECORATOR EXAMPLE *nvim-tree-decorator-example*
2800
+ >lua
2801
+ ---Create your decorator class
2802
+ ---@class (exact) MyDecorator: nvim_tree.api.decorator.UserDecorator
2803
+ ---@field private my_icon nvim_tree.api.HighlightedString
2804
+ local MyDecorator = require("nvim-tree.api").decorator.UserDecorator:extend()
2805
+
2806
+ ---Mandatory constructor :new() will be called once per tree render, with no arguments.
2807
+ function MyDecorator:new()
2808
+ self.enabled = true
2809
+ self.highlight_range = "all"
2810
+ self.icon_placement = "signcolumn"
2811
+
2812
+ -- create your icon once, for convenience
2813
+ self.my_icon = { str = "I", hl = { "MyIcon" } }
2814
+
2815
+ -- Define the icon sign only once
2816
+ -- Only needed if you are using icon_placement = "signcolumn"
2817
+ self:define_sign(self.my_icon)
2818
+ end
2819
+
2820
+ ---Override node icon
2821
+ ---@param node nvim_tree.api.Node
2822
+ ---@return nvim_tree.api.HighlightedString? icon_node
2823
+ function MyDecorator:icon_node(node)
2824
+ if node.name == "example" then
2825
+ return self.my_icon
2826
+ else
2827
+ return nil
2828
+ end
2829
+ end
2830
+
2831
+ ---Return one icon for DecoratorIconPlacement
2832
+ ---@param node nvim_tree.api.Node
2833
+ ---@return nvim_tree.api.HighlightedString[]? icons
2834
+ function MyDecorator:icons(node)
2835
+ if node.name == "example" then
2836
+ return { self.my_icon }
2837
+ else
2838
+ return nil
2839
+ end
2840
+ end
2841
+
2842
+ ---Exactly one highlight group for DecoratorHighlightRange
2843
+ ---@param node nvim_tree.api.Node
2844
+ ---@return string? highlight_group
2845
+ function MyDecorator:highlight_group(node)
2846
+ if node.name == "example" then
2847
+ return "MyHighlight"
2848
+ else
2849
+ return nil
2850
+ end
2851
+ end
2852
+ <
2853
+ ==============================================================================
2854
+ 12. OS SPECIFIC RESTRICTIONS *nvim-tree-os-specific*
2759
2855
2760
2856
Windows WSL and PowerShell
2761
2857
- Trash is synchronized
@@ -2767,7 +2863,7 @@ Windows WSL and PowerShell
2767
2863
issues or disable this feature.
2768
2864
2769
2865
==============================================================================
2770
- 12 . NETRW *nvim-tree-netrw*
2866
+ 13 . NETRW *nvim-tree-netrw*
2771
2867
2772
2868
| netrw | is a standard neovim plugin that is enabled by default. It provides,
2773
2869
amongst other functionality, a file/directory browser.
@@ -2788,14 +2884,14 @@ keep using |netrw| without its browser features please ensure:
2788
2884
| nvim-tree.hijack_netrw | ` = true`
2789
2885
2790
2886
==============================================================================
2791
- 13 . LEGACY *nvim-tree-legacy*
2887
+ 14 . LEGACY *nvim-tree-legacy*
2792
2888
2793
2889
Breaking refactors have been made however the legacy versions will be silently
2794
2890
migrated and used.
2795
2891
There are no plans to remove this migration.
2796
2892
2797
2893
==============================================================================
2798
- 13 .1 LEGACY: OPTS *nvim-tree-legacy-opts*
2894
+ 14 .1 LEGACY: OPTS *nvim-tree-legacy-opts*
2799
2895
2800
2896
Legacy options are translated to the current, making type and value changes as
2801
2897
needed.
@@ -2813,7 +2909,7 @@ needed.
2813
2909
`renderer.icons.webdev_colors` | nvim-tree.renderer.icons.web_devicons.file.color |
2814
2910
2815
2911
==============================================================================
2816
- 13 .2 LEGACY: HIGHLIGHT *nvim-tree-legacy-highlight*
2912
+ 14 .2 LEGACY: HIGHLIGHT *nvim-tree-legacy-highlight*
2817
2913
2818
2914
Legacy highlight group are still obeyed when they are defined and the current
2819
2915
highlight group is not, hard linking as follows: >
@@ -2862,10 +2958,10 @@ highlight group is not, hard linking as follows: >
2862
2958
NvimTreeLspDiagnosticsHintFolderText NvimTreeDiagnosticHintFolderHL
2863
2959
<
2864
2960
==============================================================================
2865
- 14 INDEX *nvim-tree-index*
2961
+ 15 INDEX *nvim-tree-index*
2866
2962
2867
2963
==============================================================================
2868
- 14 .1 INDEX: OPTS *nvim-tree-index-opts*
2964
+ 15 .1 INDEX: OPTS *nvim-tree-index-opts*
2869
2965
2870
2966
| nvim-tree.actions.change_dir |
2871
2967
| nvim-tree.actions.change_dir.enable |
@@ -2943,6 +3039,7 @@ highlight group is not, hard linking as follows: >
2943
3039
| nvim-tree.prefer_startup_root |
2944
3040
| nvim-tree.reload_on_bufenter |
2945
3041
| nvim-tree.renderer.add_trailing |
3042
+ | nvim-tree.renderer.decorators |
2946
3043
| nvim-tree.renderer.full_name |
2947
3044
| nvim-tree.renderer.group_empty |
2948
3045
| nvim-tree.renderer.hidden_display |
@@ -3033,7 +3130,7 @@ highlight group is not, hard linking as follows: >
3033
3130
| nvim-tree.view.width.padding |
3034
3131
3035
3132
==============================================================================
3036
- 14 .2 INDEX: API *nvim-tree-index-api*
3133
+ 15 .2 INDEX: API *nvim-tree-index-api*
3037
3134
3038
3135
| nvim-tree-api.commands.get() |
3039
3136
| nvim-tree-api.config.mappings.default_on_attach() |
0 commit comments