Formatting provides additional details in cmp recommendations.
Completion Without Formatting
Completion With Formatting
Setup requires setting the formatting variable in the config() function for nvim-cmp.
-- nvim-cmp.lua
{
"hrsh7th/nvim-cmp",
config = function()
formatting = {
format = function(entry, vim_item)
if entry.source.name = "cmp_rolodex" then
vim_item.kind = "📇 Contact"
vim_item.menu = "[RLDX]"
end
return vim_item
end
}
end
}You may already have formatting configured. Possibly like…
return {
"hrsh7th/nvim-cmp",
config = function()
formatting = {
format = lspkind.cmp_format({
maxwidth = 50,
ellipsis_char = "...",
}),
}
end
}In such a case, you can merge your formatting with the RLDX formatting.
return {
"hrsh7th/nvim-cmp",
config = function()
formatting = {
format = function(entry, vim_item)
-- Existing configuration
local format_func = lspkind.cmp_format({
maxwidth = 50,
ellipsis_char = "...",
})
vim_item = format_func(entry, vim_item)
-- RLDX configuration
if entry.source.name == "cmp_rolodex" then
vim_item.kind = "📇 Contact"
vim_item.menu = "[RLDX]"
end
return vim_item
end
}
end
}
