diff --git a/coc-settings.json b/coc-settings.json new file mode 100644 index 0000000..4942f3d --- /dev/null +++ b/coc-settings.json @@ -0,0 +1,15 @@ +{ + "languageserver": { + "rust": { + "command": "rustup", + "args": ["run", "nightly", "rust-analyzer"], + "filetypes": ["rust"], + "rootPatterns": ["Cargo.toml"] + }, + "elm": { + "command": "elm-language-server", + "filetypes": ["elm"], + "rootPatterns": ["elm.json"] + } + } +} diff --git a/init.vim b/init.vim index 1382722..0fdb498 100644 --- a/init.vim +++ b/init.vim @@ -3,35 +3,24 @@ set nocompatible " PLUGNIS ###########################################################{{{ call plug#begin() -if has('nvim') - Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' } -else - Plug 'Shougo/deoplete.nvim' - Plug 'roxma/nvim-yarp' - Plug 'roxma/vim-hug-neovim-rpc' -endif + +" Conquer of Completion +Plug 'neoclide/coc.nvim', {'branch': 'release'} " General plugins Plug 'vim-airline/vim-airline' Plug 'vim-airline/vim-airline-themes' Plug 'https://gitea.tforgione.fr/tforgione/peach.git' Plug 'scrooloose/nerdtree' -Plug 'w0rp/ale' Plug 'tpope/vim-abolish' " Language specific plugins -" C++ -Plug 'Shougo/deoplete-clangx' - " Rust Plug 'rust-lang/rust.vim' -Plug 'racer-rust/vim-racer' -Plug 'sebastianmarkow/deoplete-rust' " Elm Plug 'ElmCast/elm-vim' -Plug 'antew/vim-elm-language-server' " Toml Plug 'cespare/vim-toml' @@ -157,11 +146,46 @@ let g:markdown_composer_browser = 'firefox' let g:instant_markdown_autostart = 0 " }}} -" CODE COMPLETION ###################################################{{{ +" COC CONFIG ########################################################{{{ -" Use deoplete -let g:deoplete#enable_at_startup = 1 -autocmd FileType elm call deoplete#custom#buffer_option('auto_complete', v:false) +" Use `[g` and `]g` to navigate diagnostics +" Use `:CocDiagnostics` to get all diagnostics of current buffer in location list. +nmap gp (coc-diagnostic-prev) +nmap gn (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 + +" Having longer updatetime (default is 4000 ms = 4 s) leads to noticeable +" delays and poor user experience. +set updatetime=300 + +" Highlight the symbol and its references when holding the cursor. +autocmd CursorHold * silent call CocActionAsync('highlight') + +" Symbol renaming. +nmap rn (coc-rename) + +" Formatting selected code. +xmap f (coc-format-selected) +nmap f (coc-format-selected) " Autoclose preview autocmd CursorMovedI * if pumvisible() == 0|pclose|endif @@ -169,19 +193,7 @@ autocmd InsertLeave * if pumvisible() == 0|pclose|endif " Complete on tab inoremap pumvisible() ? "\" : "\" - " }}} " CUSTOM THINGS DEPENDING ON ENV ####################################{{{ let g:rustfmt_autosave = 1 -let g:ale_linters = {} -let g:ale_c_parse_compile_commands=1 -let g:ale_elm_ls_use_global = 1 -let g:ale_linters_ignore = { 'elm': ['make'] } -let g:ale_lint_on_text_changed = 0 -if $NVIM_DISABLE_PYTHON_LINTER == '1' - let g:ale_linters.python = [] -endif -if $NVIM_DISABLE_JAVA_LINTER == '1' - let g:ale_linters.java = [] -endif