Closed Sologala closed 5 months ago
@Sologala that is called a kind items, not a sources. You can customize the kind items name with text or icon in formatting
options like these example:
local kind_items = {
Text = "Text",
Method = "Method",
Function = "Func",
Constructor = "Constructor",
Field = "Field",
Variable = "Var",
Class = "Class",
Interface = "Interface",
Module = "Module",
Property = "Prop",
Unit = "Unit",
Value = "Val",
Enum = "Enum",
Keyword = "Keyword",
Snippet = "Snippet",
Color = "Color",
File = "File",
Reference = "Ref",
Folder = "Folder",
EnumMember = "EnumMember",
Constant = "Const",
Struct = "Struct",
Event = "Event",
Operator = "Operator",
TypeParameter = "TypeParameter"
}
require("cmp").setup({
formatting = {
format = function (entry, vim_item)
-- Kind items
vim_item.kind = string.format("%s", kind_items[vim_item.kind])
-- Source
vim_item.menu = ({
nvim_lsp = "[LSP]",
luasnip = "[LuaSnip]",
buffer = "[Buffer]"
})[entry.source.name]
return vim_item
end
}
})
Take a look the detail in Menu Appearance wiki.
And I think what source_names
option you provide it should be sources
for the completion item like these example I have completion for LSP, LuaSnip, and buffer:
sources = {
{ name = "nvim_lsp" },
{ name = "luasnip", option = { show_autosnippets = true } },
{ name = "buffer" }
}
For all list of sources name, look in List of sources wiki.
THX, I got it work like i wish by your instrcutions.
I wang to alias Property source type to Prop. Where I should config to achive it.
Things already tried: I found the following configuration in other's dotfile. But
source_names
segments not work.