dotfiles/config/nvim/lua/autocomplete.lua

52 lines
1.2 KiB
Lua

-- Autocompletion shenanigans
local cmp = require'cmp'
cmp.setup({
snippet = {
expand = function(args)
vim.fn["vsnip#anonymous"](args.body)
end,
},
window = {
completion = cmp.config.window.bordered(),
documentation = cmp.config.window.bordered(),
},
mapping = cmp.mapping.preset.insert({
['<C-b>'] = cmp.mapping.scroll_docs(-4),
['<C-f>'] = cmp.mapping.scroll_docs(4),
['<C-Space>'] = cmp.mapping.complete(),
['<C-e>'] = cmp.mapping.abort(),
['<CR>'] = cmp.mapping.confirm({ select = true }),
}),
sources = cmp.config.sources({
{ name = 'nvim_lsp' },
{ name = 'vsnip' },
{ name = 'buffer' },
})
})
-- filetype specific setup
-- gitconfig
cmp.setup.filetype('gitcommit', {
sources = cmp.config.sources({
{ name = 'git' },
{ name = 'buffer' },
})
})
-- / andd ? completion
cmp.setup.cmdline({'/', '?'}, {
mapping = cmp.mapping.preset.cmdline(),
sources = { { name = 'buffer' } },
})
-- : completion
cmp.setup.cmdline(':', {
mapping = cmp.mapping.preset.cmdline(),
sources = {
{ name = 'path' },
{ name = 'cmdline' },
},
matching = { disallow_symbol_nonprefix_matching = false },
})