Skip to content

Commit cec8e77

Browse files
committed
Update coc vim config
1 parent d0ed4e1 commit cec8e77

1 file changed

Lines changed: 48 additions & 43 deletions

File tree

.vimrc.dist

Lines changed: 48 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -151,19 +151,19 @@ let g:doge_doc_standard_python = 'google'
151151
" see .vim/coc-settings.json !! or Use :CocConfig
152152
" to update plugins use :CocUpdate
153153

154-
" Use tab for trigger completion with characters ahead and navigate.
154+
" Use tab for trigger completion with characters ahead and navigate
155155
" NOTE: There's always complete item selected by default, you may want to enable
156-
" no select by `"suggest.noselect": true` in your configuration file.
156+
" no select by `"suggest.noselect": true` in your configuration file
157157
" NOTE: Use command ':verbose imap <tab>' to make sure tab is not mapped by
158-
" other plugin before putting this into your config.
158+
" other plugin before putting this into your config
159159
inoremap <silent><expr> <TAB>
160160
\ coc#pum#visible() ? coc#pum#next(1) :
161161
\ CheckBackspace() ? "\<Tab>" :
162162
\ coc#refresh()
163163
inoremap <expr><S-TAB> coc#pum#visible() ? coc#pum#prev(1) : "\<C-h>"
164164

165165
" Make <CR> to accept selected completion item or notify coc.nvim to format
166-
" <C-g>u breaks current undo, please make your own choice.
166+
" <C-g>u breaks current undo, please make your own choice
167167
inoremap <silent><expr> <CR> coc#pum#visible() ? coc#pum#confirm()
168168
\: "\<C-g>u\<CR>\<c-r>=coc#on_enter()\<CR>"
169169

@@ -172,25 +172,25 @@ function! CheckBackspace() abort
172172
return !col || getline('.')[col - 1] =~# '\s'
173173
endfunction
174174

175-
" Use <c-space> to trigger completion.
175+
" Use <c-space> to trigger completion
176176
if has('nvim')
177177
inoremap <silent><expr> <c-space> coc#refresh()
178178
else
179179
inoremap <silent><expr> <c-@> coc#refresh()
180180
endif
181181

182182
" Use `[g` and `]g` to navigate diagnostics
183-
" Use `:CocDiagnostics` to get all diagnostics of current buffer in location list.
184-
nmap <silent> [g <Plug>(coc-diagnostic-prev)
185-
nmap <silent> ]g <Plug>(coc-diagnostic-next)
183+
" Use `:CocDiagnostics` to get all diagnostics of current buffer in location list
184+
nmap <silent><nowait> [g <Plug>(coc-diagnostic-prev)
185+
nmap <silent><nowait> ]g <Plug>(coc-diagnostic-next)
186186

187-
" GoTo code navigation.
188-
nmap <silent> gd <Plug>(coc-definition)
189-
nmap <silent> gy <Plug>(coc-type-definition)
190-
nmap <silent> gi <Plug>(coc-implementation)
191-
nmap <silent> gr <Plug>(coc-references)
187+
" GoTo code navigation
188+
nmap <silent><nowait> gd <Plug>(coc-definition)
189+
nmap <silent><nowait> gy <Plug>(coc-type-definition)
190+
nmap <silent><nowait> gi <Plug>(coc-implementation)
191+
nmap <silent><nowait> gr <Plug>(coc-references)
192192

193-
" Use K to show documentation in preview window.
193+
" Use K to show documentation in preview window
194194
nnoremap <silent> K :call ShowDocumentation()<CR>
195195

196196
function! ShowDocumentation()
@@ -201,39 +201,44 @@ function! ShowDocumentation()
201201
endif
202202
endfunction
203203

204-
" Highlight the symbol and its references when holding the cursor.
204+
" Highlight the symbol and its references when holding the cursor
205205
autocmd CursorHold * silent call CocActionAsync('highlight')
206206

207-
" Symbol renaming.
207+
" Symbol renaming
208208
nmap <leader>rn <Plug>(coc-rename)
209209

210-
" Formatting selected code.
210+
" Formatting selected code
211211
xmap <leader>f <Plug>(coc-format-selected)
212212
nmap <leader>f <Plug>(coc-format-selected)
213213

214214
augroup mygroup
215215
autocmd!
216-
" Setup formatexpr specified filetype(s).
216+
" Setup formatexpr specified filetype(s)
217217
autocmd FileType typescript,json setl formatexpr=CocAction('formatSelected')
218-
" Update signature help on jump placeholder.
219-
autocmd User CocJumpPlaceholder call CocActionAsync('showSignatureHelp')
220218
augroup end
221219

222-
" Applying codeAction to the selected region.
220+
" Applying code actions to the selected code block
223221
" Example: `<leader>aap` for current paragraph
224222
xmap <leader>a <Plug>(coc-codeaction-selected)
225223
nmap <leader>a <Plug>(coc-codeaction-selected)
226224

