From 4ca7a4c1ae35a4f55dd10e48802b5e9cdd93dedb Mon Sep 17 00:00:00 2001 From: Camil Staps Date: Thu, 1 Oct 2020 12:02:58 +0200 Subject: Vim: set line border color correctly --- vim/.vimrc | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'vim') diff --git a/vim/.vimrc b/vim/.vimrc index 72f0dd6..b373cf8 100644 --- a/vim/.vimrc +++ b/vim/.vimrc @@ -87,6 +87,29 @@ highlight SpellLocal cterm=underline,bold ctermfg=black ctermbg=blue highlight SpellRare cterm=underline,bold ctermfg=black ctermbg=white highlight ColorColumn ctermfg=black ctermbg=yellow +" The terminal background (set in .Xresources) is the background for that part +" of the terminal where characters can be placed. The padding at the bottom +" and right side are the line border (color 708 in .Xresources). This is not +" colored by Vim by default. When the color scheme is changed, we check the +" current background color and update the line border of the terminal. +function! s:set_terminal_line_border() + let bg=synIDattr(synIDtrans(hlID('Normal')), 'bg', 'cterm') + if bg == '255' + silent execute ':!echo -e "\033]708;\#eeeeee\007"' + else + if bg != '234' + echohl WarningMsg + echo 'Vim background was set to '.bg.', which is unknown; resetting terminal lineBorder to default...' + echohl None + call getchar() + endif + silent execute ':!echo -e "\033]708;\#1c1c1c\007"' + endif +endfunction +autocmd ColorScheme * call s:set_terminal_line_border() +" When we leave vim we restore the value set also in .Xresources +autocmd VimLeave * silent execute ':!echo -e "\033]708;\#002b36\007"' + 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 -- cgit v1.2.3