My dotfiles
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.
 
 

153 line
4.7 KiB

  1. " Specify a directory for plugins
  2. " - For Neovim: stdpath('data') . '/plugged'
  3. " - Avoid using standard Vim directory names like 'plugin'
  4. call plug#begin('~/.local/share/nvim/site/plugged')
  5. " Make sure you use single quotes
  6. " Shorthand notation; fetches https://github.com/junegunn/vim-easy-align
  7. Plug 'junegunn/vim-easy-align'
  8. Plug 'ryanoasis/vim-devicons'
  9. Plug 'scrooloose/nerdtree', { 'on': 'NERDTreeToggle' }
  10. Plug 'neoclide/coc.nvim', {'branch': 'release'}
  11. Plug 'mattn/emmet-vim'
  12. Plug 'terryma/vim-multiple-cursors'
  13. Plug 'matze/vim-move'
  14. Plug 'jiangmiao/auto-pairs'
  15. Plug 'prettier/vim-prettier'
  16. Plug 'rhysd/vim-clang-format'
  17. call plug#end()
  18. set encoding=UTF-8
  19. set tabstop=4
  20. set shiftwidth=4
  21. set expandtab
  22. set number
  23. " if hidden is not set, TextEdit might fail.
  24. set hidden
  25. " Some servers have issues with backup files, see #649
  26. set nobackup
  27. set nowritebackup
  28. " Better display for messages
  29. set cmdheight=2
  30. " You will have bad experience for diagnostic messages when it's default 4000.
  31. set updatetime=300
  32. " don't give |ins-completion-menu| messages.
  33. set shortmess+=c
  34. " always show signcolumns
  35. set signcolumn=yes
  36. " Use tab for trigger completion with characters ahead and navigate.
  37. " Use command ':verbose imap <tab>' to make sure tab is not mapped by other plugin.
  38. inoremap <silent><expr> <TAB>
  39. \ pumvisible() ? "\<C-n>" :
  40. \ <SID>check_back_space() ? "\<TAB>" :
  41. \ coc#refresh()
  42. inoremap <expr><S-TAB> pumvisible() ? "\<C-p>" : "\<C-h>"
  43. function! s:check_back_space() abort
  44. let col = col('.') - 1
  45. return !col || getline('.')[col - 1] =~# '\s'
  46. endfunction
  47. " Use <c-space> to trigger completion.
  48. inoremap <silent><expr> <c-space> coc#refresh()
  49. " Use <cr> to confirm completion, `<C-g>u` means break undo chain at current position.
  50. " Coc only does snippet and additional edit on confirm.
  51. inoremap <expr> <cr> pumvisible() ? "\<C-y>" : "\<C-g>u\<CR>"
  52. " Use `[c` and `]c` to navigate diagnostics
  53. nmap <silent> [c <Plug>(coc-diagnostic-prev)
  54. nmap <silent> ]c <Plug>(coc-diagnostic-next)
  55. " Remap keys for gotos
  56. nmap <silent> gd <Plug>(coc-definition)
  57. nmap <silent> gy <Plug>(coc-type-definition)
  58. nmap <silent> gi <Plug>(coc-implementation)
  59. nmap <silent> gr <Plug>(coc-references)
  60. " Use K to show documentation in preview window
  61. nnoremap <silent> K :call <SID>show_documentation()<CR>
  62. function! s:show_documentation()
  63. if (index(['vim','help'], &filetype) >= 0)
  64. execute 'h '.expand('<cword>')
  65. else
  66. call CocAction('doHover')
  67. endif
  68. endfunction
  69. " Highlight symbol under cursor on CursorHold
  70. autocmd CursorHold * silent call CocActionAsync('highlight')
  71. " Remap for rename current word
  72. nmap <leader>rn <Plug>(coc-rename)
  73. " Remap for format selected region
  74. xmap <leader>f <Plug>(coc-format-selected)
  75. nmap <leader>f <Plug>(coc-format-selected)
  76. augroup mygroup
  77. autocmd!
  78. " Setup formatexpr specified filetype(s).
  79. autocmd FileType typescript,json setl formatexpr=CocAction('formatSelected')
  80. " Update signature help on jump placeholder
  81. autocmd User CocJumpPlaceholder call CocActionAsync('showSignatureHelp')
  82. augroup end
  83. " Remap for do codeAction of selected region, ex: `<leader>aap` for current paragraph
  84. xmap <leader>a <Plug>(coc-codeaction-selected)
  85. nmap <leader>a <Plug>(coc-codeaction-selected)
  86. " Remap for do codeAction of current line
  87. nmap <leader>ac <Plug>(coc-codeaction)
  88. " Fix autofix problem of current line
  89. nmap <leader>qf <Plug>(coc-fix-current)
  90. " Use <tab> for select selections ranges, needs server support, like: coc-tsserver, coc-python
  91. nmap <silent> <TAB> <Plug>(coc-range-select)
  92. xmap <silent> <TAB> <Plug>(coc-range-select)
  93. xmap <silent> <S-TAB> <Plug>(coc-range-select-backword)
  94. " Use `:Format` to format current buffer
  95. command! -nargs=0 Format :call CocAction('format')
  96. " Use `:Fold` to fold current buffer
  97. command! -nargs=? Fold :call CocAction('fold', <f-args>)
  98. " use `:OR` for organize import of current buffer
  99. command! -nargs=0 OR :call CocAction('runCommand', 'editor.action.organizeImport')
  100. " Add status line support, for integration with other plugin, checkout `:h coc-status`
  101. set statusline^=%{coc#status()}%{get(b:,'coc_current_function','')}
  102. " Using CocList
  103. " Show all diagnostics
  104. nnoremap <silent> <space>a :<C-u>CocList diagnostics<cr>
  105. " Manage extensions
  106. nnoremap <silent> <space>e :<C-u>CocList extensions<cr>
  107. " Show commands
  108. nnoremap <silent> <space>c :<C-u>CocList commands<cr>
  109. " Find symbol of current document
  110. nnoremap <silent> <space>o :<C-u>CocList outline<cr>
  111. " Search workspace symbols
  112. nnoremap <silent> <space>s :<C-u>CocList -I symbols<cr>
  113. " Do default action for next item.
  114. nnoremap <silent> <space>j :<C-u>CocNext<CR>
  115. " Do default action for previous item.
  116. nnoremap <silent> <space>k :<C-u>CocPrev<CR>
  117. " Resume latest coc list
  118. nnoremap <silent> <space>p :<C-u>CocListResume<CR>