Skip to content

Commit 2907185

Browse files
committed
limit to two highlight groups for line rendering
1 parent 1295a2b commit 2907185

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
@@ -790,8 +790,8 @@ Use nvim-tree in a floating window.
790790
==============================================================================
791791
5.3 OPTS: RENDERER *nvim-tree-opts-renderer*
792792

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

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

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

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

22242224
Default linked group or definition follows name.
22252225

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

2344-
2023/10/XX revision xxxxx made significant highlighting changes, some breaking:
2347+
2023-12: significant highlighting changes, some breaking:
23452348

23462349
- Full cterm support.
23472350
- 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)