diff options
Diffstat (limited to 'vim/autoload/colorscheme.vim')
-rw-r--r-- | vim/autoload/colorscheme.vim | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/vim/autoload/colorscheme.vim b/vim/autoload/colorscheme.vim index 9ee9f24d..349ee374 100644 --- a/vim/autoload/colorscheme.vim +++ b/vim/autoload/colorscheme.vim @@ -1,8 +1,22 @@ -" Reset colorscheme based on current colorscheme name +" Reset window-global value for 'cursorline' based on current colorscheme name function! colorscheme#UpdateCursorline(colors_name, list) abort - if index(a:list, a:colors_name) >= 0 - set cursorline - else - set nocursorline - endif + + " Record current tab and window number so we can jump back once we're done + let l:tab = tabpagenr() + let l:win = winnr() + + " Set the window-global value for 'cursorline' in each window of each tab; + " on if the current colorscheme is in the whitelist, and off otherwise; fire + " the WinEnter and WinLeave events so any other 'cursorline' related hooks + " can run too + " + let l:cursorline = index(a:list, a:colors_name) >= 0 + tabdo windo let &g:cursorline = l:cursorline + \| silent doautocmd WinEnter,WinLeave + + " Move back to the tab and window the user started in + execute l:tab . 'tabnext' + execute l:win . 'wincmd w' + \| silent doautocmd WinEnter + endfunction |