1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
local cmp = require'cmp'
local lspkind = require 'lspkind'
local luasnip = require 'luasnip'
lspkind.init()
cmp.setup({
snippet = {
expand = function(args)
require('luasnip').lsp_expand(args.body)
end,
},
mapping = {
['<C-Space>'] = cmp.mapping.complete(),
['<C-e>'] = cmp.mapping.close(),
['<CR>'] = cmp.mapping.confirm({
behavior = cmp.ConfirmBehavior.Insert,
select = true,
}),
},
sources = {
{ name = 'nvim_lsp' },
{ name = 'nvim_lua' },
{ name = 'path' },
{ name = 'luasnip' },
{ name = 'buffer', keyword_length = 5 },
},
formatting = {
format = lspkind.cmp_format {
with_text = true,
menu = {
buffer = '[buf]',
nvim_lsp = '[LSP]',
nvim_lua = '[api]',
luasnip = '[snip]',
},
},
},
experimental = {
ghost_text = true,
}
})
|