Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

setup cmp window, item.abbr maxwidth and minwidth #361

Open
wants to merge 8 commits into
base: v3.0
Choose a base branch
from
14 changes: 14 additions & 0 deletions lua/nvchad/cmp/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,20 @@ local M = {
format_kk.tailwind(entry, item)
end

-- item.abbr maxwidth and minwidth
local ellipsis_char = '…'
local abbr_maxwidth = 29
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

au VimResized with a variable storing the width will be better (if it's possible)

local abbr_minwidth = 0

local abbr = item.abbr
local truncated_abbr = vim.fn.strcharpart(abbr, 0, abbr_maxwidth)
if truncated_abbr ~= abbr then
item.abbr = truncated_abbr .. ellipsis_char
elseif string.len(abbr) < abbr_minwidth then
local padding = string.rep(' ', abbr_minwidth - string.len(abbr))
item.abbr = abbr .. padding
end

return item
end,

Expand Down