hnOsmium0001

.vimrc 2020-3-24

Mar 24th, 2020
172
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. " ================================================================
  2. " Plugins
  3. " ================================================================
  4.  
  5. call plug#begin('~/.vim/plugged')
  6.  
  7. " Editing Enhancement
  8. Plug 'neoclide/coc.nvim', {'branch': 'release'}
  9. Plug 'liuchengxu/vista.vim'
  10. Plug 'junegunn/vim-easy-align'
  11.  
  12. " GUI Enhancement
  13. Plug 'itchyny/lightline.vim'
  14. Plug 'junegunn/seoul256.vim'
  15.  
  16. Plug 'scrooloose/nerdtree'
  17. Plug 'scrooloose/nerdcommenter'
  18. Plug 'Xuyuanp/nerdtree-git-plugin'
  19. Plug 'Shougo/deol.nvim'
  20. Plug 'SirVer/ultisnips' | Plug 'honza/vim-snippets/'
  21.  
  22. call plug#end()
  23.  
  24.  
  25.  
  26.  
  27. " ================================================================
  28. " # coc.nvim Settings
  29. " ================================================================
  30.  
  31. " if hidden is not set, TextEdit might fail.
  32. set hidden
  33.  
  34. " Some servers have issues with backup files, see #649
  35. set nobackup
  36. set nowritebackup
  37.  
  38. " Better display for messages
  39. set cmdheight=2
  40.  
  41. " You will have bad experience for diagnostic messages when it's default 4000.
  42. set updatetime=300
  43.  
  44. " don't give |ins-completion-menu| messages.
  45. set shortmess+=c
  46.  
  47. " always show signcolumns
  48. set signcolumn=yes
  49.  
  50. " Use tab for trigger completion with characters ahead and navigate.
  51. " Use command ':verbose imap <tab>' to make sure tab is not mapped by other plugin.
  52. inoremap <silent><expr> <TAB>
  53. \ pumvisible() ? "\<C-n>" :
  54. \ <SID>check_back_space() ? "\<TAB>" :
  55. \ coc#refresh()
  56. inoremap <expr><S-TAB> pumvisible() ? "\<C-p>" : "\<C-h>"
  57.  
  58. function! s:check_back_space() abort
  59. let col = col('.') - 1
  60. return !col || getline('.')[col - 1] =~# '\s'
  61. endfunction
  62.  
  63. " Use <c-space> to trigger completion.
  64. inoremap <silent><expr> <c-space> coc#refresh()
  65.  
  66. " Use <cr> to confirm completion, `<C-g>u` means break undo chain at current position.
  67. " Coc only does snippet and additional edit on confirm.
  68. inoremap <expr> <cr> pumvisible() ? "\<C-y>" : "\<C-g>u\<CR>"
  69. " Or use `complete_info` if your vim support it, like:
  70. " inoremap <expr> <cr> complete_info()["selected"] != "-1" ? "\<C-y>" : "\<C-g>u\<CR>"
  71.  
  72. " Use `[g` and `]g` to navigate diagnostics
  73. nmap <silent> [g <Plug>(coc-diagnostic-prev)
  74. nmap <silent> ]g <Plug>(coc-diagnostic-next)
  75.  
  76. " Remap keys for gotos
  77. nmap <silent> gd <Plug>(coc-definition)
  78. nmap <silent> gy <Plug>(coc-type-definition)
  79. nmap <silent> gi <Plug>(coc-implementation)
  80. nmap <silent> gr <Plug>(coc-references)
  81.  
  82. " Use K to show documentation in preview window
  83. nnoremap <silent> K :call <SID>show_documentation()<CR>
  84.  
  85. function! s:show_documentation()
  86. if (index(['vim','help'], &filetype) >= 0)
  87. execute 'h '.expand('<cword>')
  88. else
  89. call CocAction('doHover')
  90. endif
  91. endfunction
  92.  
  93. " Highlight symbol under cursor on CursorHold
  94. autocmd CursorHold * silent call CocActionAsync('highlight')
  95.  
  96. " Remap for rename current word
  97. nmap <leader>rn <Plug>(coc-rename)
  98.  
  99. " Remap for format selected region
  100. xmap <leader>f <Plug>(coc-format-selected)
  101. nmap <leader>f <Plug>(coc-format-selected)
  102.  
  103. augroup mygroup
  104. autocmd!
  105. " Setup formatexpr specified filetype(s).
  106. autocmd FileType typescript,json setl formatexpr=CocAction('formatSelected')
  107. " Update signature help on jump placeholder
  108. autocmd User CocJumpPlaceholder call CocActionAsync('showSignatureHelp')
  109. augroup end
  110.  
  111. " Remap for do codeAction of selected region, ex: `<leader>aap` for current paragraph
  112. xmap <leader>a <Plug>(coc-codeaction-selected)
  113. nmap <leader>a <Plug>(coc-codeaction-selected)
  114.  
  115. " Remap for do codeAction of current line
  116. nmap <leader>ac <Plug>(coc-codeaction)
  117. " Fix autofix problem of current line
  118. nmap <leader>qf <Plug>(coc-fix-current)
  119.  
  120. " Create mappings for function text object, requires document symbols feature of languageserver.
  121. xmap if <Plug>(coc-funcobj-i)
  122. xmap af <Plug>(coc-funcobj-a)
  123. omap if <Plug>(coc-funcobj-i)
  124. omap af <Plug>(coc-funcobj-a)
  125.  
  126. " Use <C-d> for select selections ranges, needs server support, like: coc-tsserver, coc-python
  127. nmap <silent> <C-d> <Plug>(coc-range-select)
  128. xmap <silent> <C-d> <Plug>(coc-range-select)
  129.  
  130. " Use `:Format` to format current buffer
  131. command! -nargs=0 Format :call CocAction('format')
  132.  
  133. " Use `:Fold` to fold current buffer
  134. command! -nargs=? Fold :call CocAction('fold', <f-args>)
  135.  
  136. " use `:OR` for organize import of current buffer
  137. command! -nargs=0 OR :call CocAction('runCommand', 'editor.action.organizeImport')
  138.  
  139. " Add status line support, for integration with other plugin, checkout `:h coc-status`
  140. set statusline^=%{coc#status()}%{get(b:,'coc_current_function','')}
  141.  
  142. " Using CocList
  143. " Show all diagnostics
  144. nnoremap <silent> <space>a :<C-u>CocList diagnostics<cr>
  145. " Manage extensions
  146. nnoremap <silent> <space>e :<C-u>CocList extensions<cr>
  147. " Show commands
  148. nnoremap <silent> <space>c :<C-u>CocList commands<cr>
  149. " Find symbol of current document
  150. nnoremap <silent> <space>o :<C-u>CocList outline<cr>
  151. " Search workspace symbols
  152. nnoremap <silent> <space>s :<C-u>CocList -I symbols<cr>
  153. " Do default action for next item.
  154. nnoremap <silent> <space>j :<C-u>CocNext<CR>
  155. " Do default action for previous item.
  156. nnoremap <silent> <space>k :<C-u>CocPrev<CR>
  157. " Resume latest coc list
  158. nnoremap <silent> <space>p :<C-u>CocListResume<CR>
  159.  
  160. " Comments for json file
  161. autocmd FileType json syntax match Comment +\/\/.\+$+
  162.  
  163.  
  164.  
  165.  
  166. " ================================================================
  167. " # Other Plugin Settigs
  168. " ================================================================
  169.  
  170. " # Settings for lightline.vim
  171. set laststatus=2
  172.  
  173. " # Settings for seoul256.vim
  174. let g:seoul256_background=235
  175. let g:seoul256_srgb=1
  176. colo seoul256
  177.  
  178. " # Settings for UltiSnips
  179. let g:UltiSnipsExpandTrigger="<C-k>"
  180.  
  181.  
  182.  
  183. " ================================================================
  184. " # Regular Vim settings
  185. " ================================================================
  186.  
  187. " Force use xTerm 256 coloring
  188. if !has('gui_running')
  189. set t_Co=256
  190. endif
  191.  
  192. " Visual stuff
  193. set number
  194. set relativenumber
  195. set nowrap
  196.  
  197. " Permanent undo
  198. set undodir=~/.vim/undo
  199. set undofile
  200.  
  201. " Tab configuration
  202. set shiftwidth=2
  203. set softtabstop=2
  204. set tabstop=2
  205. set noexpandtab
  206.  
  207. " Esc to unfocus from Deol.nvim terminal
  208. tnoremap <Esc> <C-\><C-n>
  209.  
  210. " Ctrl+J to switch to normal mode
  211. inoremap <C-j> <Esc>
  212. vnoremap <C-j> <Esc>
  213.  
  214. " Force set language regardless of system language
  215. set langmenu=en_US
  216. let $LANG = 'en_US'
  217. source $VIMRUNTIME/delmenu.vim
  218. source $VIMRUNTIME/menu.vim
  219.  
  220. " Open NerdTree hotkey in the directory of the current open file ('%')
  221. nmap <leader>ne :NERDTree<CR>
  222. nmap <leader>nc :NERDTree %<CR>
  223. " Open deol.nvim terminal hotkey
  224. nmap <leader>to :Deol
  225.  
  226. " Enable mouse mode
  227. set mouse=a
  228.  
  229. " Search visual selection
  230. vnoremap // y/\V<C-R>=escape(@",'/\')<CR><CR>s
  231. " Close all search highlights
  232. nnoremap <leader>noh :noh<CR>
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×