added luasnip as cmp snippet engine

This commit is contained in:
Sven Vogel 2024-04-13 10:26:19 +02:00
parent 4258701c98
commit 6c68f8d6c7
1 changed files with 11 additions and 6 deletions

View File

@ -11,8 +11,8 @@ return {
'hrsh7th/cmp-emoji', 'hrsh7th/cmp-emoji',
'kdheepak/cmp-latex-symbols', 'kdheepak/cmp-latex-symbols',
-- snippets -- snippets
'hrsh7th/cmp-vsnip', 'saadparwaiz1/cmp_luasnip',
'hrsh7th/vim-vsnip', 'L3MON4D3/LuaSnip',
'onsails/lspkind.nvim' 'onsails/lspkind.nvim'
}, },
config = function(_, _) config = function(_, _)
@ -32,12 +32,12 @@ return {
}, },
snippet = { snippet = {
expand = function(args) expand = function(args)
vim.fn["vsnip#anonymous"](args.body) require('luasnip').lsp_expand(args.body)
end, end,
}, },
completion = { completion = {
preselect = 'none', preselect = 'none',
completeopt = "menu,menuone,noinser,noselectt", completeopt = "menu,menuone,noinser",
}, },
sources = cmp.config.sources({ sources = cmp.config.sources({
{ name = 'nvim_lsp' }, { name = 'nvim_lsp' },
@ -69,9 +69,14 @@ return {
}), }),
}), }),
formatting = { formatting = {
fields = { "abbr", "kind", "menu" }, fields = { "kind", "abbr", "menu" },
format = function(entry, item) format = function(entry, item)
return require("lspkind").cmp_format()(entry, item) local kind = require("lspkind").cmp_format({ mode = "symbol_text", maxwidth = 50 })(entry, item)
local strings = vim.split(kind.kind, "%s", { trimempty = true })
kind.kind = (strings[1] or "") .. " "
kind.menu = " (" .. (strings[2] or "") .. ")"
return kind
end end
}, },
experimental = { experimental = {