diff --git a/init.vim b/init.vim index d10a8fb..c41babc 100644 --- a/init.vim +++ b/init.vim @@ -23,13 +23,13 @@ Plug 'Xuyuanp/nerdtree-git-plugin' " To Plug 'https://github.com/editorconfig/editorconfig-vim' " Support of '.editorconfig' files Plug 'vim-syntastic/syntastic' " Syntax checking (linting) " Auto completion -Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' } -Plug 'zchee/deoplete-jedi' " source for python autocompletion -Plug 'Shougo/neco-syntax' " other sources for autocompletion -Plug 'davidhalter/jedi-vim' " Code jump +Plug 'neoclide/coc.nvim', {'branch': 'release'} +Plug 'pappasam/coc-jedi', { 'do': 'yarn install --frozen-lockfile && yarn build' } "Python, using jedi +" Code jump +Plug 'davidhalter/jedi-vim' " Code jump for python " Imports sorting Plug 'stsewd/isort.nvim', { 'do': ':UpdateRemotePlugins' } -Plug 'vitalk/vim-simple-todo' +Plug 'vitalk/vim-simple-todo' " Allow to manage todo list easily " Search Plug 'kien/ctrlp.vim' " Search 'Ctrl+P' like Plug 'jremmen/vim-ripgrep' " Use ripgrep as vimgrep @@ -164,18 +164,82 @@ let g:syntastic_always_populate_loc_list = 1 let g:syntastic_auto_loc_list = 1 let g:syntastic_check_on_open = 1 -" autocompletion -let g:deoplete#enable_at_startup=1 " start deoplete at startup -" Close suggestion window at completion -autocmd InsertLeave,CompleteDone * if pumvisible() == 0 | pclose | endif -" Use tab to sensible items in the suggestion list -inoremap pumvisible() ? "\" : "\" +" ######################################### +" ######################################### +" autocompletion, mainly coc configuration +" as inspired from the project README +" 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 + +" Always show the signcolumn, otherwise it would shift the text each time +" diagnostics appear/become resolved. +if has("patch-8.1.1564") + " Recently vim can merge signcolumn and number column into one + set signcolumn=number +else + set signcolumn=yes +endif + +" Use tab for trigger completion with characters ahead and navigate +inoremap + \ pumvisible() ? "\" : + \ check_back_space() ? "\" : + \ coc#refresh() +inoremap pumvisible() ? "\" : "\" + +function! s:check_back_space() abort + let col = col('.') - 1 + return !col || getline('.')[col - 1] =~# '\s' +endfunction +" Use to trigger completion. +if has('nvim') + inoremap coc#refresh() +else + inoremap coc#refresh() +endif + +" Make auto-select the first completion item and notify coc.nvim to +" format on enter, could be remapped by other vim plugin +inoremap pumvisible() ? coc#_select_confirm() + \: "\u\\=coc#on_enter()\" + +" Use `[g` and `]g` to navigate diagnostics +" Use `:CocDiagnostics` to get all diagnostics of current buffer in location list. +nmap [g (coc-diagnostic-prev) +nmap ]g (coc-diagnostic-next) + +" GoTo code navigation. +nmap gd (coc-definition) +nmap gy (coc-type-definition) +nmap gi (coc-implementation) +nmap gr (coc-references) + +" Use K to show documentation in preview window. +nnoremap K :call show_documentation() + +function! s:show_documentation() + if (index(['vim','help'], &filetype) >= 0) + execute 'h '.expand('') + elseif (coc#rpc#ready()) + call CocActionAsync('doHover') + else + execute '!' . &keywordprg . " " . expand('') + endif +endfunction + +" Install missing coc extensions +let g:coc_global_extensions = ['coc-html', 'coc-json', 'coc-css', 'coc-markdownlint', 'coc-git'] +autocmd FileType scss setl iskeyword+=@-@ " Add @ to iskeyword option +let g:coc_filetype_map = { 'pandoc': 'markdown' } " Allow markdownlint to recognized pandoc filetype + +" ######################################### +" ######################################### "Code jump -" disable autocompletion, cause we use deoplete for completion -let g:jedi#completions_enabled=0 -" open the go-to function in split, not another buffer -let g:jedi#use_splits_not_buffers="right" +let g:jedi#use_splits_not_buffers="right" " open the go-to function in split, not another buffer " Python provider in a pyenv let g:python3_host_prog='/home/igor/.pyenv/versions/neovim3/bin/python'