Debian Rice Scripts
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.

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