installation scripts for servers.
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.

220 lines
7.3 KiB

3 years ago
  1. call plug#begin(stdpath('data') . '/plugged')
  2. " The default plugin directory will be as follows:
  3. " - Vim (Linux/macOS): '~/.vim/plugged'
  4. " - Vim (Windows): '~/vimfiles/plugged'
  5. " - Neovim (Linux/macOS/Windows): stdpath('data') . '/plugged'
  6. " You can specify a custom plugin directory by passing it as the argument
  7. " - e.g. `call plug#begin('~/.vim/plugged')`
  8. " - Avoid using standard Vim directory names like 'plugin'
  9. " Make sure you use single quotes
  10. " Shorthand notation; fetches https://github.com/junegunn/vim-easy-align
  11. Plug 'tpope/vim-sensible'
  12. Plug 'vim-airline/vim-airline'
  13. Plug 'vim-airline/vim-airline-themes'
  14. Plug 'Townk/vim-autoclose'
  15. Plug 'neoclide/coc.nvim', {'branch': 'release'}
  16. "let g:airline_powerline_fonts = 1
  17. map j gj
  18. map k gk
  19. " Initialize plugin system
  20. call plug#end()
  21. let g:airline_them ='base16_atelier_heath_light'
  22. set number
  23. set wrap
  24. set linebreak
  25. " use indents of 4 spaces, and have them copied down lines:
  26. set shiftwidth=2
  27. set tabstop=2
  28. set softtabstop=2
  29. set expandtab
  30. set smarttab
  31. set autoindent
  32. set textwidth=80
  33. filetype indent off
  34. " enable filetype detection:
  35. filetype on
  36. autocmd FileType markdown,tex,text set nosmarttab noautoindent
  37. " for C-like programming, have automatic indentation:
  38. autocmd FileType c,cpp,slang set cindent
  39. " * Keystrokes -- Insert Mode
  40. autocmd Filetype python set shiftwidth=4 tabstop=4 softtabstop=4
  41. "Coc Stuff
  42. set encoding=utf-8
  43. " TextEdit might fail if hidden is not set.
  44. set hidden
  45. " Some servers have issues with backup files, see #649.
  46. set nobackup
  47. set nowritebackup
  48. " Give more space for displaying messages.
  49. set cmdheight=2
  50. " Having longer updatetime (default is 4000 ms = 4 s) leads to noticeable
  51. " delays and poor user experience.
  52. set updatetime=300
  53. " Don't pass messages to |ins-completion-menu|.
  54. set shortmess+=c
  55. " Always show the signcolumn, otherwise it would shift the text each time
  56. " diagnostics appear/become resolved.
  57. if has("nvim-0.5.0") || has("patch-8.1.1564")
  58. " Recently vim can merge signcolumn and number column into one
  59. set signcolumn=number
  60. else
  61. set signcolumn=yes
  62. endif
  63. " Use tab for trigger completion with characters ahead and navigate.
  64. " NOTE: Use command ':verbose imap <tab>' to make sure tab is not mapped by
  65. " other plugin before putting this into your config.
  66. inoremap <silent><expr> <TAB>
  67. \ pumvisible() ? "\<C-n>" :
  68. \ <SID>check_back_space() ? "\<TAB>" :
  69. \ coc#refresh()
  70. inoremap <expr><S-TAB> pumvisible() ? "\<C-p>" : "\<C-h>"
  71. function! s:check_back_space() abort
  72. let col = col('.') - 1
  73. return !col || getline('.')[col - 1] =~# '\s'
  74. endfunction
  75. " Use <c-space> to trigger completion.
  76. if has('nvim')
  77. inoremap <silent><expr> <c-space> coc#refresh()
  78. else
  79. inoremap <silent><expr> <c-@> coc#refresh()
  80. endif
  81. " Make <CR> auto-select the first completion item and notify coc.nvim to
  82. " format on enter, <cr> could be remapped by other vim plugin
  83. inoremap <silent><expr> <cr> pumvisible() ? coc#_select_confirm()
  84. \: "\<C-g>u\<CR>\<c-r>=coc#on_enter()\<CR>"
  85. " Use `[g` and `]g` to navigate diagnostics
  86. " Use `:CocDiagnostics` to get all diagnostics of current buffer in location list.
  87. nmap <silent> [g <Plug>(coc-diagnostic-prev)
  88. nmap <silent> ]g <Plug>(coc-diagnostic-next)
  89. " GoTo code navigation.
  90. nmap <silent> gd <Plug>(coc-definition)
  91. nmap <silent> gy <Plug>(coc-type-definition)
  92. nmap <silent> gi <Plug>(coc-implementation)
  93. nmap <silent> gr <Plug>(coc-references)
  94. " Use K to show documentation in preview window.
  95. nnoremap <silent> K :call <SID>show_documentation()<CR>
  96. function! s:show_documentation()
  97. if (index(['vim','help'], &filetype) >= 0)
  98. execute 'h '.expand('<cword>')
  99. elseif (coc#rpc#ready())
  100. call CocActionAsync('doHover')
  101. else
  102. execute '!' . &keywordprg . " " . expand('<cword>')
  103. endif
  104. endfunction
  105. " Highlight the symbol and its references when holding the cursor.
  106. autocmd CursorHold * silent call CocActionAsync('highlight')
  107. " Symbol renaming.
  108. nmap <leader>rn <Plug>(coc-rename)
  109. " Formatting selected code.
  110. xmap <leader>f <Plug>(coc-format-selected)
  111. nmap <leader>f <Plug>(coc-format-selected)
  112. augroup mygroup
  113. autocmd!
  114. " Setup formatexpr specified filetype(s).
  115. autocmd FileType typescript,json setl formatexpr=CocAction('formatSelected')
  116. " Update signature help on jump placeholder.
  117. autocmd User CocJumpPlaceholder call CocActionAsync('showSignatureHelp')
  118. augroup end
  119. " Applying codeAction to the selected region.
  120. " Example: `<leader>aap` for current paragraph
  121. xmap <leader>a <Plug>(coc-codeaction-selected)
  122. nmap <leader>a <Plug>(coc-codeaction-selected)
  123. " Remap keys for applying codeAction to the current buffer.
  124. nmap <leader>ac <Plug>(coc-codeaction)
  125. " Apply AutoFix to problem on the current line.
  126. nmap <leader>qf <Plug>(coc-fix-current)
  127. " Run the Code Lens action on the current line.
  128. nmap <leader>cl <Plug>(coc-codelens-action)
  129. " Map function and class text objects
  130. " NOTE: Requires 'textDocument.documentSymbol' support from the language server.
  131. xmap if <Plug>(coc-funcobj-i)
  132. omap if <Plug>(coc-funcobj-i)
  133. xmap af <Plug>(coc-funcobj-a)
  134. omap af <Plug>(coc-funcobj-a)
  135. xmap ic <Plug>(coc-classobj-i)
  136. omap ic <Plug>(coc-classobj-i)
  137. xmap ac <Plug>(coc-classobj-a)
  138. omap ac <Plug>(coc-classobj-a)
  139. " Remap <C-f> and <C-b> for scroll float windows/popups.
  140. if has('nvim-0.4.0') || has('patch-8.2.0750')
  141. nnoremap <silent><nowait><expr> <C-f> coc#float#has_scroll() ? coc#float#scroll(1) : "\<C-f>"
  142. nnoremap <silent><nowait><expr> <C-b> coc#float#has_scroll() ? coc#float#scroll(0) : "\<C-b>"
  143. inoremap <silent><nowait><expr> <C-f> coc#float#has_scroll() ? "\<c-r>=coc#float#scroll(1)\<cr>" : "\<Right>"
  144. inoremap <silent><nowait><expr> <C-b> coc#float#has_scroll() ? "\<c-r>=coc#float#scroll(0)\<cr>" : "\<Left>"
  145. vnoremap <silent><nowait><expr> <C-f> coc#float#has_scroll() ? coc#float#scroll(1) : "\<C-f>"
  146. vnoremap <silent><nowait><expr> <C-b> coc#float#has_scroll() ? coc#float#scroll(0) : "\<C-b>"
  147. endif
  148. " Use CTRL-S for selections ranges.
  149. " Requires 'textDocument/selectionRange' support of language server.
  150. nmap <silent> <C-s> <Plug>(coc-range-select)
  151. xmap <silent> <C-s> <Plug>(coc-range-select)
  152. " Add `:Format` command to format current buffer.
  153. command! -nargs=0 Format :call CocActionAsync('format')
  154. " Add `:Fold` command to fold current buffer.
  155. command! -nargs=? Fold :call CocAction('fold', <f-args>)
  156. " Add `:OR` command for organize imports of the current buffer.
  157. command! -nargs=0 OR :call CocActionAsync('runCommand', 'editor.action.organizeImport')
  158. " Add (Neo)Vim's native statusline support.
  159. " NOTE: Please see `:h coc-status` for integrations with external plugins that
  160. " provide custom statusline: lightline.vim, vim-airline.
  161. set statusline^=%{coc#status()}%{get(b:,'coc_current_function','')}
  162. " Mappings for CoCList
  163. " Show all diagnostics.
  164. nnoremap <silent><nowait> <space>a :<C-u>CocList diagnostics<cr>
  165. " Manage extensions.
  166. nnoremap <silent><nowait> <space>e :<C-u>CocList extensions<cr>
  167. " Show commands.
  168. nnoremap <silent><nowait> <space>c :<C-u>CocList commands<cr>
  169. " Find symbol of current document.
  170. nnoremap <silent><nowait> <space>o :<C-u>CocList outline<cr>
  171. " Search workspace symbols.
  172. nnoremap <silent><nowait> <space>s :<C-u>CocList -I symbols<cr>
  173. " Do default action for next item.
  174. nnoremap <silent><nowait> <space>j :<C-u>CocNext<CR>
  175. " Do default action for previous item.
  176. nnoremap <silent><nowait> <space>k :<C-u>CocPrev<CR>
  177. " Resume latest coc list.
  178. nnoremap <silent><nowait> <space>p :<C-u>CocListResume<CR>
  179. " END Coc