Skip to content

Commit fd7f60e

Browse files
authored
feat(help ui): allow custom names to be provided for custom keybinds (#485)
1 parent 5417b9c commit fd7f60e

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

lua/nvim-tree/renderer.lua

+7-5
Original file line numberDiff line numberDiff line change
@@ -376,13 +376,15 @@ function M.draw_help()
376376
for _, b in pairs(bindings) do
377377
local cb = b.cb
378378
local key = b.key
379+
local name
379380
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+
name = cb:match("'[^']+'[^']*$")
382+
name = name:match("'[^']+'")
383+
table.insert(processed, {key, name, true})
383384
else
384-
cb = '"' .. cb .. '"'
385-
table.insert(processed, {key, cb, false})
385+
name = (b.name ~= nil) and b.name or cb
386+
name = '"' .. name .. '"'
387+
table.insert(processed, {key, name, false})
386388
end
387389
end
388390
table.sort(processed, function(a,b)

lua/nvim-tree/view.lua

+1-1
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ function M.setup()
142142
if vim.g.nvim_tree_disable_default_keybindings == 1 then
143143
M.View.bindings = user_mappings
144144
else
145-
ok, result = pcall(vim.fn.extend, M.View.bindings, user_mappings)
145+
local ok, result = pcall(vim.fn.extend, M.View.bindings, user_mappings)
146146
if not ok then
147147
-- TODO: remove this in a few weeks
148148
warn_wrong_mapping()

0 commit comments

Comments
 (0)