add lspkind-nvim

This commit is contained in:
Charlotte 🦝 Delenk 2023-04-13 20:00:05 +01:00
parent c43ba12712
commit c287bc427e
Signed by: darkkirb
GPG key ID: AB2BD8DAF2E37122
2 changed files with 60 additions and 1 deletions

View file

@ -13,6 +13,7 @@
cmp_luasnip
cmp-git
cmp-omni
lspkind-nvim
]
++ (
if config.isDesktop

View file

@ -2,6 +2,8 @@
local cmp = require'cmp'
local compare = require('cmp.config.compare')
local lspkind = require('lspkind')
cmp.setup({
snippet = {
-- REQUIRED - you must specify a snippet engine
@ -28,7 +30,7 @@ cmp.setup({
{ name = 'buffer' },
}),
{
sorting = {
priority_weight = 2,
comparators = {
require('cmp_tabnine.compare'),
@ -42,6 +44,62 @@ cmp.setup({
compare.order,
},
},
formatting = {
format = function(entry, vim_item)
lspkind_format = lspkind.cmp_format({
mode = 'symbol_text', -- show only symbol annotations
maxwidth = 80, -- prevent the popup from showing more than provided characters (e.g 50 will not show more than 50 characters)
ellipsis_char = '...', -- when popup menu exceed maxwidth, the truncated part would show ellipsis_char instead (must define maxwidth first)
symbol_map = {
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 = ""
},
-- The function below will be called before any actual modifications from lspkind
-- so that you can provide more controls on popup customization. (See [#30](https://github.com/onsails/lspkind-nvim/pull/30))
before = function (entry, vim_item)
return vim_item
end
})
vim_item = lspkind_format(entry, vim_item)
if entry.source.name == "cmp_tabnine" then
vim_item.kind = ""
if detail and detail:find('.*%%.*') then
vim_item.kind = vim_item.kind .. ' ' .. detail
end
if (entry.completion_item.data or {}).multiline then
vim_item.kind = vim_item.kind .. ' ' .. '[ML]'
end
end
return vim_item
end
}
})
-- Set configuration for specific filetype.