" Use system (homebrew) node if executable('/usr/local/bin/node') let g:coc_node_path = '/usr/local/bin/node' elseif executable('/opt/homebrew/bin/node') let g:coc_node_path = '/opt/homebrew/bin/node' endif " It seems 'longest' break behavior for empty completion " https://github.com/neoclide/coc.nvim/issues/4398 set completeopt-=longest " Global extension names to install when they aren't installed let g:coc_global_extensions = [ \ '@yaegassy/coc-ruff', \ '@yaegassy/coc-tailwindcss3', \ 'coc-deno', \ 'coc-diagnostic', \ 'coc-eslint', \ 'coc-gauge', \ 'coc-git', \ 'coc-go', \ 'coc-jest', \ 'coc-json', \ 'coc-lua', \ 'coc-prettier', \ 'coc-pyright', \ 'coc-rust-analyzer', \ 'coc-sh', \ 'coc-sumneko-lua', \ 'coc-tsserver', \ 'coc-vetur', \ 'coc-vimlsp', \ 'coc-word', \ 'coc-yaml', \] " Use to trigger completion inoremap coc#refresh() inoremap coc#pum#visible() ? coc#pum#confirm() : "\" nmap gd (coc-definition) nmap gD (coc-declaration) nmap gi (coc-implementation) nmap gy (coc-type-definition) nmap gr (coc-references) nmap gR (coc-refactor) nmap gq (coc-format) nmap gQ (coc-format-selected) vmap gQ (coc-format-selected) nmap qf (coc-fix-current) nmap qr (coc-rename) nmap (coc-codeaction) nmap g (coc-codeaction-cursor) vmap (coc-codeaction-selected) " Use [[ and ]] to navigate diagnostics nnoremap (my-zv) call timer_start(10, { -> feedkeys("zv", "nx") }) nmap [[ (coc-diagnostic-prev)(my-zv) nmap ]] (coc-diagnostic-next)(my-zv) nmap qd call CocAction('diagnosticToggle') xmap if (coc-funcobj-i) xmap af (coc-funcobj-a) omap if (coc-funcobj-i) omap af (coc-funcobj-a) xmap ic (coc-classobj-i) xmap ac (coc-classobj-a) omap ic (coc-classobj-i) omap ac (coc-classobj-a) " Remap and for scroll float windows/popups. " Note coc#float#scroll works on neovim >= 0.4.3 or vim >= 8.2.0750 if has('nvim-0.4.3') || has('patch-8.2.0750') nnoremap coc#float#has_scroll() ? coc#float#scroll(1) : "\" nnoremap coc#float#has_scroll() ? coc#float#scroll(0) : "\" endif " NeoVim-only mapping for visual mode scroll " Useful on signatureHelp after jump placeholder of snippet expansion if has('nvim') vnoremap coc#float#has_scroll() ? coc#float#nvim_scroll(1, 1) : "\" vnoremap coc#float#has_scroll() ? coc#float#nvim_scroll(0, 1) : "\" endif " Use K to show documentation in preview window function! s:show_documentation() abort if (index(['vim','help'], &filetype) >= 0) execute 'help' expand('') elseif (coc#rpc#ready()) call CocActionAsync('doHover') else execute printf('!%s', &keywordprg) expand('') endif endfunction nnoremap K call show_documentation() vnoremap K call CocActionAsync('doHover') augroup my-coc autocmd! " Highlight symbol under cursor on CursorHold autocmd CursorHold * silent! call CocActionAsync('highlight') " Update signature help on jump placeholder autocmd User CocJumpPlaceholder call CocActionAsync('showSignatureHelp') augroup END " coc-git nmap gs (coc-git-chunkinfo) nmap gp (coc-git-prevchunk) nmap gn (coc-git-nextchunk) command! CocEnableFormatOnSave call coc#config('coc.preferences.formatOnSave', v:true) command! CocDisableFormatOnSave call coc#config('coc.preferences.formatOnSave', v:false)