diff options
| author | daangoossens22 <62295482+daangoossens22@users.noreply.github.com> | 2022-01-14 21:13:32 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-01-14 21:13:32 +0100 |
| commit | d173740bb49654d755ea1b0018c9a6c6f8689f98 (patch) | |
| tree | b71385d11f90434477b30746c51cba82d8c8bf2c /lua/telescope/make_entry.lua | |
| parent | 303f3ca6f732a50697a11ebe76d2d0fef3b3a4a1 (diff) | |
feat: make results pane of builtin `keymaps` more readable (#1684)
Diffstat (limited to 'lua/telescope/make_entry.lua')
| -rw-r--r-- | lua/telescope/make_entry.lua | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/lua/telescope/make_entry.lua b/lua/telescope/make_entry.lua index 2d53248..98129d7 100644 --- a/lua/telescope/make_entry.lua +++ b/lua/telescope/make_entry.lua @@ -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 |
