Skip to content

Commit

Permalink
feat(cmp): attempt for dynamic width and trimming between fields (Laz…
Browse files Browse the repository at this point in the history
…yVim#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 LazyVim#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 <[email protected]>
  • Loading branch information
dpetka2001 and folke authored Jun 30, 2024
1 parent d23731c commit 78cf6ee
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions lua/lazyvim/plugins/coding.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
Expand Down

0 comments on commit 78cf6ee

Please sign in to comment.