aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--plugin/cursorline_current.vim17
1 files changed, 13 insertions, 4 deletions
diff --git a/plugin/cursorline_current.vim b/plugin/cursorline_current.vim
index a7704e7..ed590b8 100644
--- a/plugin/cursorline_current.vim
+++ b/plugin/cursorline_current.vim
@@ -11,14 +11,23 @@ if exists('loaded_cursorline_current') || &compatible || v:version < 700
endif
let loaded_cursorline_current = 1
+" Set up hooks
augroup cursorline_current
autocmd!
- autocmd VimEnter *
- \ if winnr('$') > 1 | call cursorline_current#Load() | endif
- autocmd BufEnter *
- \ if winnr('$') > 1 | call cursorline_current#Restore() | endif
+
+ " Toggle local 'cursorline' state to follow window focus
autocmd InsertLeave,WinEnter,FocusGained *
\ call cursorline_current#Restore()
autocmd InsertEnter,WinLeave,FocusLost *
\ call cursorline_current#Suspend()
+
+ " If Vim opens with more than one window, set them up correctly
+ autocmd VimEnter *
+ \ if winnr('$') > 1 | call cursorline_current#Load() | endif
+
+ " Restore the window setting on re-entering a window onto an existing
+ " buffer, if there is more than one buffer
+ autocmd BufEnter *
+ \ if winnr('$') > 1 | call cursorline_current#Restore() | endif
+
augroup END