forked from sharksforarms/neovim-rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvim-vimrc-coc.vim
More file actions
64 lines (49 loc) · 1.68 KB
/
vim-vimrc-coc.vim
File metadata and controls
64 lines (49 loc) · 1.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
" Prerequisites:
" - coc needs vim >= 8.1.1719 to support features like popup and text property
" - nodejs: curl -sL install-node.now.sh/lts | bash
" Steps:
" - :PlugInstall
" - :CocInstall coc-rust-analyzer
" - Restart
call plug#begin('~/.vim/plugged')
" coc: Conquer of completion
Plug 'neoclide/coc.nvim', {'branch': 'release'}
call plug#end()
syntax enable
filetype plugin indent on
" This is a highly configurable plugin.
"
" For features such as goto definition, tab completion, documentation preview
" and more, see the sample configuration:
" https://github.com/neoclide/coc.nvim#example-vim-configuration
" Set completeopt to have a better completion experience
set completeopt=menuone,noinsert,noselect
" Avoid showing extra messages when using completion
set shortmess+=c
" Code navigation
nmap <silent> gd <Plug>(coc-definition)
nmap <silent> gy <Plug>(coc-type-definition)
nmap <silent> gi <Plug>(coc-implementation)
nmap <silent> gr <Plug>(coc-references)
" Trigger completion with <tab>
" found in :help completion
function! s:check_back_space() abort
let col = col('.') - 1
return !col || getline('.')[col - 1] =~ '\s'
endfunction
inoremap <silent><expr> <TAB>
\ pumvisible() ? "\<C-n>" :
\ <SID>check_back_space() ? "\<TAB>" :
\ completion#trigger_completion()
" Goto previous/next diagnostic warning/error
nmap <silent> [g <Plug>(coc-diagnostic-prev)
nmap <silent> ]g <Plug>(coc-diagnostic-next)
" Use K to show documentation in preview window.
nnoremap <silent> K :call <SID>show_documentation()<CR>
function! s:show_documentation()
if (index(['vim','help'], &filetype) >= 0)
execute 'h '.expand('<cword>')
else
call CocActionAsync('doHover')
endif
endfunction