diff --git a/lua/plugins/cmp.lua b/lua/plugins/cmp.lua index d22091f..abd6403 100644 --- a/lua/plugins/cmp.lua +++ b/lua/plugins/cmp.lua @@ -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, },