You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
57 lines
1.1 KiB
Lua
57 lines
1.1 KiB
Lua
3 years ago
|
-- TODO: Improve docs
|
||
|
-- Setup nvim-cmp.
|
||
|
local cmp = require'cmp'
|
||
|
|
||
|
-- Ensure vsnip is installed
|
||
|
require'cmp_vsnip'
|
||
|
|
||
|
cmp.setup({
|
||
|
snippet = {
|
||
|
expand = function(args)
|
||
|
vim.fn["vsnip#anonymous"](args.body)
|
||
|
end,
|
||
|
},
|
||
|
mapping = {
|
||
|
['<C-Space>'] = cmp.mapping(cmp.mapping.complete(), { 'i', 'c' }),
|
||
|
['<CR>'] = cmp.mapping.confirm({ select = true }),
|
||
|
['<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,
|
||
|
},
|
||
|
sources = cmp.config.sources({
|
||
|
{ name = 'nvim_lsp' },
|
||
|
{ name = 'vsnip' },
|
||
|
}, {
|
||
|
{ 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' }
|
||
|
})
|
||
|
})
|
||
|
|
||
|
return { cmp = cmp }
|