coc.vim 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. " Thanks https://www.chrisatmachine.com/Neovim/17-snippets/
  2. " Use <C-l> for trigger snippet expand.
  3. imap <C-l> <Plug>(coc-snippets-expand)
  4. " Use <C-j> for select text for visual placeholder of snippet.
  5. vmap <C-j> <Plug>(coc-snippets-select)
  6. " Use <C-j> for jump to next placeholder, it's default of coc.nvim
  7. let g:coc_snippet_next = '<c-j>'
  8. " Use <C-k> for jump to previous placeholder, it's default of coc.nvim
  9. let g:coc_snippet_prev = '<c-k>'
  10. " Use <C-j> for both expand and jump (make expand higher priority.)
  11. imap <C-j> <Plug>(coc-snippets-expand-jump)
  12. " Use `[g` and `]g` to navigate diagnostics
  13. " Use `:CocDiagnostics` to get all diagnostics of current buffer in location list.
  14. nmap <silent> [g <Plug>(coc-diagnostic-prev)
  15. nmap <silent> ]g <Plug>(coc-diagnostic-next)
  16. " GoTo code navigation.
  17. nmap <silent> gd <Plug>(coc-definition)
  18. nmap <silent> gy <Plug>(coc-type-definition)
  19. nmap <silent> gi <Plug>(coc-implementation)
  20. nmap <silent> gr <Plug>(coc-references)
  21. inoremap <silent><expr> <Tab>
  22. " Use K to show documentation in preview window.
  23. nnoremap <silent> K :call <SID>show_documentation()<CR>
  24. function! s:show_documentation()
  25. if CocAction('hasProvider', 'hover')
  26. call CocActionAsync('doHover')
  27. else
  28. call feedkeys('K', 'in')
  29. endif
  30. endfunction
  31. " MDX
  32. " Thanks https://github.com/neoclide/coc-prettier/issues/127#issuecomment-850598753
  33. let g:coc_filetype_map = { 'markdown.mdx': 'mdx' }
  34. " use <tab> for trigger completion and navigate to the next complete item
  35. function! s:check_back_space() abort
  36. let col = col('.') - 1
  37. return !col || getline('.')[col - 1] =~ '\s'
  38. endfunction
  39. " Use tab for trigger completion with characters ahead and navigate.
  40. " NOTE: Use command ':verbose imap <tab>' to make sure tab is not mapped by
  41. " other plugin before putting this into your config.
  42. inoremap <silent><expr> <TAB>
  43. \ pumvisible() ? "\<C-n>" :
  44. \ <SID>check_back_space() ? "\<TAB>" :
  45. \ coc#refresh()
  46. inoremap <expr><S-TAB> pumvisible() ? "\<C-p>" : "\<C-h>"