@@ -11,6 +11,8 @@ local WIN_HL = table.concat({
11
11
" CursorLine:NvimTreeCursorLine" ,
12
12
}, " ," )
13
13
14
+ local namespace_help_id = vim .api .nvim_create_namespace (" NvimTreeHelp" )
15
+
14
16
local M = {
15
17
config = {},
16
18
82
84
83
85
--- Compute all lines for the buffer
84
86
--- @param map table keymap.get_keymap
85
- --- @return table strings of text
86
- --- @return table arrays of arguments 3-6 for nvim_buf_add_highlight ()
87
+ --- @return string[] lines of text
88
+ --- @return table[] hl for lines : named arguments for vim.hl.range : higroup , start , finish
87
89
--- @return number maximum length of text
88
90
local function compute (map )
89
91
local head_lhs = " nvim-tree mappings"
@@ -131,9 +133,9 @@ local function compute(map)
131
133
132
134
-- header highlight, assume one character keys
133
135
local hl = {
134
- { " NvimTreeFolderName" , 0 , 0 , # head_lhs },
135
- { " NvimTreeFolderName" , 0 , width - 1 , width },
136
- { " NvimTreeFolderName" , 1 , width - 1 , width },
136
+ { higroup = " NvimTreeFolderName" , start = { 0 , 0 , }, finish = { 0 , # head_lhs , }, },
137
+ { higroup = " NvimTreeFolderName" , start = { 0 , width - 1 , }, finish = { 0 , width , }, },
138
+ { higroup = " NvimTreeFolderName" , start = { 1 , width - 1 , }, finish = { 1 , width , }, },
137
139
}
138
140
139
141
-- mappings, left padded 1
@@ -145,7 +147,7 @@ local function compute(map)
145
147
width = math.max (# line , width )
146
148
147
149
-- highlight lhs
148
- table.insert (hl , { " NvimTreeFolderName" , i + 1 , 1 , # l .lhs + 1 })
150
+ table.insert (hl , { higroup = " NvimTreeFolderName" , start = { i + 1 , 1 , }, finish = { i + 1 , # l .lhs + 1 , }, })
149
151
end
150
152
151
153
return lines , hl , width
@@ -188,7 +190,11 @@ local function open()
188
190
189
191
-- highlight it
190
192
for _ , h in ipairs (hl ) do
191
- vim .api .nvim_buf_add_highlight (M .bufnr , - 1 , h [1 ], h [2 ], h [3 ], h [4 ])
193
+ if vim .fn .has (" nvim-0.11" ) == 1 then
194
+ vim .hl .range (M .bufnr , namespace_help_id , h .higroup , h .start , h .finish , {})
195
+ else
196
+ vim .api .nvim_buf_add_highlight (M .bufnr , - 1 , h .higroup , h .start [1 ], h .start [2 ], h .finish [2 ]) --- @diagnostic disable-line : deprecated
197
+ end
192
198
end
193
199
194
200
-- open a very restricted window
0 commit comments