1
0

init.vim 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242
  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. call denite#custom#option('_', 'cursor_wrap', 1)
  50. call denite#custom#option('_', 'prompt', '>')
  51. call denite#custom#option('_', 'updatetime', 16)
  52. call denite#custom#map(
  53. \ 'insert',
  54. \ 'jj',
  55. \ '<denite:quit>',
  56. \ 'noremap'
  57. \)
  58. call denite#custom#map(
  59. \ 'insert',
  60. \ '<C-j>',
  61. \ '<denite:move_to_next_line>',
  62. \ 'noremap'
  63. \)
  64. call denite#custom#map(
  65. \ 'insert',
  66. \ '<C-k>',
  67. \ '<denite:move_to_previous_line>',
  68. \ 'noremap'
  69. \)
  70. call denite#custom#map(
  71. \ 'insert',
  72. \ '<C-s>',
  73. \ '<denite:do_action:split>',
  74. \ 'noremap'
  75. \)
  76. call denite#custom#map(
  77. \ 'insert',
  78. \ '<C-v>',
  79. \ '<denite:do_action:vsplit>',
  80. \ 'noremap'
  81. \)
  82. " use rg or ag if present
  83. if executable('rg')
  84. call denite#custom#var('file_rec', 'command',
  85. \ ['rg', '--files', '--glob', '!.git', ''])
  86. call denite#custom#var('grep', 'command', ['rg'])
  87. call denite#custom#var('grep', 'default_opts',
  88. \ ['--vimgrep', '--no-heading'])
  89. call denite#custom#var('grep', 'recursive_opts', [])
  90. call denite#custom#var('grep', 'pattern_opt', ['--regexp'])
  91. call denite#custom#var('grep', 'separator', ['--'])
  92. call denite#custom#var('grep', 'final_opts', [])
  93. elseif executable('ag')
  94. call denite#custom#var('file_rec', 'command',
  95. \ ['ag', '--follow', '--nocolor', '--nogroup', '-g', ''])
  96. call denite#custom#var('grep', 'command', ['ag'])
  97. call denite#custom#var('grep', 'default_opts',
  98. \ ['-i', '--vimgrep'])
  99. call denite#custom#var('grep', 'recursive_opts', [])
  100. call denite#custom#var('grep', 'pattern_opt', [])
  101. call denite#custom#var('grep', 'separator', ['--'])
  102. call denite#custom#var('grep', 'final_opts', [])
  103. endif
  104. " ------ settings ------
  105. " change terminal title
  106. set title
  107. " xdg-ish settings
  108. set undodir=~/.cache/vim/undo,.
  109. set backupdir=~/.cache/vim/backup,.
  110. set directory=~/.cache/vim/swap//,.
  111. " default indentation
  112. set shiftwidth=2
  113. set tabstop=4
  114. set expandtab
  115. " permanent undo history
  116. set undofile
  117. " allow switching buffers
  118. set hidden
  119. " always scroll
  120. set scrolloff=99
  121. " show line numbers
  122. set number
  123. set relativenumber
  124. " set wordwrap indent
  125. set nowrap
  126. set linebreak
  127. if exists("&breakindent")
  128. set breakindent
  129. set breakindentopt=shift:2,sbr
  130. endif
  131. " show whitespace
  132. set list
  133. " make a new copy of the file for backup
  134. " setting to no or auto messes with filewatchers
  135. set backupcopy=yes
  136. " ------ key bindings ------
  137. " ; as :
  138. nnoremap ; :
  139. vnoremap ; :
  140. " allow <ESC> via jj in insert mode
  141. inoremap jj <ESC>
  142. " fix j/k with wraps
  143. nnoremap j gj
  144. nnoremap k gk
  145. vnoremap j gj
  146. vnoremap k gk
  147. " opening unite
  148. nnoremap <C-P> :Denite file_rec<cr>
  149. nnoremap <C-O> :Denite buffer<cr>
  150. imap <C-W> <ESC><C-W>
  151. nnoremap <C-T>h :tabprev<cr>
  152. nnoremap <C-T>l :tabnext<cr>
  153. " grepper
  154. nnoremap <Leader>f :Denite -mode=normal grep:.<CR>
  155. " git
  156. nnoremap <Leader>gs :Gstatus<CR>
  157. nnoremap <Leader>gb :Merginal<CR>
  158. " undo tree
  159. nnoremap <Leader>ut :GundoToggle<CR>
  160. " vimrc
  161. nnoremap <Leader>ve :vsplit $MYVIMRC<CR>
  162. nnoremap <Leader>vs :source $MYVIMRC<CR>
  163. " ------ nvim specific ------
  164. if has('nvim')
  165. set inccommand=split
  166. let g:airline_theme_patch_func = 'AirlineThemePatch'
  167. function! AirlineThemePatch(palette)
  168. let a:palette.terminal = copy(a:palette.insert)
  169. endfunction
  170. let g:terminal_scrollback_buffer_size = 10000
  171. tnoremap <C-j><C-j> <C-\><C-N>
  172. tmap <C-T> <C-\><C-N><C-T>
  173. tmap <C-W> <C-\><C-N><C-W>
  174. tmap <C-P> <C-\><C-N><C-P>
  175. tmap <C-O> <C-\><C-N><C-O>
  176. tnoremap <C-V><C-V><C-V> <C-V><C-V>
  177. tnoremap <C-V><C-V> <C-V>
  178. tnoremap <C-V> <C-\><C-N>"+pi
  179. autocmd BufWinEnter,WinEnter term://* startinsert
  180. autocmd BufLeave term://* stopinsert
  181. nnoremap <Leader>tv :vsp term://zsh<CR>
  182. nnoremap <Leader>to :term<CR>
  183. endif
  184. augroup formatting
  185. au!
  186. " strip trailing whitespace
  187. autocmd BufWritePre * :%s/\s\+$//e
  188. autocmd FileType markdown :set tw=80
  189. augroup end
  190. colorscheme seti
  191. if filereadable(expand('~/.vimrc.local'))
  192. source ~/.vimrc.local
  193. endif