@@ -52,14 +52,15 @@ 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
+ 12. OS Specific Restrictions | nvim-tree-os-specific |
57
+ 13. Netrw | nvim-tree-netrw |
58
+ 14. Legacy | nvim-tree-legacy |
59
+ 14.1 Legacy: Opts | nvim-tree-legacy-opts |
60
+ 14.2 Legacy: Highlight | nvim-tree-legacy-highlight |
61
+ 15. Index | nvim-tree-index |
62
+ 15.1 Index: Opts | nvim-tree-index-opts |
63
+ 15.2 Index: API | nvim-tree-index-api |
63
64
64
65
==============================================================================
65
66
1. INTRODUCTION *nvim-tree-introduction*
@@ -843,9 +844,6 @@ Use nvim-tree in a floating window.
843
844
==============================================================================
844
845
5.3 OPTS: RENDERER *nvim-tree-opts-renderer*
845
846
846
- Highlight precedence, additive, change via | nvim-tree.renderer.decorators |
847
- git < opened < modified < bookmarked < diagnostics < copied < cut
848
-
849
847
*nvim-tree.renderer.add_trailing*
850
848
Appends a trailing slash to folder names.
851
849
Type: `boolean ` , Default: `false`
@@ -1013,9 +1011,6 @@ Configuration options for tree indent markers.
1013
1011
*nvim-tree.renderer.icons*
1014
1012
Configuration options for icons.
1015
1013
1016
- Icon order and sign column precedence, change via | nvim-tree.renderer.decorators |
1017
- git < hidden < modified < bookmarked < diagnostics
1018
-
1019
1014
`renderer.icons.* _placement` options may be:
1020
1015
- `" before" ` : before file/folder, after the file/folders icons
1021
1016
- `" after" ` : after file/folder
@@ -2772,7 +2767,90 @@ configurations for different types of prompts.
2772
2767
send all bookmarked to trash during | nvim-tree-api.marks.bulk.trash() |
2773
2768
2774
2769
==============================================================================
2775
- 11. OS SPECIFIC RESTRICTIONS *nvim-tree-os-specific*
2770
+ 11. DECORATORS *nvim-tree-decorators*
2771
+
2772
+ Highlighting and icons for nodes are is provided by Decorators. You may provide
2773
+ your own in addition to the builtin decorators.
2774
+
2775
+ Decorators may:
2776
+ - Add icons
2777
+ - Set highlight group for the name or icons
2778
+ - Override node icon
2779
+
2780
+ Create your decorator class via `api.decorator.DecoratorUser: extend ()` and add it
2781
+ to | nvim-tree.renderer.decorators |
2782
+
2783
+ e.g. default decorators with an user decorator being overridden only by Cut: >lua
2784
+ {
2785
+ "Git",
2786
+ "Opened",
2787
+ "Hidden",
2788
+ "Modified",
2789
+ "Bookmarks",
2790
+ "Diagnostics",
2791
+ "Copied",
2792
+ MyDecorator,
2793
+ "Cut",
2794
+ }
2795
+ <
2796
+ See `api_decorator.lua ` for decorator class definition and full documentation.
2797
+
2798
+ Example decorator: >lua
2799
+
2800
+ ---Create your decorator class
2801
+ ---@class (exact) MyDecorator: nvim_tree.api.decorator.DecoratorUser
2802
+ ---@field private my_icon nvim_tree.api.HighlightedString
2803
+ local MyDecorator = require("nvim-tree.api").decorator.DecoratorUser:extend()
2804
+
2805
+ ---Mandatory constructor :new() will be called once per tree render, with no arguments.
2806
+ function MyDecorator:new()
2807
+ self.enabled = true
2808
+ self.highlight_range = "all"
2809
+ self.icon_placement = "signcolumn"
2810
+
2811
+ -- create your icon once, for convenience
2812
+ self.my_icon = { str = "I", hl = { "MyIcon" } }
2813
+
2814
+ -- Define the icon sign only once
2815
+ -- Only needed if you are using icon_placement = "signcolumn"
2816
+ self:define_sign(self.my_icon)
2817
+ end
2818
+
2819
+ ---Override node icon
2820
+ ---@param node nvim_tree.api.Node
2821
+ ---@return nvim_tree.api.HighlightedString? icon_node
2822
+ function MyDecorator:icon_node(node)
2823
+ if node.name == "example" then
2824
+ return self.my_icon
2825
+ else
2826
+ return nil
2827
+ end
2828
+ end
2829
+
2830
+ ---Return one icon for DecoratorIconPlacement
2831
+ ---@param node nvim_tree.api.Node
2832
+ ---@return nvim_tree.api.HighlightedString[]? icons
2833
+ function MyDecorator:icons(node)
2834
+ if node.name == "example" then
2835
+ return { self.my_icon }
2836
+ else
2837
+ return nil
2838
+ end
2839
+ end
2840
+
2841
+ ---Exactly one highlight group for DecoratorHighlightRange
2842
+ ---@param node nvim_tree.api.Node
2843
+ ---@return string? highlight_group
2844
+ function MyDecorator:highlight_group(node)
2845
+ if node.name == "example" then
2846
+ return "MyHighlight"
2847
+ else
2848
+ return nil
2849
+ end
2850
+ end
2851
+ <
2852
+ ==============================================================================
2853
+ 12. OS SPECIFIC RESTRICTIONS *nvim-tree-os-specific*
2776
2854
2777
2855
Windows WSL and PowerShell
2778
2856
- Trash is synchronized
@@ -2784,7 +2862,7 @@ Windows WSL and PowerShell
2784
2862
issues or disable this feature.
2785
2863
2786
2864
==============================================================================
2787
- 12 . NETRW *nvim-tree-netrw*
2865
+ 13 . NETRW *nvim-tree-netrw*
2788
2866
2789
2867
| netrw | is a standard neovim plugin that is enabled by default. It provides,
2790
2868
amongst other functionality, a file/directory browser.
@@ -2805,14 +2883,14 @@ keep using |netrw| without its browser features please ensure:
2805
2883
| nvim-tree.hijack_netrw | ` = true`
2806
2884
2807
2885
==============================================================================
2808
- 13 . LEGACY *nvim-tree-legacy*
2886
+ 14 . LEGACY *nvim-tree-legacy*
2809
2887
2810
2888
Breaking refactors have been made however the legacy versions will be silently
2811
2889
migrated and used.
2812
2890
There are no plans to remove this migration.
2813
2891
2814
2892
==============================================================================
2815
- 13 .1 LEGACY: OPTS *nvim-tree-legacy-opts*
2893
+ 14 .1 LEGACY: OPTS *nvim-tree-legacy-opts*
2816
2894
2817
2895
Legacy options are translated to the current, making type and value changes as
2818
2896
needed.
@@ -2830,7 +2908,7 @@ needed.
2830
2908
`renderer.icons.webdev_colors` | nvim-tree.renderer.icons.web_devicons.file.color |
2831
2909
2832
2910
==============================================================================
2833
- 13 .2 LEGACY: HIGHLIGHT *nvim-tree-legacy-highlight*
2911
+ 14 .2 LEGACY: HIGHLIGHT *nvim-tree-legacy-highlight*
2834
2912
2835
2913
Legacy highlight group are still obeyed when they are defined and the current
2836
2914
highlight group is not, hard linking as follows: >
@@ -2879,10 +2957,10 @@ highlight group is not, hard linking as follows: >
2879
2957
NvimTreeLspDiagnosticsHintFolderText NvimTreeDiagnosticHintFolderHL
2880
2958
<
2881
2959
==============================================================================
2882
- 14 INDEX *nvim-tree-index*
2960
+ 15 INDEX *nvim-tree-index*
2883
2961
2884
2962
==============================================================================
2885
- 14 .1 INDEX: OPTS *nvim-tree-index-opts*
2963
+ 15 .1 INDEX: OPTS *nvim-tree-index-opts*
2886
2964
2887
2965
| nvim-tree.actions.change_dir |
2888
2966
| nvim-tree.actions.change_dir.enable |
@@ -3051,7 +3129,7 @@ highlight group is not, hard linking as follows: >
3051
3129
| nvim-tree.view.width.padding |
3052
3130
3053
3131
==============================================================================
3054
- 14 .2 INDEX: API *nvim-tree-index-api*
3132
+ 15 .2 INDEX: API *nvim-tree-index-api*
3055
3133
3056
3134
| nvim-tree-api.commands.get() |
3057
3135
| nvim-tree-api.config.mappings.default_on_attach() |
0 commit comments