init.vim 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250
  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 'tpope/vim-abolish'
  7. Plug 'bling/vim-airline'
  8. Plug 'mhinz/vim-signify'
  9. Plug 'sjl/gundo.vim'
  10. Plug 'Shougo/denite.nvim'
  11. Plug 'EinfachToll/DidYouMean'
  12. Plug 'diepm/vim-rest-console'
  13. Plug 'idanarye/vim-merginal'
  14. Plug 'vimwiki/vimwiki'
  15. Plug 'vim-scripts/dbext.vim', {'for': 'sql'}
  16. Plug 'cespare/vim-toml'
  17. Plug 'chrisbra/csv.vim'
  18. if executable('lein')
  19. Plug 'guns/vim-sexp'
  20. Plug 'tpope/vim-sexp-mappings-for-regular-people'
  21. Plug 'tpope/vim-fireplace', {'for': 'clojure'}
  22. endif
  23. if executable('sbt')
  24. Plug 'derekwyatt/vim-scala'
  25. endif
  26. if executable('kotlin')
  27. Plug 'udalov/kotlin-vim'
  28. endif
  29. if executable('ansible')
  30. Plug 'pearofducks/ansible-vim'
  31. endif
  32. if executable('rustc')
  33. Plug 'rust-lang/rust.vim'
  34. endif
  35. if executable('npm')
  36. Plug 'pangloss/vim-javascript'
  37. Plug 'mxw/vim-jsx'
  38. endif
  39. if executable('qml')
  40. Plug 'peterhoeg/vim-qml'
  41. endif
  42. Plug 'trusktr/seti.vim'
  43. call plug#end()
  44. " ----- plugin settings ------
  45. let g:signify_vcs_list = [ 'git' ]
  46. let g:jsx_ext_required = 0
  47. let g:airline_left_sep=''
  48. let g:airline_right_sep=''
  49. let g:vimwiki_list = [{'path': '~/.root/home/wiki'}]
  50. let g:vrc_curl_opts = {
  51. \ '-L': '',
  52. \ '-i': '',
  53. \ '-s': '',
  54. \ '-S': ''
  55. \}
  56. call denite#custom#option('_', 'cursor_wrap', 1)
  57. call denite#custom#option('_', 'prompt', '>')
  58. call denite#custom#option('_', 'updatetime', 16)
  59. call denite#custom#map(
  60. \ 'insert',
  61. \ 'jj',
  62. \ '<denite:quit>',
  63. \ 'noremap'
  64. \)
  65. call denite#custom#map(
  66. \ 'insert',
  67. \ '<C-j>',
  68. \ '<denite:move_to_next_line>',
  69. \ 'noremap'
  70. \)
  71. call denite#custom#map(
  72. \ 'insert',
  73. \ '<C-k>',
  74. \ '<denite:move_to_previous_line>',
  75. \ 'noremap'
  76. \)
  77. call denite#custom#map(
  78. \ 'insert',
  79. \ '<C-s>',
  80. \ '<denite:do_action:split>',
  81. \ 'noremap'
  82. \)
  83. call denite#custom#map(
  84. \ 'insert',
  85. \ '<C-v>',
  86. \ '<denite:do_action:vsplit>',
  87. \ 'noremap'
  88. \)
  89. " use rg or ag if present
  90. if executable('rg')
  91. call denite#custom#var('file_rec', 'command',
  92. \ ['rg', '--files', '--glob', '!.git', ''])
  93. call denite#custom#var('grep', 'command', ['rg'])
  94. call denite#custom#var('grep', 'default_opts',
  95. \ ['--vimgrep', '--no-heading'])
  96. call denite#custom#var('grep', 'recursive_opts', [])
  97. call denite#custom#var('grep', 'pattern_opt', ['--regexp'])
  98. call denite#custom#var('grep', 'separator', ['--'])
  99. call denite#custom#var('grep', 'final_opts', [])
  100. elseif executable('ag')
  101. call denite#custom#var('file_rec', 'command',
  102. \ ['ag', '--follow', '--nocolor', '--nogroup', '-g', ''])
  103. call denite#custom#var('grep', 'command', ['ag'])
  104. call denite#custom#var('grep', 'default_opts',
  105. \ ['-i', '--vimgrep'])
  106. call denite#custom#var('grep', 'recursive_opts', [])
  107. call denite#custom#var('grep', 'pattern_opt', [])
  108. call denite#custom#var('grep', 'separator', ['--'])
  109. call denite#custom#var('grep', 'final_opts', [])
  110. endif
  111. " ------ settings ------
  112. " change terminal title
  113. set title
  114. " xdg-ish settings
  115. set undodir=~/.cache/vim/undo,.
  116. set backupdir=~/.cache/vim/backup,.
  117. set directory=~/.cache/vim/swap//,.
  118. " default indentation
  119. set shiftwidth=2
  120. set tabstop=4
  121. set expandtab
  122. " permanent undo history
  123. set undofile
  124. " allow switching buffers
  125. set hidden
  126. " always scroll
  127. set scrolloff=99
  128. " show line numbers
  129. set number
  130. set relativenumber
  131. " set wordwrap indent
  132. set nowrap
  133. set linebreak
  134. if exists("&breakindent")
  135. set breakindent
  136. set breakindentopt=shift:2,sbr
  137. endif
  138. " show whitespace
  139. set list
  140. " make a new copy of the file for backup
  141. " setting to no or auto messes with filewatchers
  142. set backupcopy=yes
  143. " ------ key bindings ------
  144. " ; as :
  145. nnoremap ; :
  146. vnoremap ; :
  147. " allow <ESC> via jj in insert mode
  148. inoremap jj <ESC>
  149. " fix j/k with wraps
  150. nnoremap j gj
  151. nnoremap k gk
  152. vnoremap j gj
  153. vnoremap k gk
  154. " opening unite
  155. nnoremap <C-P> :Denite file_rec<cr>
  156. nnoremap <C-O> :Denite buffer<cr>
  157. imap <C-W> <ESC><C-W>
  158. nnoremap <C-T>h :tabprev<cr>
  159. nnoremap <C-T>l :tabnext<cr>
  160. " grepper
  161. nnoremap <Leader>f :Denite -mode=normal grep:.<CR>
  162. " git
  163. nnoremap <Leader>gs :Gstatus<CR>
  164. nnoremap <Leader>gb :Merginal<CR>
  165. " undo tree
  166. nnoremap <Leader>ut :GundoToggle<CR>
  167. " vimrc
  168. nnoremap <Leader>ve :vsplit $MYVIMRC<CR>
  169. nnoremap <Leader>vs :source $MYVIMRC<CR>
  170. " ------ nvim specific ------
  171. if has('nvim')
  172. set inccommand=split
  173. let g:airline_theme_patch_func = 'AirlineThemePatch'
  174. function! AirlineThemePatch(palette)
  175. let a:palette.terminal = copy(a:palette.insert)
  176. endfunction
  177. let g:terminal_scrollback_buffer_size = 10000
  178. tnoremap <C-j><C-j> <C-\><C-N>
  179. tmap <C-T> <C-\><C-N><C-T>
  180. tmap <C-W> <C-\><C-N><C-W>
  181. tmap <C-P> <C-\><C-N><C-P>
  182. tmap <C-O> <C-\><C-N><C-O>
  183. tnoremap <C-V><C-V><C-V> <C-V><C-V>
  184. tnoremap <C-V><C-V> <C-V>
  185. tnoremap <C-V> <C-\><C-N>"+pi
  186. autocmd BufWinEnter,WinEnter term://* startinsert
  187. autocmd BufLeave term://* stopinsert
  188. nnoremap <Leader>tv :vsp term://zsh<CR>
  189. nnoremap <Leader>to :term<CR>
  190. endif
  191. augroup formatting
  192. au!
  193. " strip trailing whitespace
  194. autocmd BufWritePre * :%s/\s\+$//e
  195. autocmd FileType markdown :set tw=80
  196. augroup end
  197. colorscheme seti
  198. if filereadable(expand('~/.vimrc.local'))
  199. source ~/.vimrc.local
  200. endif