From f0811a86fee2858cb3198f8c5e99187f19d39adc Mon Sep 17 00:00:00 2001 From: DustVoice Date: Sun, 28 Mar 2021 20:42:48 +0200 Subject: [PATCH] Add coc.nvim with all kind of settings, etc. --- custom.vim.example | 3 +- init.vim | 72 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 74 insertions(+), 1 deletion(-) diff --git a/custom.vim.example b/custom.vim.example index 2352705..bf47022 100644 --- a/custom.vim.example +++ b/custom.vim.example @@ -1,3 +1,4 @@ "Here you can define your own custom settings like "let g:use_sound = 1 -"let g:use_autocomplete = 2 +"let g:use_autocomplete = 1 +"let g:use_coc = 1 diff --git a/init.vim b/init.vim index 04eec3d..d738786 100644 --- a/init.vim +++ b/init.vim @@ -97,6 +97,7 @@ let g:use_autocomplete=1 let g:use_bufkill = 1 let g:use_buftabline = 1 let g:use_clang_format = 0 +let g:use_coc = 0 let g:use_comfortable_motion = 0 let g:use_cpp = 1 let g:use_font = 0 @@ -111,6 +112,7 @@ let g:use_nerdtree = 1 let g:use_pandoc = 0 let g:use_polyglot = 0 let g:use_python = 1 +let g:use_rust = 1 let g:use_sound = 0 let g:use_sxhkd = 1 let g:use_templator = 0 @@ -265,6 +267,22 @@ if g:use_javacomplete == 1 endif " === +" === +" CoC +" === +if g:use_coc == 1 + Plug 'neoclide/coc.nvim', {'branch': 'release'} +endif +" === + +" === +" Rust +" === +if g:use_rust == 1 + Plug 'rust-lang/rust.vim' +endif +" === + " === " Special functionality " === @@ -565,6 +583,60 @@ if g:use_autocomplete == 3 endif " === +" === +" Setup CoC +" === +if g:use_coc == 1 + set updatetime=300 + + set shortmess+=c + + if has("patch-8.1.1564") + set signcolumn=number + else + set signcolumn=yes + endif + + inoremap coc#refresh() + + nmap [g (coc-diagnostic-prev) + nmap ]g (coc-diagnostic-next) + + nmap gd (coc-definition) + nmap gy (coc-type-definition) + nmap gi (coc-implementation) + nmap gr (coc-references) + + 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 + + autocmd CursorHold * silent call CocActionAsync('highlight') + + nmap rn (coc-rename) + + xmap f (coc-format-selected) + nmap f (coc-format-selected) + + xmap a (coc-codeaction-selected) + nmap a (coc-codeaction-selected) + nmap ac (coc-codeaction) + nmap qf (coc-fix-current) + + nnoremap y :CocList -A --normal yank + + let g:coc_gloabl_extensions = ['coc-clangd', 'coc-cmake', 'coc-html', 'coc-html-css-support', 'coc-java', 'coc-json', 'coc-markdownlint', 'coc-omnisharp', 'coc-prettier', 'coc-pyright', 'coc-rust-analyzer', 'coc-sh', 'coc-snippets', 'coc-xml', 'coc-yank'] +endif +" === + " === " Setup fswitch " ===