.vimrc 4.7 KB

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