.vimrc 4.2 KB

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