.vimrc 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  1. call plug#begin('~/.vim/plugged')
  2. Plug 'tpope/vim-sensible'
  3. Plug 'tpope/vim-sleuth'
  4. Plug 'tpope/vim-fugitive'
  5. Plug 'tpope/vim-surround'
  6. Plug 'bling/vim-airline'
  7. Plug 'mhinz/vim-signify'
  8. Plug 'sjl/gundo.vim'
  9. Plug 'Shougo/unite.vim'
  10. Plug 'Shougo/vimproc.vim', {'do' : 'make'}
  11. Plug 'EinfachToll/DidYouMean'
  12. Plug 'diepm/vim-rest-console'
  13. Plug 'idanarye/vim-merginal'
  14. Plug 'vimwiki/vimwiki'
  15. Plug 'vim-scripts/dbext.vim', {'for': 'sql'}
  16. Plug 'cespare/vim-toml'
  17. if executable('lein')
  18. Plug 'guns/vim-sexp'
  19. Plug 'tpope/vim-sexp-mappings-for-regular-people'
  20. Plug 'tpope/vim-fireplace', {'for': 'clojure'}
  21. endif
  22. if executable('sbt')
  23. Plug 'derekwyatt/vim-scala'
  24. endif
  25. if executable('kotlin')
  26. Plug 'udalov/kotlin-vim'
  27. endif
  28. if executable('ansible')
  29. Plug 'pearofducks/ansible-vim'
  30. endif
  31. if executable('rustc')
  32. Plug 'rust-lang/rust.vim'
  33. endif
  34. if executable('npm')
  35. Plug 'pangloss/vim-javascript'
  36. Plug 'mxw/vim-jsx'
  37. endif
  38. if executable('qml')
  39. Plug 'peterhoeg/vim-qml'
  40. endif
  41. Plug 'trusktr/seti.vim'
  42. call plug#end()
  43. " ----- plugin settings ------
  44. let g:signify_vcs_list = [ 'git' ]
  45. let g:jsx_ext_required = 0
  46. let g:unite_enable_auto_select = 0
  47. let g:airline_left_sep=''
  48. let g:airline_right_sep=''
  49. let g:vimwiki_list = [{'path': '~/.root/home/wiki'}]
  50. " use rg or ag if present
  51. if executable('rg')
  52. let g:unite_source_rec_async_command =
  53. \ ['rg', '--follow', '--hidden', '--files']
  54. let g:unite_source_grep_command = 'rg'
  55. let g:unite_source_grep_default_opts = '-i --vimgrep --hidden'
  56. let g:unite_source_grep_recursive_opt = ''
  57. elseif executable('ag')
  58. let g:unite_source_rec_async_command =
  59. \ ['ag', '--follow', '--nocolor', '--nogroup',
  60. \ '--hidden', '-g', '']
  61. let g:unite_source_grep_command = 'ag'
  62. let g:unite_source_grep_default_opts = '-i --vimgrep --hidden'
  63. let g:unite_source_grep_recursive_opt = ''
  64. endif
  65. autocmd FileType unite call s:unite_settings()
  66. function! s:unite_settings()
  67. " Enable navigation with control-j and control-k in insert mode
  68. imap <buffer> <C-j> <Plug>(unite_select_next_line)
  69. imap <buffer> <C-k> <Plug>(unite_select_previous_line)
  70. inoremap <silent><buffer><expr> <C-s> unite#do_action('split')
  71. inoremap <silent><buffer><expr> <C-v> unite#do_action('vsplit')
  72. nnoremap <silent><buffer><expr> s unite#do_action('split')
  73. nnoremap <silent><buffer><expr> v unite#do_action('vsplit')
  74. endfunction
  75. call unite#custom#profile('default', 'context', {
  76. \ 'ignorecase': 1,
  77. \ 'prompt': '> ',
  78. \ 'direction': 'botright',
  79. \ })
  80. " ------ settings ------
  81. " change terminal title
  82. set title
  83. " xdg-ish settings
  84. set undodir=~/.cache/vim/undo,.
  85. set backupdir=~/.cache/vim/backup,.
  86. set directory=~/.cache/vim/swap//,.
  87. " default indentation
  88. set shiftwidth=2
  89. set tabstop=4
  90. set expandtab
  91. " permanent undo history
  92. set undofile
  93. " allow switching buffers
  94. set hidden
  95. " always scroll
  96. set scrolloff=99
  97. " show line numbers
  98. set number
  99. set relativenumber
  100. " set wordwrap indent
  101. set nowrap
  102. set linebreak
  103. if exists("&breakindent")
  104. set breakindent
  105. set breakindentopt=shift:2,sbr
  106. endif
  107. " show whitespace
  108. set list
  109. " make a new copy of the file for backup
  110. " setting to no or auto messes with filewatchers
  111. set backupcopy=yes
  112. " ------ key bindings ------
  113. " ; as :
  114. nnoremap ; :
  115. vnoremap ; :
  116. " allow <ESC> via jj in insert mode
  117. inoremap jj <ESC>
  118. " fix j/k with wraps
  119. nnoremap j gj
  120. nnoremap k gk
  121. vnoremap j gj
  122. vnoremap k gk
  123. " opening unite
  124. nnoremap <C-P> :Unite -buffer-name=files -start-insert file_rec/async<cr>
  125. nnoremap <C-O> :Unite -buffer-name=buffers -start-insert buffer<cr>
  126. imap <C-W> <ESC><C-W>
  127. nnoremap <C-T>h :tabprev<cr>
  128. nnoremap <C-T>l :tabnext<cr>
  129. " grepper
  130. nnoremap <Leader>f :Unite grep:.<CR>
  131. " git
  132. nnoremap <Leader>gs :Gstatus<CR>
  133. nnoremap <Leader>gb :Merginal<CR>
  134. " undo tree
  135. nnoremap <Leader>ut :GundoToggle<CR>
  136. " vimrc
  137. nnoremap <Leader>ve :vsplit $MYVIMRC<CR>
  138. nnoremap <Leader>vs :source $MYVIMRC<CR>
  139. " ------ nvim specific ------
  140. if has('nvim')
  141. set inccommand=split
  142. let g:airline_theme_patch_func = 'AirlineThemePatch'
  143. function! AirlineThemePatch(palette)
  144. let a:palette.terminal = copy(a:palette.insert)
  145. endfunction
  146. let g:terminal_scrollback_buffer_size = 10000
  147. tnoremap <C-j><C-j> <C-\><C-N>
  148. tmap <C-T> <C-\><C-N><C-T>
  149. tmap <C-W> <C-\><C-N><C-W>
  150. tmap <C-P> <C-\><C-N><C-P>
  151. tmap <C-O> <C-\><C-N><C-O>
  152. tnoremap <C-V><C-V><C-V> <C-V><C-V>
  153. tnoremap <C-V><C-V> <C-V>
  154. tnoremap <C-V> <C-\><C-N>"+pi
  155. autocmd BufWinEnter,WinEnter term://* startinsert
  156. nnoremap <Leader>tv :vsp term://zsh<CR>
  157. nnoremap <Leader>to :term<CR>
  158. endif
  159. augroup formatting
  160. au!
  161. " strip trailing whitespace
  162. autocmd BufWritePre * :%s/\s\+$//e
  163. augroup end
  164. colorscheme seti
  165. if filereadable(expand('~/.vimrc.local'))
  166. source ~/.vimrc.local
  167. endif