feat: make menu fixed size

This commit is contained in:
fiplox 2023-04-09 12:42:41 +02:00
parent 403925def9
commit b3dbc8eddf
1 changed files with 10 additions and 2 deletions

View File

@ -76,9 +76,17 @@ function M.config()
ghost_text = true,
},
formatting = {
fields = { 'menu', 'abbr', 'kind' },
format = function(_, item)
fields = { 'abbr', 'kind', 'menu' },
format = function(entry, item)
local ELLIPSIS_CHAR = ''
local MAX_LABEL_WIDTH = 20
item.kind = string.format('%s %s', kind_icons[item.kind], item.kind) -- This concatonates the icons with the name of the item kind
local label = item.abbr
local truncated_label = vim.fn.strcharpart(label, 0, MAX_LABEL_WIDTH)
if truncated_label ~= label then
item.abbr = truncated_label .. ELLIPSIS_CHAR
end
return item
end,
},