nvimrc: improve nvim-cmp configuration

This commit is contained in:
Rob Watson 2021-10-27 09:35:24 +02:00
parent 8be560abe1
commit 3ed67b0aac
1 changed files with 37 additions and 28 deletions

65
nvimrc
View File

@ -596,6 +596,41 @@ require 'nvim-treesitter.configs'.setup {
}
EOF
" nvim-cmp:
packadd! nvim-cmp " https://github.com/hrsh7th/nvim-cmp.git
packadd! vim-vsnip " https://github.com/hrsh7th/vim-vsnip.git
packadd! cmp-vsnip " https://github.com/hrsh7th/cmp-vsnip.git
packadd! cmp-nvim-lsp " https://github.com/hrsh7th/cmp-nvim-lsp.git
packadd! cmp-buffer " https://github.com/hrsh7th/cmp-buffer.git
packadd! cmp-path " https://github.com/hrsh7th/cmp-path.git
packadd! cmp-calc " https://github.com/hrsh7th/cmp-calc
lua <<EOF
local cmp = require('cmp')
cmp.setup({
snippet = {
expand = function(args)
vim.fn["vsnip#anonymous"](args.body)
end,
},
mapping = {
['<C-u>'] = cmp.mapping.scroll_docs(-4),
['<C-d>'] = cmp.mapping.scroll_docs(4),
['<C-Space>'] = cmp.mapping.complete(),
['<C-e>'] = cmp.mapping.close(),
['<CR>'] = cmp.mapping.confirm({ select = true, behaviour = cmp.ConfirmBehavior.Replace }),
},
sources = cmp.config.sources({
{ name = 'nvim_lsp' },
{ name = 'buffer' },
{ name = 'path' },
{ name = 'calc' },
})
})
EOF
" LSP
packadd! nvim-lspconfig " https://github.com/neovim/nvim-lspconfig.git
@ -654,6 +689,8 @@ capabilities.textDocument.completion.completionItem.resolveSupport = {
}
}
require('cmp_nvim_lsp').update_capabilities(capabilities)
nvim_lsp.gopls.setup{
settings = {
gopls = {
@ -767,31 +804,3 @@ nvim_lsp.sumneko_lua.setup {
on_attach = on_attach,
}
EOF
" nvim-cmp:
packadd! nvim-cmp " https://github.com/hrsh7th/nvim-cmp.git
packadd! cmp-nvim-lsp " https://github.com/hrsh7th/cmp-nvim-lsp.git
packadd! cmp-buffer " https://github.com/hrsh7th/cmp-buffer.git
packadd! cmp-path " https://github.com/hrsh7th/cmp-path.git
packadd! cmp-calc " https://github.com/hrsh7th/cmp-calc
lua <<EOF
local cmp = require('cmp')
cmp.setup({
mapping = {
['<C-u>'] = cmp.mapping.scroll_docs(-4),
['<C-d>'] = cmp.mapping.scroll_docs(4),
['<C-Space>'] = cmp.mapping.complete(),
['<C-e>'] = cmp.mapping.close(),
['<CR>'] = cmp.mapping.confirm({ select = true }),
},
sources = cmp.config.sources({
{ name = 'nvim_lsp' },
{ name = 'buffer' },
{ name = 'path' },
{ name = 'calc' },
})
})
EOF