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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
|
return {
{
'onsails/lspkind.nvim',
config = function()
require('lspkind').setup({
mode = 'symbol_text',
preset = 'codicons',
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 = "",
},
})
end
},
{
"hrsh7th/nvim-cmp",
dependencies = {
"onsails/lspkind.nvim",
"hrsh7th/cmp-nvim-lsp",
"hrsh7th/cmp-buffer",
"hrsh7th/cmp-path",
"L3MON4D3/LuaSnip",
},
event = "InsertEnter",
config = function()
local cmp = require('cmp')
local lspkind = require('lspkind')
cmp.setup({
snippet = {
expand = function(args)
require('luasnip').lsp_expand(args.body)
end,
},
formatting = {
format = lspkind.cmp_format({
mode = 'symbol_text',
maxwidth = {
menu = 50,
abbr = 50,
},
ellipsis_char = '...',
show_labelDetails = true,
before = function(entry, vim_item)
-- Add source name to menu
vim_item.menu = ({
nvim_lsp = "[LSP]",
luasnip = "[LuaSnip]",
buffer = "[Buffer]",
path = "[Path]",
})[entry.source.name]
return vim_item
end
})
},
mapping = cmp.mapping.preset.insert({
['<C-j>'] = cmp.mapping.select_next_item(cmp_select),
['<C-k>'] = cmp.mapping.select_prev_item(cmp_select),
['<C-b>'] = cmp.mapping.scroll_docs(-4),
['<C-f>'] = cmp.mapping.scroll_docs(4),
['<C-Space>'] = cmp.mapping.complete(),
['<C-e>'] = cmp.mapping.abort(),
['<CR>'] = cmp.mapping.confirm({ select = true }),
}),
sources = cmp.config.sources({
{ name = 'nvim_lsp' },
{ name = 'luasnip' },
}, {
{ name = 'buffer' },
{ name = 'path' },
}),
window = {
completion = cmp.config.window.bordered(),
documentation = cmp.config.window.bordered(),
},
})
end,
},
}
|