Skip to content

feat(help ui): allow custom names to be provided for custom keybinds #485

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 6, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions lua/nvim-tree/renderer.lua
Original file line number Diff line number Diff line change
Expand Up @@ -376,13 +376,15 @@ function M.draw_help()
for _, b in pairs(bindings) do
local cb = b.cb
local key = b.key
local name
if cb:sub(1,35) == view.nvim_tree_callback('test'):sub(1,35) then
cb = cb:match("'[^']+'[^']*$")
cb = cb:match("'[^']+'")
table.insert(processed, {key, cb, true})
name = cb:match("'[^']+'[^']*$")
name = name:match("'[^']+'")
table.insert(processed, {key, name, true})
else
cb = '"' .. cb .. '"'
table.insert(processed, {key, cb, false})
name = (b.name ~= nil) and b.name or cb
name = '"' .. name .. '"'
table.insert(processed, {key, name, false})
end
end
table.sort(processed, function(a,b)
Expand Down
2 changes: 1 addition & 1 deletion lua/nvim-tree/view.lua
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ function M.setup()
if vim.g.nvim_tree_disable_default_keybindings == 1 then
M.View.bindings = user_mappings
else
ok, result = pcall(vim.fn.extend, M.View.bindings, user_mappings)
local ok, result = pcall(vim.fn.extend, M.View.bindings, user_mappings)
if not ok then
-- TODO: remove this in a few weeks
warn_wrong_mapping()
Expand Down