init.vim 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  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 'itchyny/lightline.vim'
  8. Plug 'mhinz/vim-signify'
  9. Plug 'sjl/gundo.vim'
  10. Plug 'EinfachToll/DidYouMean'
  11. Plug 'idanarye/vim-merginal'
  12. Plug 'junegunn/fzf'
  13. Plug 'junegunn/fzf.vim'
  14. if filereadable(expand('~/.vim/local-plugins.vim'))
  15. source ~/.vim/local-plugins.vim
  16. endif
  17. Plug 'trusktr/seti.vim'
  18. call plug#end()
  19. " ----- plugin settings ------
  20. let g:signify_vcs_list = [ 'git' ]
  21. let g:lightline = {
  22. \ 'colorscheme': 'wombat',
  23. \ 'active': {
  24. \ 'left': [ [ 'mode', 'paste' ],
  25. \ [ 'gitbranch', 'readonly', 'filename', 'modified' ] ]
  26. \ },
  27. \ 'component_function': {
  28. \ 'gitbranch': 'fugitive#head'
  29. \ },
  30. \ }
  31. autocmd FileType fzf setlocal nonumber norelativenumber
  32. autocmd FileType fzf tnoremap <buffer> jj <Esc>
  33. " ------ settings ------
  34. " change terminal title
  35. set title
  36. " xdg-ish settings
  37. set undodir=~/.cache/vim/undo,.
  38. set backupdir=~/.cache/vim/backup,.
  39. set directory=~/.cache/vim/swap//,.
  40. " default indentation
  41. set shiftwidth=2
  42. set tabstop=4
  43. set expandtab
  44. " permanent undo history
  45. set undofile
  46. " allow switching buffers
  47. set hidden
  48. " always scroll
  49. set scrolloff=99
  50. " show line numbers
  51. set number
  52. set relativenumber
  53. " show gutter
  54. set signcolumn=yes
  55. " set wordwrap indent
  56. set nowrap
  57. set linebreak
  58. if exists("&breakindent")
  59. set breakindent
  60. set breakindentopt=shift:2,sbr
  61. endif
  62. " show whitespace
  63. set list
  64. " make a new copy of the file for backup
  65. " setting to no or auto messes with filewatchers
  66. set backupcopy=yes
  67. " ------ key bindings ------
  68. " ; as :
  69. nnoremap ; :
  70. vnoremap ; :
  71. " allow <ESC> via jj in insert mode
  72. inoremap jj <ESC>
  73. " fix j/k with wraps
  74. nnoremap j gj
  75. nnoremap k gk
  76. vnoremap j gj
  77. vnoremap k gk
  78. " opening unite
  79. nnoremap <C-P> :GFiles<cr>
  80. nnoremap <C-O> :Buffers<cr>
  81. imap <C-W> <ESC><C-W>
  82. nnoremap <C-T>h :tabprev<cr>
  83. nnoremap <C-T>l :tabnext<cr>
  84. " grepper
  85. nnoremap <Leader>f :Rg
  86. " git
  87. nnoremap <Leader>gs :Gstatus<CR>
  88. nnoremap <Leader>gb :Merginal<CR>
  89. " undo tree
  90. nnoremap <Leader>ut :GundoToggle<CR>
  91. " vimrc
  92. nnoremap <Leader>ve :vsplit $MYVIMRC<CR>
  93. nnoremap <Leader>vs :source $MYVIMRC<CR>
  94. " ------ nvim specific ------
  95. if has('nvim')
  96. set inccommand=split
  97. tnoremap <C-[><C-[> <C-\><C-N>
  98. autocmd TermOpen term://* startinsert
  99. autocmd BufWinEnter,WinEnter term://* startinsert
  100. autocmd BufLeave term://* stopinsert
  101. nnoremap <Leader>tv :vsp term://zsh<CR>
  102. nnoremap <Leader>to :term<CR>
  103. endif
  104. augroup formatting
  105. au!
  106. " strip trailing whitespace
  107. autocmd BufWritePre * :%s/\s\+$//e
  108. autocmd FileType markdown :set tw=80
  109. augroup end
  110. colorscheme seti
  111. if filereadable(expand('~/.vim/local-config.vim'))
  112. source ~/.vim/local-config.vim
  113. endif