Skip to content

Commit 5fac9a1

Browse files
committed
chore(mappings): add desc to all mappings
1 parent cd6d295 commit 5fac9a1

File tree

1 file changed

+7
-18
lines changed

1 file changed

+7
-18
lines changed

lua/nvim-tree/renderer/help.lua

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -10,22 +10,14 @@ local function tidy_lhs(lhs)
1010
end
1111

1212
-- uppercase ctrls
13-
if lhs:match "^<C%-" then
13+
if lhs:lower():match "^<c%-" then
1414
lhs = lhs:upper()
1515
end
1616

17-
return lhs
18-
end
17+
-- space is not escaped
18+
lhs = lhs:gsub(" ", "<Space>")
1919

20-
local function shorten_lhs(lhs)
2120
return lhs
22-
:gsub("LeftMouse>$", "LM>")
23-
:gsub("RightMouse>$", "RM>")
24-
:gsub("MiddleMouse>$", "MM>")
25-
:gsub("ScrollWheelDown>$", "SD>")
26-
:gsub("ScrollWheelUp>$", "SU>")
27-
:gsub("ScrollWheelLeft>$", "SL>")
28-
:gsub("ScrollWheelRight>$", "SR>")
2921
end
3022

3123
-- sort lhs roughly as per :help index
@@ -78,19 +70,16 @@ function M.compute_lines()
7870
return sort_lhs(a.lhs, b.lhs)
7971
end)
8072

81-
for _, p in pairs(lines) do
82-
p.lhs = shorten_lhs(p.lhs)
83-
end
84-
8573
local num = 0
8674
for _, p in pairs(lines) do
8775
num = num + 1
88-
local bind_string = string.format("%-6.6s %s", shorten_lhs(p.lhs), p.desc)
76+
local bind_string = string.format("%-5s %s", p.lhs, p.desc)
77+
local hl_len = math.max(5, string.len(p.lhs))
8978
table.insert(help_lines, bind_string)
9079

91-
table.insert(help_hl, { "NvimTreeFolderName", num, 0, 6 })
80+
table.insert(help_hl, { "NvimTreeFolderName", num, 0, hl_len })
9281

93-
table.insert(help_hl, { "NvimTreeFileRenamed", num, 6, -1 })
82+
table.insert(help_hl, { "NvimTreeFileRenamed", num, hl_len, -1 })
9483
end
9584
return help_lines, help_hl
9685
end

0 commit comments

Comments
 (0)