227-
" Remap keys for applying codeAction to the current buffer.
228-
nmap <leader>ac <Plug>(coc-codeaction)
229-
" Apply AutoFix to problem on the current line.
225+
" Remap keys for applying code actions at the cursor position
226+
nmap <leader>ac <Plug>(coc-codeaction-cursor)
227+
" Remap keys for apply code actions affect whole buffer
228+
nmap <leader>as <Plug>(coc-codeaction-source)
229+
" Apply the most preferred quickfix action to fix diagnostic on the current line
230230
nmap <leader>qf <Plug>(coc-fix-current)
231231

232-
" Run the Code Lens action on the current line.
232+
" Remap keys for applying refactor code actions
233+
nmap <silent> <leader>re <Plug>(coc-codeaction-refactor)
234+
xmap <silent> <leader>r <Plug>(coc-codeaction-refactor-selected)
235+
nmap <silent> <leader>r <Plug>(coc-codeaction-refactor-selected)
236+
237+
" Run the Code Lens action on the current line
233238
nmap <leader>cl <Plug>(coc-codelens-action)
234239

235240
" Map function and class text objects
236-
" NOTE: Requires 'textDocument.documentSymbol' support from the language server.
241+
" NOTE: Requires 'textDocument.documentSymbol' support from the language server
237242
xmap if <Plug>(coc-funcobj-i)
238243
omap if <Plug>(coc-funcobj-i)
239244
xmap af <Plug>(coc-funcobj-a)
@@ -243,7 +248,7 @@ omap ic <Plug>(coc-classobj-i)
243248
xmap ac <Plug>(coc-classobj-a)
244249
omap ac <Plug>(coc-classobj-a)
245250

246-
" Remap <C-f> and <C-b> for scroll float windows/popups.
251+
" Remap <C-f> and <C-b> to scroll float windows/popups
247252
if has('nvim-0.4.0') || has('patch-8.2.0750')
248253
nnoremap <silent><nowait><expr> <C-f> coc#float#has_scroll() ? coc#float#scroll(1) : "\<C-f>"
249254
nnoremap <silent><nowait><expr> <C-b> coc#float#has_scroll() ? coc#float#scroll(0) : "\<C-b>"
@@ -253,39 +258,39 @@ if has('nvim-0.4.0') || has('patch-8.2.0750')
253258
vnoremap <silent><nowait><expr> <C-b> coc#float#has_scroll() ? coc#float#scroll(0) : "\<C-b>"
254259
endif
255260

256-
" Use CTRL-S for selections ranges.
257-
" Requires 'textDocument/selectionRange' support of language server.
261+
" Use CTRL-S for selections ranges
262+
" Requires 'textDocument/selectionRange' support of language server
258263
nmap <silent> <C-s> <Plug>(coc-range-select)
259264
xmap <silent> <C-s> <Plug>(coc-range-select)
260265

261-
" Add `:Format` command to format current buffer.
266+
" Add `:Format` command to format current buffer
262267
command! -nargs=0 Format :call CocActionAsync('format')
263268

264-
" Add `:Fold` command to fold current buffer.
269+
" Add `:Fold` command to fold current buffer
265270
command! -nargs=? Fold :call CocAction('fold', <f-args>)
266271

267-
" Add `:OR` command for organize imports of the current buffer.
272+
" Add `:OR` command for organize imports of the current buffer
268273
command! -nargs=0 OR :call CocActionAsync('runCommand', 'editor.action.organizeImport')
269274

270-
" Add (Neo)Vim's native statusline support.
275+
" Add (Neo)Vim's native statusline support
271276
" NOTE: Please see `:h coc-status` for integrations with external plugins that
272-
" provide custom statusline: lightline.vim, vim-airline.
273-
let g:airline#extensions#coc#enabled = 1
277+
" provide custom statusline: lightline.vim, vim-airline
278+
set statusline^=%{coc#status()}%{get(b:,'coc_current_function','')}
274279

275280
" Mappings for CoCList
276-
" Show all diagnostics.
281+
" Show all diagnostics
277282
nnoremap <silent><nowait> <space>a :<C-u>CocList diagnostics<cr>
278-
" Manage extensions.
283+
" Manage extensions
279284
nnoremap <silent><nowait> <space>e :<C-u>CocList extensions<cr>
280-
" Show commands.
285+
" Show commands
281286
nnoremap <silent><nowait> <space>c :<C-u>CocList commands<cr>
282-
" Find symbol of current document.
287+
" Find symbol of current document
283288
nnoremap <silent><nowait> <space>o :<C-u>CocList outline<cr>
284-
" Search workspace symbols.
289+
" Search workspace symbols
285290
nnoremap <silent><nowait> <space>s :<C-u>CocList -I symbols<cr>
286-
" Do default action for next item.
291+
" Do default action for next item
287292
nnoremap <silent><nowait> <space>j :<C-u>CocNext<CR>
288-
" Do default action for previous item.
293+
" Do default action for previous item
289294
nnoremap <silent><nowait> <space>k :<C-u>CocPrev<CR>
290-
" Resume latest coc list.
295+
" Resume latest coc list
291296
nnoremap <silent><nowait> <space>p :<C-u>CocListResume<CR>

0 commit comments

Comments
 (0)