-
Notifications
You must be signed in to change notification settings - Fork 397
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
Fix the width of completion menu #980
Comments
#609 (comment) Is that solution good enough? |
No. As I mentioned in my comments to that question. The solution in #609 (comment) only helps to truncate items to a maximum width. It doesn't help to eliminate the jarring visual effects of changing pop-up width during completion. |
I think you can define minimum width in |
@Shougo Nice. Can you show us how? |
local ELLIPSIS_CHAR = '…'
local MAX_LABEL_WIDTH = 20
local MIN_LABEL_WIDTH = 20
cmp.setup({
formatting = {
format = function(entry, vim_item)
local label = vim_item.abbr
local truncated_label = vim.fn.strcharpart(label, 0, MAX_LABEL_WIDTH)
if truncated_label ~= label then
vim_item.abbr = truncated_label .. ELLIPSIS_CHAR
elseif string.len(label) < MIN_LABEL_WIDTH then
local padding = string.rep(' ', MIN_LABEL_WIDTH - string.len(label))
vim_item.abbr = label .. padding
end
return vim_item
end,
},
}) |
@Shougo Awesome. Thank works! Thank you so much! |
It looks like the menu still saves space for the menu/kind even when Update - I can achieve what I want by setting kind and menu to empty string: format = function(_, vim_item)
vim_item.menu = ""
vim_item.kind = ""
return vim_item
end |
Wish he had built in |
@hrsh7th Can we please have a |
As was mentioned in #1535, It might be possible to set the minimum width and maximum height by options |
this is working for me, I only use |
Should probably add some media queries and/or toggles, but it's a start Relevant issue: hrsh7th/nvim-cmp#980
Restrict the width of the completion window by omitting the `menu` item from the `fields` table of the `formatting`. Additionally we have overridden the `format` function of the `formatting` section [1,2]. [1] hrsh7th/nvim-cmp#980 (comment) [2] hrsh7th/nvim-cmp#890
Restrict the width of the completion window by omitting the `menu` item from the `fields` table of the `formatting`. Clear the `menu` string in the `format` function of the `formatting` section [1,2]. [1] hrsh7th/nvim-cmp#980 (comment) [2] hrsh7th/nvim-cmp#890
Restrict the width of the completion window by omitting the `menu` item from the `fields` table of the `formatting`. Clear the `menu` string in the `format` function of the `formatting` section [1,2]. [1] hrsh7th/nvim-cmp#980 (comment) [2] hrsh7th/nvim-cmp#890
1. restrict max width of the completion menu. Here I am using lspkind.nvim to achieve this. There are other native ways to do this, see also hrsh7th/nvim-cmp#609 and hrsh7th/nvim-cmp#980 2. remove cmp-emoji as it is rarely used and interfere when I write Python 3. lower the transparency for popup menu
1. restrict max width of the completion menu. Here I am using lspkind.nvim to achieve this. There are other native ways to do this, see also hrsh7th/nvim-cmp#609 and hrsh7th/nvim-cmp#980 2. remove cmp-emoji as it is rarely used and interfere when I write Python 3. lower the transparency for popup menu
FAQ
Issues
Neovim Version
0.7
Minimal reproducible full config
cmp.nvim
's autocompletion pop-up menu changes width to accommodate the completion candidates.While, there are a few options to set the max_width, I don't see any solution to fix the pop-up menu at a certain width.
Can we have an option in
cmp
to set the pop-up menu to a fixed width?Description
It is rather annoying when the completion menu's width keeps on changing to be bigger and smaller, leading to a very jarring user experience.
Steps to reproduce
Default config of
cmp
.Expected behavior
Fix the pop-up window width irrespective of the length of the completion candidates.
Actual behavior
The completion menu's width keeps on changing to be bigger and smaller dynamically, depending on the width of the populated candidates.
Additional context
The constantly changing pop-up menu width is rather annoying and leads to a jarring user experience.
The text was updated successfully, but these errors were encountered: