aboutsummaryrefslogtreecommitdiff
path: root/vim
diff options
context:
space:
mode:
authorCamil Staps2021-06-12 13:59:25 +0200
committerCamil Staps2021-06-12 13:59:25 +0200
commit92972d513a9886d7b70ab5e02e555cefab5b936e (patch)
tree8ae8f8cca76ac933af6c7c72f3c5218ac9e4b992 /vim
parentAdd AutomaticBackground{En,Dis}able commands to vim (diff)
Fix set_terminal_line_border for neovim
Diffstat (limited to 'vim')
-rw-r--r--vim/.vimrc22
1 files changed, 15 insertions, 7 deletions
diff --git a/vim/.vimrc b/vim/.vimrc
index e333fd9..ceef212 100644
--- a/vim/.vimrc
+++ b/vim/.vimrc
@@ -87,10 +87,18 @@ highlight ColorColumn ctermfg=black ctermbg=yellow
" 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()
+function! s:set_terminal_line_border(color)
+ if has('nvim')
+ call chansend(v:stderr, "\033]708;#".a:color."\007")
+ else
+ silent execute ':!echo -e "\033]708;\#'.a:color.'\007"'
+ endif
+endfunction
+
+function! s:detect_terminal_line_border()
let bg=synIDattr(synIDtrans(hlID('Normal')), 'bg', 'cterm')
if bg == '255'
- silent execute ':!echo -e "\033]708;\#eeeeee\007"'
+ call s:set_terminal_line_border('eeeeee')
else
if bg != '234'
echohl WarningMsg
@@ -98,12 +106,12 @@ function! s:set_terminal_line_border()
echohl None
call getchar()
endif
- silent execute ':!echo -e "\033]708;\#1c1c1c\007"'
+ call s:set_terminal_line_border('1c1c1c')
endif
endfunction
-autocmd VimEnter,ColorScheme * call s:set_terminal_line_border()
+autocmd VimEnter,ColorScheme * call s:detect_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"'
+autocmd VimLeave * call s:set_terminal_line_border('002b36')
let network = system("iwconfig wlp2s0 | grep ESSID | cut -d'\"' -f2")
let network = substitute(network, '\n', '', '')
@@ -117,8 +125,8 @@ map <LocalLeader>s :syn sync fromstart<CR>
function s:enable_automatic_background()
augroup bg
- autocmd bg BufEnter * set bg=dark | call s:set_terminal_line_border()
- autocmd bg BufEnter *.bib,*.md,*.tex,*.txt set bg=light | call s:set_terminal_line_border()
+ autocmd bg BufEnter * set bg=dark | call s:detect_terminal_line_border()
+ autocmd bg BufEnter *.bib,*.md,*.tex,*.txt set bg=light | call s:detect_terminal_line_border()
augroup END
endfunction