aboutsummaryrefslogtreecommitdiff
path: root/autoload/cursorline_current.vim
diff options
context:
space:
mode:
Diffstat (limited to 'autoload/cursorline_current.vim')
-rw-r--r--autoload/cursorline_current.vim17
1 files changed, 17 insertions, 0 deletions
diff --git a/autoload/cursorline_current.vim b/autoload/cursorline_current.vim
new file mode 100644
index 0000000..648d633
--- /dev/null
+++ b/autoload/cursorline_current.vim
@@ -0,0 +1,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