init.vim 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  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 'mhinz/vim-signify'
  8. Plug 'sjl/gundo.vim'
  9. Plug 'EinfachToll/DidYouMean'
  10. Plug 'idanarye/vim-merginal'
  11. Plug 'junegunn/fzf'
  12. Plug 'junegunn/fzf.vim'
  13. Plug 'itchyny/lightline.vim'
  14. Plug 'trusktr/seti.vim'
  15. if filereadable(expand('~/.vim/local-plugins.vim'))
  16. source ~/.vim/local-plugins.vim
  17. endif
  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. " ------ settings ------
  32. " change terminal title
  33. set title
  34. " xdg-ish settings
  35. set undodir=~/.cache/vim/undo,.
  36. set backupdir=~/.cache/vim/backup,.
  37. set directory=~/.cache/vim/swap//,.
  38. " default indentation
  39. set shiftwidth=2
  40. set tabstop=4
  41. set expandtab
  42. " permanent undo history
  43. set undofile
  44. " allow switching buffers
  45. set hidden
  46. " always scroll
  47. set scrolloff=99
  48. " show line numbers
  49. set number
  50. set relativenumber
  51. " show gutter
  52. set signcolumn=yes
  53. " set wordwrap indent
  54. set nowrap
  55. set linebreak
  56. if exists("&breakindent")
  57. set breakindent
  58. set breakindentopt=shift:2,sbr
  59. endif
  60. " show whitespace
  61. set list
  62. " make a new copy of the file for backup
  63. " setting to no or auto messes with filewatchers
  64. set backupcopy=yes
  65. " disable modelines
  66. set nomodeline
  67. " ------ key bindings ------
  68. " ; as :
  69. nnoremap ; :
  70. vnoremap ; :
  71. " allow <ESC> via jj in insert mode
  72. inoremap jj <ESC>
  73. " tab switching
  74. nnoremap <C-T>h :tabprev<cr>
  75. nnoremap <C-T>l :tabnext<cr>
  76. " fix j/k with wraps
  77. nnoremap j gj
  78. nnoremap k gk
  79. vnoremap j gj
  80. vnoremap k gk
  81. " cursor display
  82. nnoremap <Leader>c :set cursorline! cursorcolumn!<CR>
  83. " fzf
  84. nnoremap <C-P> :GitFiles -o -c --exclude-standard<CR>
  85. nnoremap <C-O> :Buffers<CR>
  86. if executable('rg')
  87. nnoremap <Leader>f :Rg<SPACE>
  88. elseif executable('ag')
  89. nnoremap <Leader>f :Ag<SPACE>
  90. endif
  91. " close buffer
  92. nnoremap <Leader>q :bp<bar>sp<bar>bn<bar>bd<CR>
  93. " git
  94. nnoremap <Leader>gs :Gstatus<CR>
  95. nnoremap <Leader>gb :Merginal<CR>
  96. " undo tree
  97. nnoremap <Leader>ut :GundoToggle<CR>
  98. " vimrc
  99. nnoremap <Leader>ve :vsplit $MYVIMRC<CR>
  100. nnoremap <Leader>vs :source $MYVIMRC<CR>
  101. " ------ nvim specific ------
  102. if has('nvim')
  103. set inccommand=split
  104. tnoremap <C-[><C-[> <C-\><C-N>
  105. autocmd TermOpen * setlocal scrollback=10000 nonumber norelativenumber
  106. autocmd TermOpen * startinsert
  107. autocmd FileType fzf tnoremap <buffer> jj <ESC>
  108. autocmd BufWinEnter,WinEnter term://* startinsert
  109. autocmd BufLeave term://* stopinsert
  110. " fix flickering when clearing terminal
  111. autocmd TermEnter * setlocal scrolloff=0
  112. autocmd TermLeave * setlocal scrolloff=99
  113. nnoremap <Leader>tv :vsp term://$SHELL<CR>
  114. nnoremap <Leader>to :term<CR>
  115. endif
  116. augroup formatting
  117. au!
  118. " strip trailing whitespace
  119. autocmd BufWritePre * :%s/\s\+$//e
  120. autocmd FileType markdown :set tw=80
  121. augroup end
  122. colorscheme seti
  123. if filereadable(expand('~/.vim/local-config.vim'))
  124. source ~/.vim/local-config.vim
  125. endif