diff options
author | Tom Ryder <tom@sanctum.geek.nz> | 2022-06-30 02:18:41 +1200 |
---|---|---|
committer | Tom Ryder <tom@sanctum.geek.nz> | 2022-07-10 22:08:50 +1200 |
commit | 6e12e3c9c578e696d0ddab1025b9de7b6dee416a (patch) | |
tree | c0bd285f6f088bf36f1a95b51b77ad990c053a76 | |
parent | Translate autoload/option/item.vim to vim9script (diff) | |
download | dotfiles-6e12e3c9c578e696d0ddab1025b9de7b6dee416a.tar.gz dotfiles-6e12e3c9c578e696d0ddab1025b9de7b6dee416a.zip |
Translate autoload/colorscheme.vim to vim9script
-rw-r--r-- | vim/autoload/colorscheme.vim | 36 |
1 files changed, 20 insertions, 16 deletions
diff --git a/vim/autoload/colorscheme.vim b/vim/autoload/colorscheme.vim index 349ee374..3769180e 100644 --- a/vim/autoload/colorscheme.vim +++ b/vim/autoload/colorscheme.vim @@ -1,22 +1,26 @@ -" Reset window-global value for 'cursorline' based on current colorscheme name -function! colorscheme#UpdateCursorline(colors_name, list) abort +vim9script - " Record current tab and window number so we can jump back once we're done - let l:tab = tabpagenr() - let l:win = winnr() +var cursorline: bool - " 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 +# Reset window-global value for 'cursorline' based on current colorscheme name +export def UpdateCursorline(colors_name: string, list: list<string>): void + + # Record current tab and window number so we can jump back once we're done + const tab = tabpagenr() + const 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 + # + cursorline = index(list, colors_name) >= 0 + tabdo windo &cursorline = 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' + # Move back to the tab and window the user started in + execute ':' .. tab .. 'tabnext' + execute ':' .. win .. 'wincmd w' \| silent doautocmd WinEnter -endfunction +enddef |