This commit is contained in:
Lee Tang
2022-03-12 08:41:28 +08:00
commit 6fa77b0a86
37 changed files with 1944 additions and 0 deletions

View File

@@ -0,0 +1,42 @@
local fn = vim.fn
-- nvim-cmp
local cmp = require('cmp')
cmp.setup({
snippet = {
expand = function(args)
fn['vsnip#anonymous'](args.body)
end,
},
formatting = {
format = function(entry, vim_item)
-- set a name for each source
vim_item.menu = ({
buffer = '[Buf]',
nvim_lsp = '[LSP]',
luasnip = '[Snip]',
nvim_lua = '[Lua]',
latex_symbols = '[Latex]',
})[entry.source.name]
return vim_item
end,
},
mapping = {
['<C-y>'] = cmp.mapping.confirm({ select = true }),
['<C-d>'] = cmp.mapping.scroll_docs(-4),
['<C-f>'] = cmp.mapping.scroll_docs(4),
['<C-Space>'] = cmp.mapping.complete(),
--["<C-e>"] = cmp.mapping.close(),
['<C-e>'] = function(fallback)
fallback()
end,
['<CR>'] = cmp.mapping.confirm({
behavior = cmp.ConfirmBehavior.Replace,
select = true,
}),
},
sources = {
{ name = 'nvim_lsp' },
{ name = 'buffer' },
},
})