vim:plugins: Update coc.nvim to v0.0.82

Update the copied parts from the suggested config in the README.
This commit is contained in:
2022-10-21 01:38:02 +02:00
parent 77393007bf
commit 3d44400c59
2 changed files with 41 additions and 46 deletions

View File

@@ -1,57 +1,52 @@
" Primarly taken from: " Primarly taken from:
" https://github.com/neoclide/coc.nvim/tree/c3d31ad09d#example-vim-configuration " https://github.com/neoclide/coc.nvim/tree/v0.0.82#example-vim-configuration
" TextEdit might fail if hidden is not set.
set hidden
" Some servers have issues with backup files, see #649. " Some servers have issues with backup files, see #649.
set nobackup set nobackup
set nowritebackup set nowritebackup
" Give more space for displaying messages. " Having longer updatetime (default is 4000 ms = 4 s) leads to noticeable
set cmdheight=2 " delays and poor user experience.
set updatetime=300
" Don't pass messages to |ins-completion-menu|.
set shortmess+=c
" Always show the signcolumn, otherwise it would shift the text each time " Always show the signcolumn, otherwise it would shift the text each time
" diagnostics appear/become resolved. " diagnostics appear/become resolved.
if has("patch-8.1.1564") set signcolumn=yes
" Recently vim can merge signcolumn and number column into one
set signcolumn=number "Use <C-n> and <C-p> for navigate completion list like built in completion.
else inoremap <silent><expr> <C-n> coc#pum#visible() ? coc#pum#next(1) : "\<C-n>"
set signcolumn=yes inoremap <silent><expr> <C-p> coc#pum#visible() ? coc#pum#prev(1) : "\<C-n>"
endif
" Use tab for trigger completion with characters ahead and navigate. " Use tab for trigger completion with characters ahead and navigate.
" NOTE: Use command ':verbose imap <tab>' to make sure tab is not mapped by " NOTE: Use command ':verbose imap <tab>' to make sure tab is not mapped by
" other plugin before putting this into your config. " other plugin before putting this into your config.
inoremap <silent><expr> <TAB> inoremap <silent><expr> <TAB>
\ pumvisible() ? "\<C-n>" : \ coc#pum#visible() ? coc#pum#next(1):
\ <SID>check_back_space() ? "\<TAB>" : \ <SID>CheckBackspace() ? "\<Tab>" :
\ coc#refresh() \ coc#refresh()
inoremap <expr><S-TAB> pumvisible() ? "\<C-p>" : "\<C-h>" inoremap <expr><S-TAB> coc#pum#visible() ? coc#pum#prev(1) : "\<C-h>"
function! s:check_back_space() abort function! CheckBackspace() abort
let col = col('.') - 1 let col = col('.') - 1
return !col || getline('.')[col - 1] =~# '\s' return !col || getline('.')[col - 1] =~# '\s'
endfunction endfunction
" Use <c-space> to trigger completion. " Use <c-space> to trigger completion.
if has('nvim') if has('nvim')
inoremap <silent><expr> <c-space> coc#refresh() inoremap <silent><expr> <c-space> coc#refresh()
else else
inoremap <silent><expr> <c-@> coc#refresh() inoremap <silent><expr> <c-@> coc#refresh()
endif endif
" Use <cr> to confirm completion, `<C-g>u` means break undo chain at current " Make <CR> to accept selected completion item or notify coc.nvim to format
" position. Coc only does snippet and additional edit on confirm. " <C-g>u starts a new undo break, please make your own choice.
" <cr> could be remapped by other vim plugin, try `:verbose imap <CR>`. inoremap <silent><expr> <CR> coc#pum#visible() ? coc#pum#confirm()
if exists('*complete_info') \: "\<C-g>u\<CR>\<c-r>=coc#on_enter()\<CR>"
inoremap <expr> <cr> complete_info()["selected"] != "-1" ? "\<C-y>" : "\<C-g>u\<CR>"
else " Use `[g` and `]g` to navigate diagnostics
inoremap <expr> <cr> pumvisible() ? "\<C-y>" : "\<C-g>u\<CR>" " Use `:CocDiagnostics` to get all diagnostics of current buffer in location list.
endif nmap <silent> [g <Plug>(coc-diagnostic-prev)
nmap <silent> ]g <Plug>(coc-diagnostic-next)
" GoTo code navigation. " GoTo code navigation.
nmap <silent> gd <Plug>(coc-definition) nmap <silent> gd <Plug>(coc-definition)
@@ -60,14 +55,14 @@ nmap <silent> gi <Plug>(coc-implementation)
nmap <silent> gr <Plug>(coc-references) nmap <silent> gr <Plug>(coc-references)
" Use K to show documentation in preview window. " Use K to show documentation in preview window.
nnoremap <silent> K :call <SID>show_documentation()<CR> nnoremap <silent> K :call ShowDocumentation()<CR>
function! s:show_documentation() function! ShowDocumentation()
if (index(['vim','help'], &filetype) >= 0) if CocAction('hasProvider', 'hover')
execute 'h '.expand('<cword>') call CocActionAsync('doHover')
else else
call CocAction('doHover') call feedkeys('K', 'in')
endif endif
endfunction endfunction
" Highlight the symbol and its references when holding the cursor. " Highlight the symbol and its references when holding the cursor.
@@ -81,11 +76,11 @@ xmap <leader>f <Plug>(coc-format-selected)
nmap <leader>f <Plug>(coc-format-selected) nmap <leader>f <Plug>(coc-format-selected)
augroup mygroup augroup mygroup
autocmd! autocmd!
" Setup formatexpr specified filetype(s). " Setup formatexpr specified filetype(s).
autocmd FileType typescript,json setl formatexpr=CocAction('formatSelected') autocmd FileType typescript,json setl formatexpr=CocAction('formatSelected')
" Update signature help on jump placeholder. " Update signature help on jump placeholder.
autocmd User CocJumpPlaceholder call CocActionAsync('showSignatureHelp') autocmd User CocJumpPlaceholder call CocActionAsync('showSignatureHelp')
augroup end augroup end
" Applying codeAction to the selected region. " Applying codeAction to the selected region.
@@ -99,4 +94,4 @@ nmap <leader>ac <Plug>(coc-codeaction)
nmap <leader>qf <Plug>(coc-fix-current) nmap <leader>qf <Plug>(coc-fix-current)
" Add `:Format` command to format current buffer. " Add `:Format` command to format current buffer.
command! -nargs=0 Format :call CocAction('format') command! -nargs=0 Format :call CocActionAsync('format')