Add luasnip instead of vsnip
This commit is contained in:
@ -22,11 +22,12 @@ vim.g.windowswap_map_keys=0
|
||||
|
||||
local cmp = require('cmp')
|
||||
local lspkind = require('lspkind')
|
||||
local ls = require('luasnip')
|
||||
|
||||
cmp.setup({
|
||||
snippet = {
|
||||
expand = function(args)
|
||||
vim.fn["vsnip#anonymous"](args.body) -- For `vsnip` users.
|
||||
ls.lsp_expand(args.body)
|
||||
end,
|
||||
},
|
||||
|
||||
@ -35,13 +36,46 @@ cmp.setup({
|
||||
documentation = cmp.config.window.bordered(),
|
||||
},
|
||||
|
||||
mapping = cmp.mapping.preset.insert({
|
||||
-- mapping = cmp.mapping.preset.insert({
|
||||
-- -- ['<Tab>'] = cmp.mapping.confirm({ select = false }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items.
|
||||
-- }),
|
||||
mapping = {
|
||||
['<C-b>'] = cmp.mapping.scroll_docs(-4),
|
||||
['<C-f>'] = cmp.mapping.scroll_docs(4),
|
||||
['<C-Space>'] = cmp.mapping.complete(),
|
||||
['<C-e>'] = cmp.mapping.abort(),
|
||||
['<Tab>'] = cmp.mapping.confirm({ select = false }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items.
|
||||
}),
|
||||
['<CR>'] = cmp.mapping(function(fallback)
|
||||
if cmp.visible() then
|
||||
if ls.expandable() then
|
||||
ls.expand()
|
||||
else
|
||||
cmp.confirm({
|
||||
select = true,
|
||||
})
|
||||
end
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end),
|
||||
["<Tab>"] = cmp.mapping(function(fallback)
|
||||
if cmp.visible() then
|
||||
cmp.select_next_item()
|
||||
elseif ls.locally_jumpable(1) then
|
||||
ls.jump(1)
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end, { "i", "s" }),
|
||||
["<S-Tab>"] = cmp.mapping(function(fallback)
|
||||
if cmp.visible() then
|
||||
cmp.select_prev_item()
|
||||
elseif ls.locally_jumpable(-1) then
|
||||
ls.jump(-1)
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end, { "i", "s" }),
|
||||
},
|
||||
|
||||
sources = cmp.config.sources({
|
||||
{ name = 'nvim_lsp', priority = 1000 },
|
||||
@ -50,7 +84,7 @@ cmp.setup({
|
||||
{ name = 'path', priority = 600 },
|
||||
{ name = 'cmp_yanky', priority = 500 },
|
||||
{ name = 'git', priority = 400 },
|
||||
{ name = 'vsnip', priority = 300 },
|
||||
{ name = 'luasnip', priority = 300 },
|
||||
{ name = 'nvim_lua', priority = 200 },
|
||||
}),
|
||||
|
||||
|
||||
Reference in New Issue
Block a user