1
0
mirror of https://github.com/jdhao/nvim-config.git synced 2025-06-08 14:14:33 +02:00
2021-10-19 01:14:09 +08:00

45 lines
1021 B
Lua

-- Setup nvim-cmp.
local cmp = require'cmp'
cmp.setup({
snippet = {
expand = function(args)
-- For `ultisnips` user.
vim.fn["UltiSnips#Anon"](args.body)
end,
},
mapping = {
['<Tab>'] = function(fallback)
if cmp.visible() then
cmp.select_next_item()
else
fallback()
end
end,
['<S-Tab>'] = function(fallback)
if cmp.visible() then
cmp.select_prev_item()
else
fallback()
end
end,
['<Esc>'] = cmp.mapping.close(),
['<CR>'] = cmp.mapping.confirm({ select = true }),
['<C-d>'] = cmp.mapping.scroll_docs(-4),
['<C-f>'] = cmp.mapping.scroll_docs(4),
},
sources = {
{ name = 'nvim_lsp' }, -- For nvim-lsp
{ name = 'ultisnips' }, -- For ultisnips user.
{ name = 'path' }, -- for path completion
{ name = 'emoji', insert = true, } -- emoji completion
},
completion = {
keyword_length = 1,
completeopt = "menu,noselect"
},
experimental = {
ghost_text = false
}
})