hnOsmium0001

.vimrc 2020-5-9

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