aboutsummaryrefslogtreecommitdiff
path: root/autoload/cursorline_current.vim
blob: 648d633cbe0ae6d63a71d204642073fec61fa900 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
" Suspend 'cursorline' when a window is inactive or inserting
function! cursorline_current#Suspend() abort
  let w:cursorline = &l:cursorline
  let &l:cursorline = 0
endfunction

" Restore 'cursorline' when a window is active and non-insert
function! cursorline_current#Restore() abort
  let &l:cursorline = get(w:, 'cursorline', &g:cursorline)
endfunction

" Call cursorline_current#Suspend() on all windows besides the current one
function! cursorline_current#Load() abort
  let wcur = winnr()
  windo if winnr() != wcur | call cursorline_current#Suspend() | endif
  execute wcur . 'wincmd w'
endfunction