feat(cmp): only trim item.abbr when item.menu present, looks better in Lua

This commit is contained in:
Iordanis Petkakis 2024-06-30 21:16:32 +03:00
parent b129a100c3
commit 51ea8c4eaf

View file

@ -74,10 +74,10 @@ return {
-- Truncate the completion entry text if it's longer than the
-- max content width. We subtract 3 from the max content width
-- to account for the "..." that will be appended to it.
if #item.abbr > (max_content_width / 2) then
if item.menu and #item.abbr > (max_content_width * 0.7) then
item.abbr = vim.fn.strcharpart(item.abbr, 0, math.floor(max_content_width * 0.7) - 3) .. "..."
end
if item.menu and #item.menu > (max_content_width / 2) then
if item.menu and #item.menu > (max_content_width * 0.7) then
item.menu = vim.fn.strcharpart(item.menu, 0, math.floor(max_content_width * 0.7) - 3) .. "..."
end