-
Hey, I have noticed that if I omit a field from custom formatted window it gets way wider than it needs to be. For example, this is default with So far so good. Let's add some kind icons (from wiki): formatting = {
fields = { cmp.ItemField.Abbr, cmp.ItemField.Kind },
format = function(_, vim_item)
vim_item.kind = cmp_kinds[vim_item.kind] or ' '
return vim_item
end,
}, and we get: Still OK. Let's replace kind with source name coming from formatting = {
fields = { cmp.ItemField.Abbr, cmp.ItemField.Menu },
format = function(entry, vim_item)
vim_item.menu = ' '
.. (({ nvim_lsp = 'lsp', cmp_git = 'git' })[entry.source.name] or entry.source.name)
.. ': '
.. vim_item.kind
return vim_item
end,
}, Not so good, window expands further than it really needs to. I was thinking that formatting = {
fields = { cmp.ItemField.Kind, cmp.ItemField.Abbr, cmp.ItemField.Menu },
format = function(entry, vim_item)
vim_item.menu = ' '
.. (({ nvim_lsp = 'lsp', cmp_git = 'git' })[entry.source.name] or entry.source.name)
.. ': '
.. vim_item.kind
vim_item.kind = cmp_kinds[vim_item.kind] or ' '
return vim_item
end,
},
and everything is back to how it should be: Why is abbr+kind displayed like that? @hrsh7th is that a bug or am I doing something utterly bananas here? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
This is a feature. Change items order will change the display order. See #337 Update: |
Beta Was this translation helpful? Give feedback.
-
formatting = {
fields = { cmp.ItemField.Abbr, cmp.ItemField.Menu },
format = function(entry, vim_item)
vim_item.menu = ' '
.. (({ nvim_lsp = 'lsp', cmp_git = 'git' })[entry.source.name] or entry.source.name)
.. ': '
.. vim_item.kind
return vim_item
end,
}, For this code to work as expected, the formatting = {
fields = { cmp.ItemField.Abbr, cmp.ItemField.Menu },
format = function(entry, vim_item)
vim_item.menu = ' '
.. (({ nvim_lsp = 'lsp', cmp_git = 'git' })[entry.source.name] or entry.source.name)
.. ': '
.. vim_item.kind
+ vim_item.kind = nil
return vim_item
end,
}, |
Beta Was this translation helpful? Give feedback.
For this code to work as expected, the
vim_item.kind
need to set tonil
formatting = { fields = { cmp.ItemField.Abbr, cmp.ItemField.Menu }, format = function(entry, vim_item) vim_item.menu = ' ' .. (({ nvim_lsp = 'lsp', cmp_git = 'git' })[entry.source.name] or entry.source.name) .. ': ' .. vim_item.kind + vim_item.kind = nil return vim…