cmp cmdline and group_index wont work #881
-
According to docs using cmp.setup.cmdline(":", {
formatting = {
format = function(entry, vim_item)
vim_item.kind = lspkind.presets.default[vim_item.kind] .. " " .. vim_item.kind
vim_item.abbr = vim.fn.strcharpart(vim_item.abbr, 0, 50) -- hack to clamp cmp-cmdline-history len
vim_item.menu = ({
cmdline_history = "[HIST]",
cmdline = "[CMD]",
fuzzy_path = "[PATH]",
buffer = "[BUFF]",
})[entry.source.name]
return vim_item
end,
},
sources = cmp.config.sources {
{ name = "cmdline_history", priority = 2, group_index=2 },
{ name = "cmdline", priority = 2, group_index=1 },
{ name = "fuzzy_path", priority = 1, group_index=2 }, -- from tzacher
{ name = "buffer", priority = 1, group_index=2 },
},
}) Any ideas why? I tried to setup it as: |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
the reason is in that you're using |
Beta Was this translation helpful? Give feedback.
-
Just for reference this will work ok wit group_index: sources = {
{ name = "cmdline", priority = 2, group_index = 1 },
{ name = "cmdline_history", priority = 1, group_index = 1, max_item_count = 3 },
{ name = "path", priority = 1, group_index = 2 }, -- from tzacher
-- { name = "buffer", priority = 1, group_index = 1 },
}, |
Beta Was this translation helpful? Give feedback.
the reason is in that you're using
cmp.config.sources {}
instead of just table ({}
) as value of completion source.If you'll go to the definition of this function, you'll see, it inserts
group_index = 1
) to every table inside ;)