" if hidden not set, TextEdit might fail. set hidden " Better display for messages set cmdheight=2 " Smaller updatetime for CursorHold & CursorHoldI set updatetime=300 " always show signcolumns set signcolumn=yes " Use tab for trigger completion with characters ahead and navigate. " Use command ':verbose imap ' to make sure tab is not mapped by other plugin. inoremap \ pumvisible() ? "\" : \ check_back_space() ? "\" : \ coc#refresh() inoremap pumvisible() ? "\" : "\" function! s:check_back_space() abort let col = col('.') - 1 return !col || getline('.')[col - 1] =~# '\s' endfunction " Use for trigger completion. inoremap coc#refresh() " Use for confirm completion, `u` means break undo chain at current position. " Coc only does snippet and additional edit on confirm. "inoremap pumvisible() ? "\" : "\u\" " NOTE: above mapping disabled due to https://github.com/tpope/vim-endwise/issues/22#issuecomment-446042476 " Use `[c` and `]c` for navigate diagnostics nmap [c (coc-diagnostic-prev) nmap ]c (coc-diagnostic-next) " Remap keys for gotos nmap gd (coc-definition) nmap gy (coc-type-definition) nmap gi (coc-implementation) nmap gr (coc-references) " Use K for show documentation in preview window nnoremap K :call show_documentation() function! s:show_documentation() if &filetype == 'vim' execute 'h '.expand('') else call CocAction('doHover') endif endfunction " Highlight symbol under cursor on CursorHold autocmd CursorHold * silent call CocActionAsync('highlight') " Remap for rename current word nmap rn (coc-rename) " Remap for format selected region vmap f (coc-format-selected) nmap f (coc-format-selected) " Setup formatexpr specified filetype(s). augroup mygroup autocmd! autocmd FileType typescript,json setl formatexpr=CocAction('formatSelected') augroup end " Remap for do codeAction of selected region, ex: `aap` for current paragraph vmap a (coc-codeaction-selected) nmap a (coc-codeaction-selected) " Remap for do codeAction of current line nmap ac (coc-codeaction)