Skip to content
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

feat(render): merge keybindings in UI #1332

Closed
wants to merge 1 commit into from
Closed
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
23 changes: 19 additions & 4 deletions lua/lazy/view/render.lua
Original file line number Diff line number Diff line change
Expand Up @@ -621,10 +621,25 @@ function M:handlers(plugin, types)
types = type(types) == "string" and { types } or types
types = types and types or vim.tbl_keys(Handler.types)
for _, t in ipairs(types) do
for id, value in pairs(plugin._.handlers[t] or {}) do
value = t == "keys" and Keys.to_string(value) or id
self:reason({ [t] = value })
self:append(" ")
items = plugin._.handlers[t] or {}
if t == "keys" then
local last_key_val = nil
for id, value in vim.spairs(items) do
value = Keys.to_string(value) or id
local value_pat = vim.pesc(value)
if last_key_val and string.find(value_pat, "^" .. last_key_val) then
-- matches previous, shorter prefix - pass
else
self:reason({ [t] = value })
self:append(" ")
last_key_val = value_pat
end
end
else
for _, value in pairs(items) do
self:reason({ [t] = value })
self:append(" ")
end
end
end
end
Expand Down