" Custom statusline report function! CocStatus() abort let info = get(b:, 'coc_diagnostic_info', {}) if empty(info) | return '' | endif let msgs = [] if get(info, 'warning', 0) call add(msgs, 'W' . info['warning']) endif if get(info, 'information', 0) call add(msgs, 'I' . info['information']) endif if get(info, 'hint', 0) call add(msgs, 'H' . info['hint']) endif return join(msgs, ' ') . ' ' . get(g:, 'coc_status', '') endfunction function! CocStatusDiagnosticError() abort let info = get(b:, 'coc_diagnostic_info', {}) if !empty(info) && get(info, 'error', 0) return ('E' . info['error']) endif return '' endfunction " Refresh statusline when g:coc_status changes autocmd User CocStatusChange let &statusline=&statusline "autocmd CursorHold let &statusline=&statusline " Get correct comment highlighting in coc-settings.json autocmd FileType json syntax match Comment +\/\/.\+$+ " Highlights hi CocErrorFloat ctermfg=darkred hi CocErrorSign term=standout ctermfg=15 ctermbg=1 guifg=White guibg=Red hi CocWarningSign term=standout ctermfg=15 ctermbg=130 guifg=White guibg=Orange "hi! link CocErrorSign ErrorMsg "hi! link CocWarningSign WarningMsg hi CocFloating ctermbg=gray ctermfg=black hi CocHintSign ctermbg=gray ctermfg=black hi CocInfoSign ctermbg=darkblue ctermfg=black " Some servers have issues with backup files, see #649. "set nobackup "set nowritebackup " Give more space for displaying messages. "set cmdheight=2 " Completion set completeopt=noinsert,noselect,menuone " Don't pass messages to |ins-completion-menu|. set shortmess+=c " Use tab for trigger completion with characters ahead and navigate. " NOTE: Use command ':verbose imap ' to make sure tab is not mapped by " other plugin before putting this into your config. inoremap \ pumvisible() ? "\" : \ check_back_space() ? "\" : \ coc#refresh() function! s:check_back_space() abort let col = col('.') - 1 return !col || getline('.')[col - 1] =~# '\s' endfunction inoremap pumvisible() ? "\" : "\" " Use to trigger completion. inoremap coc#refresh() " Use to confirm completion, `u` means break undo chain at current position. " Coc only does snippet and additional edit on confirm. if has('patch8.1.1068') " Use `complete_info` if your (Neo)Vim version supports it. inoremap complete_info()["selected"] != "-1" ? "\" : "\u\" else imap pumvisible() ? "\" : "\u\" endif " Use `[g` and `]g` to navigate diagnostics "nmap [g (coc-diagnostic-prev) "nmap ]g (coc-diagnostic-next) " GoTo code navigation. nmap gd (coc-definition) nmap gr (coc-references) " Do not seem to work for haskell-ide-engine nmap gy (coc-type-definition) nmap gi (coc-implementation) " Use H to show documentation in preview window. nnoremap H :call show_documentation() function! s:show_documentation() if (index(['vim','help'], &filetype) >= 0) execute 'h '.expand('') else call CocAction('doHover') endif endfunction " Escape hides floating window nmap :noh(coc-float-hide) " Highlight the symbol and its references when holding the cursor. autocmd CursorHold * silent call CocActionAsync('highlight') " Symbol renaming. nmap rn (coc-rename) " Formatting selected code. xmap f (coc-format-selected) nmap f (coc-format-selected) augroup coc 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 " Applying codeAction to the selected region. " Example: `aap` for current paragraph xmap a (coc-codeaction-selected) nmap a (coc-codeaction-selected) " Remap keys for applying codeAction to the current line. nmap al (coc-codeaction) " Apply AutoFix to problem on the current line. nmap qf (coc-fix-current) " Introduce function text object " NOTE: Requires 'textDocument.documentSymbol' support from the language server. xmap if (coc-funcobj-i) xmap af (coc-funcobj-a) omap if (coc-funcobj-i) omap af (coc-funcobj-a) " Use for selections ranges. " NOTE: Requires 'textDocument/selectionRange' support from the language server. " coc-tsserver, coc-python are the examples of servers that support it. "nmap (coc-range-select) "xmap (coc-range-select) " Add `:Format` command to format current buffer. command! -nargs=0 Format :call CocAction('format') " Add `:Fold` command to fold current buffer. command! -nargs=? Fold :call CocAction('fold', ) command! -nargs=? Unfold :0,$foldopen " Add `:OR` command for organize imports of the current buffer. command! -nargs=0 OR :call CocAction('runCommand', 'editor.action.organizeImport') " CocList " Show all diagnostics. nnoremap fa :CocList diagnostics " Manage extensions. nnoremap fe :CocList extensions " Show commands. nnoremap fc :CocList commands " Find symbol of current document. nnoremap fo :CocList outline " Search workspace symbols. nnoremap fs :CocList -I symbols " Do default action for next item in the last list. nnoremap fj :CocNext " Do default action for previous item in the last list. nnoremap fk :CocPrev " Resume latest coc list. nnoremap fp :CocListResume " Find files in cwd. nnoremap ff :CocList files " List all errors (bugs). nnoremap fb :CocList locationlist " Find buffers. "TODO map and to open with splits. nnoremap bf :CocList buffers