diff options
Diffstat (limited to 'plugin/insert_timeout.vim')
-rw-r--r-- | plugin/insert_timeout.vim | 28 |
1 files changed, 7 insertions, 21 deletions
diff --git a/plugin/insert_timeout.vim b/plugin/insert_timeout.vim index 3705df0..80915d3 100644 --- a/plugin/insert_timeout.vim +++ b/plugin/insert_timeout.vim @@ -6,32 +6,18 @@ " Author: Tom Ryder <tom@sanctum.geek.nz> " License: Same as Vim itself " -if exists('loaded_insert_timeout') || &compatible - finish -endif -if !has('autocmd') || v:version < 700 +if exists('loaded_insert_timeout') || &compatible || v:version < 700 finish endif let loaded_insert_timeout = 1 -" Initialise 'updatetime' caching variable -let s:updatetime_save = &updatetime - -" Set update time to configured variable or default 20 seconds -function! s:SetUpdatetime() abort - let s:updatetime_save = &updatetime - let &updatetime = get(g:, 'insert_timeout_duration', 20000) -endfunction - -" Restore update time to globally configured variable -function! s:RestoreUpdatetime() abort - let &updatetime = s:updatetime_save -endfunction - " Set up actions in a group augroup insert_timeout autocmd! - autocmd InsertEnter * call s:SetUpdatetime() - autocmd InsertLeave * call s:RestoreUpdatetime() - autocmd CursorHoldI * stopinsert + autocmd InsertEnter * + \ call insert_timeout#Enter() + autocmd InsertLeave * + \ call insert_timeout#Leave() + autocmd CursorHoldI * + \ stopinsert augroup END |