nvimrc: improve nvim-cmp configuration
This commit is contained in:
parent
8be560abe1
commit
3ed67b0aac
65
nvimrc
65
nvimrc
|
@ -596,6 +596,41 @@ require 'nvim-treesitter.configs'.setup {
|
||||||
}
|
}
|
||||||
EOF
|
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
|
" LSP
|
||||||
|
|
||||||
packadd! nvim-lspconfig " https://github.com/neovim/nvim-lspconfig.git
|
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{
|
nvim_lsp.gopls.setup{
|
||||||
settings = {
|
settings = {
|
||||||
gopls = {
|
gopls = {
|
||||||
|
@ -767,31 +804,3 @@ nvim_lsp.sumneko_lua.setup {
|
||||||
on_attach = on_attach,
|
on_attach = on_attach,
|
||||||
}
|
}
|
||||||
EOF
|
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
|
|
||||||
|
|
Loading…
Reference in New Issue