From 29dff73acb39e9ba52c80103c8f7f6c4e7c7e000 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Wed, 18 Dec 2019 15:28:19 +1300 Subject: Set 'cursorline' for all windows on colors change --- vim/autoload/colorscheme.vim | 10 ++++++++++ vim/vimrc | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 vim/autoload/colorscheme.vim (limited to 'vim') diff --git a/vim/autoload/colorscheme.vim b/vim/autoload/colorscheme.vim new file mode 100644 index 00000000..591550fd --- /dev/null +++ b/vim/autoload/colorscheme.vim @@ -0,0 +1,10 @@ +" Reset window-global value for 'cursorline' based on current colorscheme name +function! colorscheme#UpdateCursorline(colors_name, list) abort + let l:tab = tabpagenr() + let l:win = winnr() + tabdo windo let &g:cursorline = index(a:list, a:colors_name) >= 0 + \| silent doautocmd WinEnter,WinLeave + execute l:tab . 'tabnext' + execute l:win . 'wincmd w' + \| silent doautocmd WinEnter +endfunction diff --git a/vim/vimrc b/vim/vimrc index 9b078c17..3eb1dbbe 100644 --- a/vim/vimrc +++ b/vim/vimrc @@ -887,7 +887,7 @@ endif " " autocmd vimrc ColorScheme * - \ let &cursorline = g:colors_name ==# 'sahara' + \ call colorscheme#UpdateCursorline(g:colors_name, ['sahara']) " Use 'dark' as my default value for 'background', in the absence of an " environment variable COLORFGBG or a response in v:termrbgresp that would set -- cgit v1.2.3