feat(cmp): attempt for dynamic width and trimming between fields (#3873)
## What is this PR for? Attempt for dynamic width and trimming between fields. Testing was done on my 15.6 laptop screen so maybe values could be raised in dynamic calculation? Also provides a `vim.g.cmp_fixed_width` for the users to be able to define a fixed width in their personal configuration if they'd like to. <!-- Describe the big picture of your changes to communicate to the maintainers why we should accept this pull request. --> ## Does this PR fix an existing issue? Attempts to rectify a concern raised in #3858 <!-- If this PR fixes any issues, please link to the issue here. Fixes #<issue_number> --> ## Checklist - [x] I've read the [CONTRIBUTING](https://github.com/LazyVim/LazyVim/blob/main/CONTRIBUTING.md) guidelines. --------- Co-authored-by: Folke Lemaitre <folke.lemaitre@gmail.com>
This commit is contained in:

committed by
GitHub

parent
d23731c50d
commit
78cf6ee024
@ -54,9 +54,18 @@ return {
|
||||
if icons[item.kind] then
|
||||
item.kind = icons[item.kind] .. item.kind
|
||||
end
|
||||
if entry.context.filetype == "rust" then
|
||||
item.menu = nil
|
||||
|
||||
local widths = {
|
||||
abbr = vim.g.cmp_widths and vim.g.cmp_widths.abbr or 40,
|
||||
menu = vim.g.cmp_widths and vim.g.cmp_widths.menu or 30,
|
||||
}
|
||||
|
||||
for key, width in pairs(widths) do
|
||||
if item[key] and vim.fn.strdisplaywidth(item[key]) > width then
|
||||
item[key] = vim.fn.strcharpart(item[key], 0, width - 1) .. "…"
|
||||
end
|
||||
end
|
||||
|
||||
return item
|
||||
end,
|
||||
},
|
||||
|
Reference in New Issue
Block a user