feat: table layout for builtin commands (#754)

This commit is contained in:
Weihang Lo
2021-04-15 21:26:38 +08:00
committed by GitHub
parent 2e7ee55aa4
commit 9e603d3c1b
2 changed files with 44 additions and 8 deletions

View File

@@ -159,14 +159,8 @@ internal.commands = function(opts)
return commands
end)(),
entry_maker = function(line)
return {
valid = line ~= "",
value = line,
ordinal = line.name,
display = line.name
}
end
entry_maker = opts.entry_maker or make_entry.gen_from_commands(opts),
},
sorter = conf.generic_sorter(opts),
attach_mappings = function(prompt_bufnr)

View File

@@ -1019,6 +1019,48 @@ function make_entry.gen_from_autocommands(_)
end
end
function make_entry.gen_from_commands(_)
local displayer = entry_display.create {
separator = "",
items = {
{ width = 25 },
{ width = 4 },
{ width = 4 },
{ width = 11 },
{ remaining = true },
},
}
local make_display = function(entry)
local attrs = ""
if entry.bang then attrs = attrs .. "!" end
if entry.bar then attrs = attrs .. "|" end
if entry.register then attrs = attrs .. '"' end
return displayer {
{entry.name, "TelescopeResultsIdentifier"},
attrs,
entry.nargs,
entry.complete or "",
entry.definition,
}
end
return function(entry)
return {
name = entry.name,
bang = entry.bang,
nargs = entry.nargs,
complete = entry.complete,
definition = entry.definition,
--
value = entry,
valid = true,
ordinal = entry.name,
display = make_display,
}
end
end
local git_icon_defaults = {
added = "+",
changed = "~",