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.

229 lines
7.6 KiB

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