47 lines
1.5 KiB
Lua
47 lines
1.5 KiB
Lua
|
local cmp = require'cmp'
|
||
|
|
||
|
cmp.setup({
|
||
|
snippet = {
|
||
|
-- REQUIRED - you must specify a snippet engine
|
||
|
expand = function(args)
|
||
|
require('luasnip').lsp_expand(args.body) -- For `luasnip` users.
|
||
|
end,
|
||
|
},
|
||
|
mapping = {
|
||
|
['<tab>'] = cmp.mapping.select_next_item({ behavior = cmp.SelectBehavior.Insert }),
|
||
|
['<C-p>'] = cmp.mapping.select_prev_item({ behavior = cmp.SelectBehavior.Insert }),
|
||
|
['<Down>'] = cmp.mapping.select_next_item({ behavior = cmp.SelectBehavior.Select }),
|
||
|
['<Up>'] = cmp.mapping.select_prev_item({ behavior = cmp.SelectBehavior.Select }),
|
||
|
['<C-d>'] = cmp.mapping.scroll_docs(-4),
|
||
|
['<C-f>'] = cmp.mapping.scroll_docs(4),
|
||
|
['<C-Space>'] = cmp.mapping.complete(),
|
||
|
['<C-e>'] = cmp.mapping.close(),
|
||
|
['<CR>'] = cmp.mapping.confirm({
|
||
|
behavior = cmp.ConfirmBehavior.Replace,
|
||
|
select = true,
|
||
|
})
|
||
|
},
|
||
|
sources = cmp.config.sources({
|
||
|
{ name = 'nvim_lsp' },
|
||
|
{ name = 'luasnip' }, -- For luasnip users.
|
||
|
}, {
|
||
|
{ name = 'buffer' },
|
||
|
})
|
||
|
})
|
||
|
|
||
|
-- Use buffer source for `/` (if you enabled `native_menu`, this won't work anymore).
|
||
|
cmp.setup.cmdline('/', {
|
||
|
sources = {
|
||
|
{ name = 'buffer' }
|
||
|
}
|
||
|
})
|
||
|
|
||
|
-- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore).
|
||
|
cmp.setup.cmdline(':', {
|
||
|
sources = cmp.config.sources({
|
||
|
{ name = 'path' }
|
||
|
}, {
|
||
|
{ name = 'cmdline' }
|
||
|
})
|
||
|
})
|