Set a limit to how wide the completion menu can be

This commit is contained in:
Kenneth Benzie 2024-04-20 12:37:15 +01:00
parent 63d2a3ffd3
commit 09c785eee9

View File

@ -139,6 +139,20 @@ return {
{ name = 'git' }, { name = 'git' },
}, },
formatting = {
format = function(entry, vim_item)
-- Set a limit to how wide the completion menu can be
local winwidth = vim.fn.winwidth(vim.api.nvim_get_current_win())
local menuwidth = math.min(winwidth / 2, 70)
if menuwidth < 70 then
vim_item.menu = ''
vim_item.kind = ''
end
vim_item.abbr = string.sub(vim_item.abbr, 1, menuwidth)
return vim_item
end
},
window = { window = {
completion = cmp.config.window.bordered(), completion = cmp.config.window.bordered(),
documentation = cmp.config.window.bordered(), documentation = cmp.config.window.bordered(),