hnOsmium0001

2020-1-7 .vimrc

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

×