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
|
return {
{
"L3MON4D3/LuaSnip",
version = "v2.*",
},
{
"hrsh7th/nvim-cmp",
dependencies = {
"hrsh7th/cmp-buffer",
"hrsh7th/cmp-nvim-lsp",
"hrsh7th/cmp-path",
"L3MON4D3/LuaSnip",
},
opts = function()
local cmp = require("cmp")
return {
snippet = {
expand = function(args)
require("luasnip").lsp_expand(args.body)
end,
},
mapping = cmp.mapping.preset.insert({
["<C-h>"] = cmp.mapping.scroll_docs(-4),
["<C-l>"] = cmp.mapping.scroll_docs(4),
["<C-j>"] = cmp.mapping.select_next_item({ behavior = cmp.SelectBehavior.Insert }),
["<C-k>"] = cmp.mapping.select_prev_item({ behavior = cmp.SelectBehavior.Insert }),
["<C-Space>"] = cmp.mapping(function(fallback)
-- Confirm with C-Space. If none selected, confirm first.
if cmp.visible() then
local entry = cmp.get_selected_entry()
if not entry then
cmp.select_next_item({ behaviour = cmp.SelectBehavior.Select })
end
cmp.confirm()
else
fallback()
end
end, { "i", "s", "c" }),
}),
sources = cmp.config.sources({
{ name = "nvim_lsp" },
{ name = "path" },
{ name = "buffer" },
}),
}
end,
},
}
|