feat: make results pane of builtin keymaps more readable (#1684)

This commit is contained in:
daangoossens22
2022-01-14 21:13:32 +01:00
committed by GitHub
parent 303f3ca6f7
commit d173740bb4
2 changed files with 50 additions and 15 deletions

View File

@@ -693,6 +693,44 @@ function make_entry.gen_from_registers(_)
end
end
function make_entry.gen_from_keymaps(opts)
local function get_desc(entry)
return entry.desc or entry.rhs or "Lua function"
end
local function get_lhs(entry)
return utils.display_termcodes(entry.lhs)
end
local displayer = require("telescope.pickers.entry_display").create {
separator = "",
items = {
{ width = 2 },
{ width = opts.width_lhs },
{ remaining = true },
},
}
local make_display = function(entry)
return displayer {
entry.mode,
get_lhs(entry),
get_desc(entry),
}
end
return function(entry)
return {
mode = entry.mode,
lhs = get_lhs(entry),
desc = get_desc(entry),
--
valid = entry ~= "",
value = entry,
ordinal = entry.mode .. " " .. get_lhs(entry) .. " " .. get_desc(entry),
display = make_display,
}
end
end
function make_entry.gen_from_highlights()
local make_display = function(entry)
local display = entry.value