Plug 'neoclide/coc.nvim', {'branch': 'release'} Plug 'IngoMeyer441/coc_current_word' " Set internal encoding of vim, not needed on neovim, since coc.nvim using some " unicode characters in the file autoload/float.vim set encoding=utf-8 " TextEdit might fail if hidden is not set. set hidden " Some servers have issues with backup files, see #649. set nobackup set nowritebackup " Give more space for displaying messages. set cmdheight=2 " Having longer updatetime (default is 4000 ms = 4 s) leads to noticeable " delays and poor user experience. set updatetime=300 " Don't pass messages to |ins-completion-menu|. set shortmess+=c " Formatting selected code. " xmap f (coc-format-selected) " nmap f (coc-format-selected) nmap rn (coc-rename) " pc = pick color nmap pc :call CocAction('pickColor') " yaml outline nmap yo nmap pm :CocCommand markdown-preview-enhanced.openPreview nmap cr :CocRestart " let g:node_client_debug = 1 let g:coc_global_extensions = [ 'coc-emoji', 'coc-eslint', 'coc-tsserver', 'coc-tslint', 'coc-tslint-plugin', 'coc-css', 'coc-json', 'coc-pyls', 'coc-yaml', 'coc-html', 'coc-go', 'coc-git', 'coc-css', 'coc-sql', 'coc-sh', 'coc-rust-analyzer', 'coc-java', 'coc-kotlin', 'coc-explorer', 'coc-highlight', 'coc-marketplace', 'coc-zi', 'coc-syntax', 'coc-fzf-preview', 'coc-mocword'] " Don't pass messages to |ins-completion-menu|. set shortmess+=c " Always show the signcolumn, otherwise it would shift the text each time " diagnostics appear/become resolved. if has("nvim-0.5.0") || has("patch-8.1.1564") " Recently vim can merge signcolumn and number column into one set signcolumn=number else set signcolumn=yes endif " 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() inoremap pumvisible() ? "\" : "\" function! s:check_back_space() abort let col = col('.') - 1 return !col || getline('.')[col - 1] =~# '\s' endfunction " Use to trigger completion. if has('nvim') inoremap coc#refresh() else inoremap coc#refresh() endif " Make auto-select the first completion item and notify coc.nvim to " format on enter, could be remapped by other vim plugin inoremap pumvisible() ? coc#_select_confirm() \: "\u\\=coc#on_enter()\" " Applying codeAction to the selected region. " Example: `aap` for current paragraph xmap a (coc-codeaction-selected) nmap a (coc-codeaction-selected) vmap a (coc-codeaction-selected) " Remap keys for applying codeAction to the current buffer. nmap ca (coc-codeaction) " Apply AutoFix to problem on the current line. nmap qf (coc-fix-current) " Run the Code Lens action on the current line. nmap cl (coc-codelens-action) "" Remap for do codeAction of selected region function! s:cocActionsOpenFromSelected(type) abort execute 'CocCommand actions.open ' . a:type endfunction " Use `[g` and `]g` to navigate diagnostics nmap [g (coc-diagnostic-prev) nmap ]g (coc-diagnostic-next) " Remap keys for gotos nmap gd (coc-definition) nmap gy (coc-type-definition) nmap gi (coc-implementation) nmap gr (coc-references) " Apply AutoFix to problem on the current line. nmap qf (coc-fix-current) " Map function and class text objects " NOTE: Requires 'textDocument.documentSymbol' support from the language server. xmap if (coc-funcobj-i) omap if (coc-funcobj-i) xmap af (coc-funcobj-a) omap af (coc-funcobj-a) xmap ic (coc-classobj-i) omap ic (coc-classobj-i) xmap ac (coc-classobj-a) omap ac (coc-classobj-a) " We're going to define single-letter keymaps, so don't try to define them " in the terminal window. The debugger CLI should continue accepting text commands. function! NvimGdbNoTKeymaps() tnoremap endfunction let g:nvimgdb_config_override = { \ 'key_next': 'n', \ 'key_step': 's', \ 'key_finish': 'f', \ 'key_continue': 'c', \ 'key_until': 'u', \ 'key_breakpoint': 'b', \ 'set_tkeymaps': "NvimGdbNoTKeymaps", \ } " Use K to show documentation in preview window. nnoremap L :call show_documentation() function! s:show_documentation() if (index(['vim','help'], &filetype) >= 0) execute 'h '.expand('') elseif (coc#rpc#ready()) call CocActionAsync('doHover') else execute '!' . &keywordprg . " " . expand('') endif endfunction set statusline^=%{coc#status()}%{get(b:,'coc_current_function','')} " Apply AutoFix to problem on the current line. nmap qf (coc-fix-current) nmap zg :CocCommand cSpell.addWordToDictionary " Mappings for CoCList " Show all diagnostics. nnoremap a :CocList diagnostics " Manage extensions. nnoremap e :CocList extensions " Show commands. nnoremap c :CocList commands " Find symbol of current document. nnoremap o :CocList outline " Search workspace symbols. nnoremap s :CocList -I symbols " Do default action for next item. nnoremap j :CocNext " Do default action for previous item. nnoremap k :CocPrev " Resume latest coc list. nnoremap p :CocListResume