1
0

.vimrc 4.2 KB

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