1
0

init.vim 5.2 KB

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