.vimrc 4.2 KB

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