init.vim 6.1 KB

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