Skip to content

Commit 2569b24

Browse files
committed
limit to two highlight groups for line rendering
1 parent 4a24950 commit 2569b24

File tree

2 files changed

+20
-8
lines changed

2 files changed

+20
-8
lines changed

doc/nvim-tree-lua.txt

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -789,8 +789,8 @@ Use nvim-tree in a floating window.
789789
==============================================================================
790790
5.3 OPTS: RENDERER *nvim-tree-opts-renderer*
791791

792-
Highlight precedence:
793-
cut > copied > diagnostics > bookmarked > modified > opened > git
792+
Highlight precedence, additive:
793+
git < opened < modified < bookmarked < diagnostics < copied < cut
794794

795795
*nvim-tree.renderer.add_trailing*
796796
Appends a trailing slash to folder names.
@@ -894,8 +894,8 @@ Configuration options for tree indent markers.
894894
*nvim-tree.renderer.icons*
895895
Configuration options for icons.
896896

897-
Icon sign column precedence:
898-
diagnostics > bookmarked > modified > git
897+
Icon order and sign column precedence:
898+
git < modified < bookmarked < diagnostics
899899

900900
*nvim-tree.renderer.icons.web_devicons*
901901
Configure optional plugin `"nvim-tree/nvim-web-devicons"`
@@ -2222,6 +2222,9 @@ as per |:highlight|
22222222

22232223
Default linked group or definition follows name.
22242224

2225+
neovim 0.9 has a limit of two highlight groups per range. The two highest
2226+
priority groups as per |nvim-tree-opts-renderer| will be used.
2227+
22252228
Standard: >
22262229
NvimTreeNormal Normal
22272230
NvimTreeNormalFloat NormalFloat
@@ -2340,7 +2343,7 @@ Diagnostics Folder Highlight: >
23402343
==============================================================================
23412344
8.1 HIGHLIGHT OVERHAUL *nvim-tree-highlight-overhaul*
23422345

2343-
2023/10/XX revision xxxxx made significant highlighting changes, some breaking:
2346+
2023-12: significant highlighting changes, some breaking:
23442347

23452348
- Full cterm support.
23462349
- Standard vim highlight groups such |DiagnosticUnderlineError| are now the

lua/nvim-tree/renderer/builder.lua

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,16 @@ function Builder:configure_group_name_modifier(group_name_modifier)
7474
return self
7575
end
7676

77-
function Builder:_insert_highlight(group, start, end_)
78-
table.insert(self.highlights, { group, self.index, start, end_ or -1 })
77+
--- Insert ranged highlight groups into self.highlights
78+
--- neovim 0.9 is limited to two highlight groups for a range so choose the highest two
79+
--- @param groups string[]
80+
--- @param start number
81+
--- @param end_ number|nil
82+
function Builder:_insert_highlight(groups, start, end_)
83+
local top_two_groups = {}
84+
table.insert(top_two_groups, groups[#groups - 1])
85+
table.insert(top_two_groups, groups[#groups])
86+
table.insert(self.highlights, { top_two_groups, self.index, start, end_ or -1 })
7987
end
8088

8189
function Builder:_insert_line(line)
@@ -271,7 +279,8 @@ function Builder:_build_line(node, idx, num_children)
271279
end
272280

273281
-- highighting
274-
for _, d in ipairs(self.decorators) do
282+
for i = #self.decorators, 1, -1 do
283+
local d = self.decorators[i]
275284
local icon_group, name_group = d:groups_icon_name(node)
276285
table.insert(icon.hl, icon_group)
277286
table.insert(name.hl, name_group)

0 commit comments

Comments
 (0)