.vimrc 4.3 KB

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