1- local appearance = require " nvim-tree.appearance"
21local core = require " nvim-tree.core"
32local live_filter = require " nvim-tree.live-filter"
43local notify = require " nvim-tree.notify"
@@ -46,7 +45,7 @@ local M = {
4645--- @field private root_cwd string absolute path
4746--- @field private index number
4847--- @field private depth number
49- --- @field private combined_groups string[] combined group names
48+ --- @field private combined_groups table< string , boolean> combined group names
5049--- @field private markers boolean[] indent markers
5150local Builder = {}
5251
@@ -246,22 +245,17 @@ function Builder:build_signs(node)
246245 end
247246end
248247
249- --- Combined group name less than the 200 byte limit of highlight group names
250- --- @private
251- --- @param groups string[] highlight group names
252- --- @return string name " NvimTreeCombinedHL" .. sha256
253- function Builder :combined_group_name (groups )
254- return string.format (" NvimTreeCombinedHL%s" , vim .fn .sha256 (table.concat (groups )))
255- end
256-
257248--- Create a highlight group for groups with later groups overriding previous.
249+ --- Combined group name is less than the 200 byte limit of highlight group names
258250--- @private
259251--- @param groups string[] highlight group names
252+ --- @return string group_name " NvimTreeCombinedHL" .. sha256
260253function Builder :create_combined_group (groups )
261- local combined_name = self : combined_group_name ( groups )
254+ local combined_name = string.format ( " NvimTreeCombinedHL%s " , vim . fn . sha256 ( table.concat ( groups )) )
262255
263256 -- only create if necessary
264- if not vim .tbl_contains (self .combined_groups , combined_name ) then
257+ if not self .combined_groups [combined_name ] then
258+ self .combined_groups [combined_name ] = true
265259 local combined_hl = {}
266260
267261 -- build the highlight, overriding values
@@ -270,11 +264,13 @@ function Builder:create_combined_group(groups)
270264 combined_hl = vim .tbl_extend (" force" , combined_hl , hl )
271265 end
272266
273- -- highlight directly in the namespace
274- vim .api .nvim_set_hl (appearance . NS_ID , combined_name , combined_hl )
267+ -- add highlights to the global namespace
268+ vim .api .nvim_set_hl (0 , combined_name , combined_hl )
275269
276270 table.insert (self .combined_groups , combined_name )
277271 end
272+
273+ return combined_name
278274end
279275
280276--- Calculate highlight group for icon and name. A combined highlight group will be created
@@ -301,16 +297,14 @@ function Builder:add_highlights(node)
301297
302298 -- one or many icon groups
303299 if # icon_groups > 1 then
304- icon_hl_group = self :combined_group_name (icon_groups )
305- self :create_combined_group (icon_groups )
300+ icon_hl_group = self :create_combined_group (icon_groups )
306301 else
307302 icon_hl_group = icon_groups [1 ]
308303 end
309304
310305 -- one or many name groups
311306 if # name_groups > 1 then
312- name_hl_group = self :combined_group_name (name_groups )
313- self :create_combined_group (name_groups )
307+ name_hl_group = self :create_combined_group (name_groups )
314308 else
315309 name_hl_group = name_groups [1 ]
316310 end
0 commit comments