Nos permite utilizar un servidor LSP para tener autocompletación de código y otras funciones como "go to definition".
Plug 'neoclide/coc.nvim', {'branch': 'release'}
:CocInstall <paquete-lenguaje>
:CocInstall coc-html
:CocInstall coc-tsserver
:CocInstall coc-java
:CocInstall coc-json
Añadimos la siguiente configuración en nuestro archivo vimrc:
" Set internal encoding of vim, not needed on neovim, since coc.nvim using some
" unicode characters in the file autoload/float.vim
set encoding=utf-8
" TextEdit might fail if hidden is not set.
set hidden
" Some servers have issues with backup files, see #649.
set nobackup
set nowritebackup
" Give more space for displaying messages.
set cmdheight=2
" Having longer updatetime (default is 4000 ms = 4 s) leads to noticeable
" delays and poor user experience.
set updatetime=300
" Don't pass messages to |ins-completion-menu|.
set shortmess+=c
" Always show the signcolumn, otherwise it would shift the text each time
" diagnostics appear/become resolved.
if has("nvim-0.5.0") || has("patch-8.1.1564")
" Recently vim can merge signcolumn and number column into one
set signcolumn=number
else
set signcolumn=yes
endif
" Use <c-space> to trigger completion.
if has('nvim')
inoremap <silent><expr> <c-space> coc#refresh()
else
inoremap <silent><expr> <c-@> coc#refresh()
endif
" Make <CR> auto-select the first completion item and notify coc.nvim to
" format on enter, <cr> could be remapped by other vim plugin
inoremap <silent><expr> <cr> pumvisible() ? coc#_select_confirm()
\: "\<C-g>u\<CR>\<c-r>=coc#on_enter()\<CR>"
Para utilizar el autocompletado con esta configuración solo tenemos que empezar a escribir y aparecerán automaticamente las posibles opciones para autocompletar, si queremos que se autocomplete solo pulsamos enter y se autocompletará con la primera opción, si queremos elegir otra opción podemos elegirla con las flechas y pulsar enter.
Si queremos fozar la aparición del autocompletado (por ejemplo cuando nos movemos con el cursor en vez de estar escribiendo) podemos hacerlo pulsando Ctrl + Espacio
Vim | plugin | coc