1
0

vimrc 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. " ------ settings ------
  2. " change terminal title
  3. set title
  4. " xdg-ish settings
  5. set undodir=~/.cache/vim/undo,.
  6. set backupdir=~/.cache/vim/backup,.
  7. set directory=~/.cache/vim/swap//,.
  8. " default indentation
  9. set shiftwidth=2
  10. set tabstop=4
  11. set expandtab
  12. " permanent undo history
  13. set undofile
  14. " allow switching buffers
  15. set hidden
  16. " always scroll
  17. set scrolloff=99
  18. " show line numbers
  19. set number
  20. set relativenumber
  21. " show gutter
  22. set signcolumn=yes
  23. " set wordwrap indent
  24. set nowrap
  25. set linebreak
  26. if exists("&breakindent")
  27. set breakindent
  28. set breakindentopt=shift:2,sbr
  29. endif
  30. " show whitespace
  31. set list
  32. " make a new copy of the file for backup
  33. " setting to no or auto messes with filewatchers
  34. set backupcopy=yes
  35. " disable modelines
  36. set nomodeline
  37. " ------ key bindings ------
  38. " ; as :
  39. nnoremap ; :
  40. vnoremap ; :
  41. " allow <ESC> via jj in insert mode
  42. inoremap jj <ESC>
  43. " tab switching
  44. nnoremap <C-T>h :tabprev<cr>
  45. nnoremap <C-T>l :tabnext<cr>
  46. " fix j/k with wraps
  47. nnoremap j gj
  48. nnoremap k gk
  49. vnoremap j gj
  50. vnoremap k gk
  51. " cursor display
  52. nnoremap <Leader>c :set cursorline! cursorcolumn!<CR>
  53. " fzf
  54. nnoremap <C-P> :GitFiles -o -c --exclude-standard<CR>
  55. nnoremap <C-O> :Buffers<CR>
  56. if executable('rg')
  57. nnoremap <Leader>f :Rg<SPACE>
  58. elseif executable('ag')
  59. nnoremap <Leader>f :Ag<SPACE>
  60. endif
  61. " git
  62. nnoremap <Leader>gs :Git<CR>
  63. nnoremap <Leader>gb :Merginal<CR>
  64. " undo tree
  65. nnoremap <Leader>ut :UndotreeToggle<CR>
  66. " vimrc
  67. nnoremap <Leader>ve :vsplit $MYVIMRC<CR>
  68. nnoremap <Leader>vs :source $MYVIMRC<CR>
  69. " ------ nvim specific ------
  70. if has('nvim')
  71. set inccommand=split
  72. tnoremap <C-[><C-[> <C-\><C-N>
  73. autocmd TermOpen * setlocal scrollback=10000 nonumber norelativenumber
  74. autocmd TermOpen * startinsert
  75. autocmd FileType fzf tnoremap <buffer> jj <ESC>
  76. autocmd BufWinEnter,WinEnter term://* startinsert
  77. autocmd BufLeave term://* stopinsert
  78. " fix flickering when clearing terminal
  79. autocmd TermEnter * setlocal scrolloff=0
  80. autocmd TermLeave * setlocal scrolloff=99
  81. nnoremap <Leader>tv :vsp term://$SHELL<CR>
  82. nnoremap <Leader>to :term<CR>
  83. endif
  84. augroup formatting
  85. au!
  86. " strip trailing whitespace
  87. autocmd BufWritePre * :%s/\s\+$//e
  88. autocmd FileType markdown :set tw=80
  89. augroup end
  90. colorscheme seti
  91. " Use unset background so that syntax-highlighted text does not overwrite the
  92. " base color. This might cause problems on white backgrounded terminals but I
  93. " don't use those
  94. highlight Normal ctermbg=NONE
  95. " Add a background for popups and floats to distinguish from regular text
  96. highlight Pmenu ctermbg=235 guibg=#282a2b
  97. highlight link FloatBorder Pmenu
  98. highlight MiniStatuslineModeNormal ctermbg=117 ctermfg=0
  99. highlight MiniStatuslineModeCommand ctermbg=117 ctermfg=0
  100. highlight MiniStatuslineModeInsert ctermbg=119 ctermfg=0
  101. highlight MiniStatuslineModeVisual ctermbg=216 ctermfg=0
  102. highlight MiniStatuslineModeReplace ctermbg=216 ctermfg=0
  103. highlight MiniStatuslineModeOther ctermbg=119 ctermfg=0