aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCamil Staps2020-08-28 20:31:26 +0200
committerCamil Staps2020-08-28 20:31:26 +0200
commite40191cfb65a581851250e06e7c2876ef4ec51eb (patch)
tree945b31d496b7d90142ea42c6fae7e9fe13cf7c15
parentUse new PaperColor color scheme for text files (diff)
Fix git gutter highlights
-rw-r--r--vim/.vimrc23
1 files changed, 17 insertions, 6 deletions
diff --git a/vim/.vimrc b/vim/.vimrc
index 385b4a3..9eb29ee 100644
--- a/vim/.vimrc
+++ b/vim/.vimrc
@@ -44,9 +44,17 @@ Plugin 'NLKNguyen/papercolor-theme'
call vundle#end()
" End Vundle
+function! s:reset_gitgutter_highlights()
+ highlight! link SignColumn LineNr
+ let ctermbg=synIDattr(synIDtrans(hlID('SignColumn')), 'bg', 'cterm')
+ exe 'highlight GitGutterAdd ctermfg=2 ctermbg='.ctermbg
+ exe 'highlight GitGutterChange ctermfg=3 ctermbg='.ctermbg
+ exe 'highlight GitGutterDelete ctermfg=1 ctermbg='.ctermbg
+endfunction
+
" Source some special files on writing
-autocmd! bufwritepost .vimrc source %
-autocmd! bufwritepost .Xresources !xrdb -merge %
+autocmd! BufWritePost .vimrc source % | call s:reset_gitgutter_highlights()
+autocmd! BufWritePost .Xresources !xrdb -merge %
" Common settings
set tabstop=4 shiftwidth=4
@@ -78,10 +86,7 @@ highlight SpellCap cterm=underline,bold ctermfg=black ctermbg=yellow
highlight SpellLocal cterm=underline,bold ctermfg=black ctermbg=blue
highlight SpellRare cterm=underline,bold ctermfg=black ctermbg=white
highlight ColorColumn ctermfg=black ctermbg=yellow
-" Needed for gitgutter. See:
-" - https://github.com/airblade/vim-gitgutter/issues/696
-" - https://stackoverflow.com/a/7383051
-autocmd ColorScheme * highlight! link SignColumn LineNr
+
let network = system("iwconfig wlp2s0 | grep ESSID | cut -d'\"' -f2")
let network = substitute(network, '\n', '', '')
if index(["WiFi in de trein", "Syntus-Utrecht"], network) >= 0
@@ -95,6 +100,12 @@ map <LocalLeader>s :syn sync fromstart<CR>
autocmd BufEnter * colorscheme solarized | set bg=dark
autocmd BufEnter *.txt colorscheme PaperColor | set bg=light
+" Setting the color scheme messes up the git gutter highlight groups, so reset
+" them. For some discussion, see:
+" - https://github.com/airblade/vim-gitgutter/issues/696
+" - https://stackoverflow.com/a/7383051
+autocmd BufEnter * call s:reset_gitgutter_highlights()
+
" Move through long lines as they were short multiple lines
map <down> gj
map <up> gk