-
-
Notifications
You must be signed in to change notification settings - Fork 133
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
base: v3.0
Are you sure you want to change the base?
Conversation
is there not a better way to do this :/ , i dont like such computations in cmp config as it'd render on every keystroke! |
It's looking way too similar to this hrsh7th/nvim-cmp#980 (comment) |
I think there's two ways to solve:
|
shamelessly stole from there |
lua/nvchad/cmp/init.lua
Outdated
@@ -26,7 +26,7 @@ local M = { | |||
|
|||
-- item.abbr maxwidth and minwidth | |||
local ellipsis_char = '…' | |||
local abbr_maxwidth = math.floor(vim.o.columns / 2) | |||
local abbr_maxwidth = 29 |
There was a problem hiding this comment.
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)
exposed an option ` cmp.format_abbr` to user: ``` cmp = { format_abbr = { maxwidth = 20, minwidth = 20, } } ```
I have added an option cmp = {
icons_left = false, -- only for non-atom styles!
lspkind_text = true,
style = "default", -- default/flat_light/flat_dark/atom/atom_colored
format_colors = {
tailwind = false, -- will work for css lsp too
icon = "",
},
format_abbr = {
maxwidth = 20,
minwidth = 10,
}
}, How about make it look like: cmp = {
icons_left = false, -- only for non-atom styles!
lspkind_text = true,
style = "default", -- default/flat_light/flat_dark/atom/atom_colored
format = {
colors = {
tailwind = false, -- will work for css lsp too
icon = "",
},
abbr = {
maxwidth = 20,
minwidth = 10,
}
},
} Its' more clean but not back compatiable (we need to use There's maybe other |
ugh i dislike such large & complex changes :/ cant we just use string:sub? |
I can not find a better way...
I don’t think I can come up with a better solution... |
Does adding this autocmd make the code seem too complex to you? The entire cost of this commit is that for each completion item, it needs to determine if it is too long, which is an unavoidable cost. The cost of the autocmd is almost negligible. |
dont close this yet, i dont think the autocmd is much of useful, I want the user to keep a fixed maxwidth. not depending on the nvim's window size. |
8b670b9
to
5be808e
Compare
Sometimes, cmp completion window, item.abbr too long. this commit can restrict item.abbr width. Maybe the default maxwidth and minwidth can be adjust.
before:
after: