-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathvimrc.coc
223 lines (186 loc) · 7.34 KB
/
vimrc.coc
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
" vim: set ft=vim:
" Tagbar and FZF {{{
Plug 'majutsushi/tagbar'
nnoremap <silent> <leader>4 :TagbarToggle<CR>
let g:tagbar_type_php = {
\'ctagstype' : 'php',
\'kinds' : [
\'i:interfaces',
\'c:classes',
\'d:constant definitions',
\'f:functions',
\'j:javascript functions:1'
\]
\}"
let g:tagbar_map_jump=["o", "<cr>"]
let g:tagbar_map_openfold="zo"
let g:tagbar_map_closefold="zc"
let g:tagbar_map_togglefold="za"
let g:tagbar_map_openallfolds="zR"
let g:tagbar_map_closeallfolds="zM"
let g:tagbar_map_hidenonpublic="I"
let g:tagbar_map_zoomwin="A"
let g:tagbar_map_previewwin="<nop>"
let g:tagbar_map_showproto="<nop>"
let g:tagbar_map_incrementfolds="<nop>"
let g:tagbar_map_decrementfolds="<nop>"
let g:tagbar_map_toggleautoclose="<nop>"
let g:tagbar_width=40
let g:tagbar_sort=0
let g:tagbar_autofocus=1
let g:Tb_MaxSize=5
Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' }
Plug 'junegunn/fzf.vim'
let g:fzf_action = {
\ 'ctrl-t': 'tab split',
\ 'ctrl-s': 'split',
\ 'ctrl-v': 'vsplit' }
let $FZF_DEFAULT_OPTS = '--bind ctrl-s:select-all,ctrl-d:deselect-all'
let g:fzf_preview_window = ''
nnoremap <c-p> :GitFiles<CR>
nnoremap <leader>ff :Files<CR>
nnoremap <leader>fg :Rg
nnoremap <leader>fb :Buffers<CR>
nnoremap <leader>fH :Helptags<CR>
nnoremap <leader>f/ :History/<CR>
nnoremap <leader>f: :History:<CR>
nnoremap <leader>ft :Tags<CR>
nnoremap <leader>fbt :BTags<CR>
nnoremap <leader>fc :Commits<CR>
nnoremap <leader>fB :BCommits<CR>
nnoremap <leader>fm :Marks<CR>
nnoremap <leader>fC :Commands<CR>
nmap <leader>fmn :call fzf#vim#maps('n', 0)<cr>
nmap <leader>fmi :call fzf#vim#maps('i', 0)<cr>
nmap <leader>fmx :call fzf#vim#maps('x', 0)<cr>
nmap <leader>fmv :call fzf#vim#maps('v', 0)<cr>
nmap <leader>fmo :call fzf#vim#maps('o', 0)<cr>
" nnoremap <leader>ag :Ag<CR>
" nnoremap <leader>agt :Agt<CR>
nnoremap <silent> <leader>at :let @"=&filetype \| Agt --<C-R>" <C-R><C-W><CR>
" imap <c-x><c-k> <plug>(fzf-complete-word)
" imap <c-x><c-f> <plug>(fzf-complete-file-ag)
" imap <c-x><c-f> <plug>(fzf-complete-path)
" imap <c-x><c-l> <plug>(fzf-complete-line)
Plug 'zackhsi/fzf-tags'
nmap g<c-]> <Plug>(fzf_tags)
" }}}
Plug 'neoclide/coc.nvim', {'branch': 'release'}
let g:coc_global_extensions =["coc-json", "coc-tsserver", "coc-html", "coc-css", "coc-vetur", "coc-highlight", "coc-prettier", "coc-snippets", "coc-eslint", "coc-python", "coc-rust-analyzer"]
" You will have bad experience for diagnostic messages when it's default 4000.
set updatetime=500
" don't give |ins-completion-menu| messages.
" set shortmess+=c
" always show signcolumns
set signcolumn=yes
" Use tab for trigger completion with characters ahead and navigate.
" Use command ':verbose imap <tab>' to make sure tab is not mapped by other plugin.
execute('silent! iunmap <buffer> <tab>')
inoremap <silent><expr> <TAB>
\ pumvisible() ? "\<C-n>" :
\ <SID>check_back_space() ? "\<TAB>" :
\ coc#refresh()
inoremap <expr><S-TAB> pumvisible() ? "\<C-p>" : "\<C-h>"
function! s:check_back_space() abort
let col = col('.') - 1
return !col || getline('.')[col - 1] =~# '\s'
endfunction
" " Use <c-space> to trigger completion.
" inoremap <silent><expr> <c-space> coc#refresh()
" Use <cr> to confirm completion, `<C-g>u` means break undo chain at current position.
" Coc only does snippet and additional edit on confirm.
execute('silent! iunmap <buffer> <cr>')
inoremap <expr> <cr> pumvisible() ? "\<c-y>" : "\<c-g>u\<cr>"
" Use `[d` and `]d` to navigate diagnostics
nmap <silent> [d <Plug>(coc-diagnostic-prev)
nmap <silent> ]d <Plug>(coc-diagnostic-next)
nmap <silent> [c :CocPrev<cr>
nmap <silent> ]c :CocNext<cr>
" Remap keys for gotos
nmap <silent> gd <Plug>(coc-definition)
nmap <silent> gt <Plug>(coc-type-definition)
nmap <silent> gi <Plug>(coc-implementation)
nmap <silent> gr <Plug>(coc-references)
nnoremap <silent> <leader>2 :CocListResume<CR>
" textobj function if af
" Use K to show documentation in preview window
nnoremap <silent> gh :call <SID>show_documentation()<CR>
function! s:show_documentation()
if (index(['vim','help'], &filetype) >= 0)
execute 'h '.expand('<cword>')
else
call CocAction('doHover')
endif
endfunction
" Highlight symbol under cursor on CursorHold
" autocmd CursorHold * silent call CocActionAsync('highlight')
" Remap for rename current word
nmap <leader>rn <Plug>(coc-rename)
" Remap for format selected region
" xmap <leader>f <Plug>(coc-format-selected)
" nmap <leader>f <Plug>(coc-format-selected)
nmap ff <Plug>(coc-format)
augroup mygroup
autocmd!
" Setup formatexpr specified filetype(s).
autocmd FileType typescript,json setl formatexpr=CocAction('formatSelected')
" Update signature help on jump placeholder
autocmd User CocJumpPlaceholder call CocActionAsync('showSignatureHelp')
augroup end
" Remap for do codeAction of selected region, ex: `<leader>aap` for current paragraph
xmap <leader>a <Plug>(coc-codeaction-selected)
nmap <leader>a <Plug>(coc-codeaction-selected)
" Remap for do codeAction of current line
nmap <leader>ga <Plug>(coc-codeaction)
" Fix autofix problem of current line
nmap <leader>qf <Plug>(coc-fix-current)
" " Use <tab> for select selections ranges, needs server support, like: coc-tsserver, coc-python
" nmap <silent> <TAB> <Plug>(coc-range-select)
" xmap <silent> <TAB> <Plug>(coc-range-select)
" xmap <silent> <S-TAB> <Plug>(coc-range-select-backword)
" Use `:Format` to format current buffer
command! -nargs=0 Format :call CocAction('format')
" Use `:Fold` to fold current buffer
command! -nargs=? Fold :call CocAction('fold', <f-args>)
" use `:OR` for organize import of current buffer
command! -nargs=0 OR :call CocAction('runCommand', 'editor.action.organizeImport')
" Add status line support, for integration with other plugin, checkout `:h coc-status`
set statusline^=%{coc#status()}%{get(b:,'coc_current_function','')}
inoremap <silent><expr> <c-g> coc#refresh()
" Using CocList
" Show all diagnostics
nnoremap <silent> <leader>oo :<C-u>CocList diagnostics<cr>
" Show commands
nnoremap <silent> <leader>oc :<C-u>CocList commands<cr>
" Resume latest coc list
command! -nargs=+ -complete=custom,s:GrepArgs Rg exe 'CocList grep '.<q-args>
function! s:GrepArgs(...)
let list = ['-S', '-smartcase', '-i', '-ignorecase', '-w', '-word',
\ '-e', '-regex', '-u', '-skip-vcs-ignores', '-t', '-extension']
return join(list, "\n")
endfunction
" Keymapping for grep word under cursor with interactive mode
nnoremap <silent> <Leader>ch :exe 'CocList -I --input='.expand('<cword>').' grep'<CR>
vnoremap <leader>g :<C-u>call <SID>GrepFromSelected(visualmode())<CR>
nnoremap <leader>g :<C-u>set operatorfunc=<SID>GrepFromSelected<CR>g@
function! s:GrepFromSelected(type)
let saved_unnamed_register = @@
if a:type ==# 'v'
normal! `<v`>y
elseif a:type ==# 'char'
normal! `[v`]y
else
return
endif
let word = substitute(@@, '\n$', '', 'g')
let word = escape(word, '| ')
let @@ = saved_unnamed_register
execute 'CocList grep '.word
endfunction
" neoclide/coc-snippets {{{
let g:coc_snippet_next = '<c-j>'
let g:coc_snippet_prev = '<c-k>'
" Use <C-j> for both expand and jump (make expand higher priority.)
imap <C-l> <Plug>(coc-snippets-expand-jump)
nmap <leader>oe :CocCommand snippets.editSnippets<cr>
""" }}}