Add custom icons for suggestions in cmp

This commit is contained in:
2021-11-16 16:21:01 +03:00
parent af4459e8e1
commit 518e706c3f

View File

@@ -1,6 +1,33 @@
local lsp_installer = require("nvim-lsp-installer")
local cmp = require("cmp")
local lspkind = require("lspkind")
local kind_icons = {
Text = "",
Method = "",
Function = "",
Constructor = "",
Field = "",
Variable = "",
Class = "",
Interface = "",
Module = "",
Property = "",
Unit = "",
Value = "",
Enum = "",
Keyword = "",
Snippet = "",
Color = "",
File = "",
Reference = "",
Folder = "",
EnumMember = "",
Constant = "",
Struct = "",
Event = "",
Operator = "",
TypeParameter = ""
}
cmp.setup({
snippet = {
@@ -29,14 +56,17 @@ cmp.setup({
completeopt = "menu,menuone,noselect,noinsert"
},
formatting = {
format = lspkind.cmp_format({
with_text = true,
menu = {
buffer = "[buf]",
format = function(entry, vim_item)
vim_item.kind = string.format('%s %s', kind_icons[vim_item.kind], vim_item.kind)
vim_item.menu = ({
buffer = "[Buffer]",
nvim_lsp = "[LSP]",
path = "[path]"
}
})
luasnip = "[Snippet]",
nvim_lua = "[Lua]",
path = "[File]"
})[entry.source.name]
return vim_item
end
},
experimental = {
ghost_text = true