init.vim 5.0 KB

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