@@ -370,33 +370,43 @@ local M = {}
370
370
371
371
function M .draw_help ()
372
372
local help_lines = {' HELP' }
373
- local help_hl = {{' NvimTreeRootFolder' , 0 , 0 , string.len ( ' HELP ' ) }}
373
+ local help_hl = {{' NvimTreeRootFolder' , 0 , 0 , # help_lines [ 1 ] }}
374
374
local bindings = view .View .bindings
375
375
local processed = {}
376
- for i , v in pairs (bindings ) do
377
- if v :sub (1 ,35 ) == view .nvim_tree_callback (' test' ):sub (1 ,35 ) then
378
- v = v :match (" '[^']+'[^']*$" )
379
- v = v :match (" '[^']+'" )
380
- table.insert (processed ,{i ,v ,true })
376
+ for _ , b in pairs (bindings ) do
377
+ local cb = b .cb
378
+ local key = b .key
379
+ if cb :sub (1 ,35 ) == view .nvim_tree_callback (' test' ):sub (1 ,35 ) then
380
+ cb = cb :match (" '[^']+'[^']*$" )
381
+ cb = cb :match (" '[^']+'" )
382
+ table.insert (processed , {key , cb , true })
381
383
else
382
- v = ' "' .. v .. ' "'
383
- table.insert (processed ,{ i , v , false })
384
+ cb = ' "' .. cb .. ' "'
385
+ table.insert (processed , { key , cb , false })
384
386
end
385
387
end
386
- table.sort (processed ,function (a ,b )
387
- return (a [3 ]== b [3 ] and (a [2 ]< b [2 ] or (a [2 ]== b [2 ] and # a [1 ]<# b [1 ]))) or (a [3 ] and not b [3 ])
388
+ table.sort (processed , function (a ,b )
389
+ return (a [3 ] == b [3 ]
390
+ and (a [2 ] < b [2 ] or (a [2 ] == b [2 ] and # a [1 ] < # b [1 ])))
391
+ or (a [3 ] and not b [3 ])
388
392
end )
389
- local i , v , builtin
390
- for num , val in pairs (processed ) do
391
- i = val [1 ]
392
- v = val [2 ]
393
- builtin = val [3 ]
394
- local bind_string = string.format (" %6s : %s" ,i ,v )
395
- table.insert (help_lines ,bind_string )
396
- local hl_len = math.max (6 ,# i )+ 2
397
- table.insert (help_hl ,{' NvimTreeFolderName' , num , 0 , hl_len })
398
- if not builtin then
399
- table.insert (help_hl ,{' NvimTreeFileRenamed' , num , hl_len , - 1 })
393
+
394
+ local num = 0
395
+ for _ , val in pairs (processed ) do
396
+ local keys = type (val [1 ]) == " string" and {val [1 ]} or val [1 ]
397
+ local map_name = val [2 ]
398
+ local builtin = val [3 ]
399
+ for _ , key in pairs (keys ) do
400
+ num = num + 1
401
+ local bind_string = string.format (" %6s : %s" , key , map_name )
402
+ table.insert (help_lines , bind_string )
403
+
404
+ local hl_len = math.max (6 , string.len (key )) + 2
405
+ table.insert (help_hl , {' NvimTreeFolderName' , num , 0 , hl_len })
406
+
407
+ if not builtin then
408
+ table.insert (help_hl , {' NvimTreeFileRenamed' , num , hl_len , - 1 })
409
+ end
400
410
end
401
411
end
402
412
return help_lines , help_hl
0 commit comments