neovim: switch to nvim-cmp
This commit is contained in:
parent
a191b6758d
commit
21180efd69
4 changed files with 80 additions and 40 deletions
66
nvim/lua/autocompletion.lua
Normal file
66
nvim/lua/autocompletion.lua
Normal file
|
@ -0,0 +1,66 @@
|
|||
-- Setup nvim-cmp.
|
||||
local cmp = require'cmp'
|
||||
|
||||
cmp.setup({
|
||||
snippet = {
|
||||
expand = function(args)
|
||||
vim.fn["UltiSnips#Anon"](args.body) -- For `ultisnips` users.
|
||||
end,
|
||||
},
|
||||
mapping = {
|
||||
['<C-b>'] = cmp.mapping(cmp.mapping.scroll_docs(-4), { 'i', 'c' }),
|
||||
['<C-f>'] = cmp.mapping(cmp.mapping.scroll_docs(4), { 'i', 'c' }),
|
||||
['<C-p>'] = cmp.mapping(cmp.mapping.complete(), { 'i', 'c' }),
|
||||
['<C-y>'] = cmp.config.disable, -- Specify `cmp.config.disable` if you want to remove the default `<C-y>` mapping.
|
||||
['<C-e>'] = cmp.mapping({
|
||||
i = cmp.mapping.abort(),
|
||||
c = cmp.mapping.close(),
|
||||
}),
|
||||
-- Accept currently selected item. If none selected, `select` first item.
|
||||
-- Set `select` to `false` to only confirm explicitly selected items.
|
||||
['<CR>'] = cmp.mapping.confirm({ select = true }),
|
||||
},
|
||||
sources = cmp.config.sources({
|
||||
{ name = 'nvim_lsp' },
|
||||
}, {
|
||||
{ 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' }
|
||||
})
|
||||
})
|
||||
|
||||
-- Setup lspconfig.
|
||||
local capabilities = require('cmp_nvim_lsp').update_capabilities(vim.lsp.protocol.make_client_capabilities())
|
||||
|
||||
lspconfig = require "lspconfig"
|
||||
lspconfig.tsserver.setup{ capabilities = capabilities }
|
||||
lspconfig.intelephense.setup{ capabilities = capabilities }
|
||||
lspconfig.vuels.setup{ capabilities = capabilities }
|
||||
lspconfig.pylsp.setup{ capabilities = capabilities}
|
||||
lspconfig.texlab.setup{ capabilities = capabilities }
|
||||
lspconfig.gopls.setup {
|
||||
cmd = {"gopls", "serve"},
|
||||
settings = {
|
||||
gopls = {
|
||||
analyses = {
|
||||
unusedparams = true,
|
||||
},
|
||||
staticcheck = true,
|
||||
},
|
||||
},
|
||||
capabilities = capabilities
|
||||
}
|
|
@ -44,13 +44,10 @@ nnoremap <silent> <leader>w :Goyo<CR>
|
|||
nnoremap <silent> <leader>se :set spell spelllang=en<CR>
|
||||
nnoremap <silent> <leader>sd :set spell spelllang=de<CR>
|
||||
|
||||
" lsp mappings
|
||||
imap <silent> <c-p> <Plug>(completion_trigger)
|
||||
|
||||
nnoremap <silent> gd <cmd>lua vim.lsp.buf.definition()<CR>
|
||||
" nnoremap <silent> gd <cmd>lua vim.lsp.buf.definition()<CR>
|
||||
nnoremap <silent> gh <cmd>lua vim.lsp.buf.hover()<CR>
|
||||
nnoremap <silent> gH <cmd>lua vim.lsp.buf.code_action()<CR>
|
||||
nnoremap <silent> gD <cmd>lua vim.lsp.buf.implementation()<CR>
|
||||
" nnoremap <silent> gH <cmd>lua vim.lsp.buf.code_action()<CR>
|
||||
" nnoremap <silent> gD <cmd>lua vim.lsp.buf.implementation()<CR>
|
||||
nnoremap <silent> gs <cmd>lua vim.lsp.buf.signature_help()<CR>
|
||||
nnoremap <silent> gr <cmd>lua vim.lsp.buf.references()<CR>
|
||||
" nnoremap <silent> gr <cmd>lua vim.lsp.buf.references()<CR>
|
||||
nnoremap <silent> gR <cmd>lua vim.lsp.buf.rename()<CR>
|
||||
|
|
|
@ -88,13 +88,11 @@ let g:tmuxcomplete#trigger = ''
|
|||
|
||||
function! s:goyo_enter()
|
||||
set noshowcmd
|
||||
set noshowmode
|
||||
set scrolloff=999
|
||||
endfunction
|
||||
|
||||
function! s:goyo_leave()
|
||||
set showcmd
|
||||
set showmode
|
||||
set scrolloff=1
|
||||
endfunction
|
||||
|
||||
|
@ -105,38 +103,10 @@ let g:goyo_width = 120
|
|||
|
||||
" AUTOCOMPLETION
|
||||
" =========================
|
||||
lua require'lspconfig'.tsserver.setup{ on_attach=require'completion'.on_attach }
|
||||
lua require'lspconfig'.intelephense.setup{ on_attach=require'completion'.on_attach }
|
||||
lua require'lspconfig'.vuels.setup{ on_attach=require'completion'.on_attach }
|
||||
lua require'lspconfig'.pylsp.setup{ on_attach=require'completion'.on_attach }
|
||||
lua require'lspconfig'.texlab.setup{ on_attach=require'completion'.on_attach }
|
||||
lua <<EOF
|
||||
lspconfig = require "lspconfig"
|
||||
lspconfig.gopls.setup {
|
||||
cmd = {"gopls", "serve"},
|
||||
settings = {
|
||||
gopls = {
|
||||
analyses = {
|
||||
unusedparams = true,
|
||||
},
|
||||
staticcheck = true,
|
||||
},
|
||||
},
|
||||
}
|
||||
EOF
|
||||
|
||||
set completeopt=menuone,noinsert,noselect
|
||||
set shortmess+=c
|
||||
|
||||
|
||||
" EMMET SETUP
|
||||
" =========================
|
||||
let g:user_emmet_leader_key='<C-i>'
|
||||
|
||||
" LANGUAGETOOL SETUP
|
||||
" =========================
|
||||
" autocmd Filetype tex LanguageToolSetUp
|
||||
let g:languagetool_cmd='/usr/bin/languagetool'
|
||||
lua require('autocompletion')
|
||||
|
||||
" TREESITTER
|
||||
lua <<EOF
|
||||
|
|
|
@ -61,9 +61,16 @@ Plug 'vim-airline/vim-airline'
|
|||
" LANGUAGES
|
||||
" ===================
|
||||
|
||||
" nvim language server
|
||||
" nvim completion
|
||||
Plug 'neovim/nvim-lspconfig'
|
||||
Plug 'nvim-lua/completion-nvim'
|
||||
Plug 'hrsh7th/cmp-nvim-lsp'
|
||||
Plug 'hrsh7th/cmp-buffer'
|
||||
Plug 'hrsh7th/cmp-path'
|
||||
Plug 'hrsh7th/cmp-cmdline'
|
||||
Plug 'hrsh7th/nvim-cmp'
|
||||
|
||||
Plug 'SirVer/ultisnips'
|
||||
Plug 'quangnguyen30192/cmp-nvim-ultisnips'
|
||||
|
||||
" Autoformatter
|
||||
Plug 'sbdchd/neoformat'
|
||||
|
|
Loading…
Add table
Reference in a new issue