feat: table layout for builtin commands (#754)
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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 = "~",
|
||||
|
||||
Reference in New Issue
Block a user