How to make description column the 2nd column ? #290
-
While I typing a keyword, I will check the column to see if the keyword is sufficient enough. It is strange/uncomfortable that I have to move my eye from the left(where the keyword at) to the right(description column), see the above picture. If the description is at 2nd column, I just need to move eye vertically, usually just the first line below the keyword, it is more convenient, what do you think? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
You can override the columns via ---Default format
---@param item LegendaryItem
---@return string[]
function M.default_format(item)
if Toolbox.is_keymap(item) then
return {
table.concat(item:modes(), ', '),
item.keys,
item.description,
}
elseif Toolbox.is_command(item) then
return {
'',
item.cmd,
item.description,
}
elseif Toolbox.is_autocmd(item) then
return {
table.concat(item.events, ', '),
table.concat(vim.tbl_get(item, 'opts', 'pattern') or { '*' }, ', '),
item.description,
}
elseif Toolbox.is_function(item) then
return {
'',
'<function>',
item.description,
}
elseif Toolbox.is_itemgroup(item) then
return {
item.icon or '',
item.name,
item.description or 'Expand to select an item...',
}
else
-- unreachable
return {
vim.inspect(item),
'',
'',
}
end
end So you could write a function that's basically the same but swaps the 2nd and 3rd columns, then assign it like: require('legendary').setup({ default_item_formatter = my_format_fn }) This is described briefly in the README.md as well under Configuration. |
Beta Was this translation helpful? Give feedback.
You can override the columns via
config.default_item_formatter
which takes an item and returns a list of strings, one string per column. Here's the default formatter code: