.vimrc 3.7 KB

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