These are some guides for various use.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

82 lines
2.1 KiB

  1. # Coc
  2. [Conquer of completion](https://github.com/neoclide/coc.nvim) enables full
  3. language server protocol support for neovim.
  4. It is written specifically for neovim.
  5. The coc config file is located in `.config/nvim/coc-settings.json`.
  6. ## Installation
  7. - Install `nodejs`
  8. - Install [vim-plug](vim-plug.md)
  9. - Add coc.vim to your init.vim
  10. - Add `Plug 'neoclide/coc.nvim', {'do': 'yarn install --frozen-lockfile'}`
  11. to your Plug-Section
  12. ## Base config
  13. Add the base configuration to your vim config file.
  14. ```vimscript
  15. " neoclide/coc.nvim
  16. inoremap <silent><expr> <TAB>
  17. \ pumvisible() ? "\<C-n>" :
  18. \ <SID>check_back_space() ? "\<TAB>" :
  19. \ coc#refresh()
  20. inoremap <expr><S-TAB> pumvisible() ? "\<C-p>" : "\<C-h>"
  21. function! s:check_back_space() abort
  22. let col = col('.') - 1
  23. return !col || getline('.')[col - 1] =~# '\s'
  24. endfunction
  25. if has('nvim')
  26. inoremap <silent><expr> <c-space> coc#refresh()
  27. else
  28. inoremap <silent><expr> <c-@> coc#refresh()
  29. endif
  30. inoremap <silent><expr> <cr> pumvisible() ? coc#_select_confirm()
  31. \: "\<C-g>u\<CR>\<c-r>=coc#on_enter()\<CR>"
  32. nmap <silent> gd <Plug>(coc-definition)
  33. nmap <silent> gy <Plug>(coc-type-definition)
  34. nmap <silent> gi <Plug>(coc-implementation)
  35. nmap <silent> gr <Plug>(coc-references)
  36. nnoremap <silent> K :call <SID>show_documentation()<CR>
  37. function! s:show_documentation()
  38. if (index(['vim','help'], &filetype) >= 0)
  39. execute 'h '.expand('<cword>')
  40. elseif (coc#rpc#ready())
  41. call CocActionAsync('doHover')
  42. else
  43. execute '!' . &keywordprg . " " . expand('<cword>')
  44. endif
  45. endfunction
  46. autocmd CursorHold * silent call CocActionAsync('highlight')
  47. nmap <F5> <Plug>(coc-rename)
  48. xmap <leader>f <Plug>(coc-format-selected)
  49. nmap <leader>f <Plug>(coc-format-selected)
  50. augroup mygroup
  51. autocmd!
  52. autocmd FileType typescript,json setl formatexpr=CocAction('formatSelected')
  53. autocmd User CocJumpPlaceholder call CocActionAsync('showSignatureHelp')
  54. augroup end
  55. ```
  56. ## Extensions
  57. Extensions can be added to the vim config aswell.
  58. A basic example for adding a few extensions is:
  59. ```vimscript
  60. let g:coc_global_extensions = [
  61. \ ]
  62. ```