aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2019-05-26 20:26:17 +1200
committerTom Ryder <tom@sanctum.geek.nz>2019-05-26 20:26:17 +1200
commit67fb8a343657a3fd69d645c0cbf53fd8e9fc9984 (patch)
tree2cf447b84d0273ea2d4180a3768c7c3ec5382809
parentMerge branch 'release/v0.3.0' (diff)
parentBump VERSION (diff)
downloadvim-insert-timeout-1.0.0.tar.gz (sig)
vim-insert-timeout-1.0.0.zip
Merge branch 'release/v1.0.0'v1.0.0
* release/v1.0.0: Refactor with autoload
-rw-r--r--VERSION2
-rw-r--r--autoload/insert_timeout.vim14
-rw-r--r--plugin/insert_timeout.vim28
3 files changed, 22 insertions, 22 deletions
diff --git a/VERSION b/VERSION
index 0d91a54..3eefcb9 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-0.3.0
+1.0.0
diff --git a/autoload/insert_timeout.vim b/autoload/insert_timeout.vim
new file mode 100644
index 0000000..5df8b3d
--- /dev/null
+++ b/autoload/insert_timeout.vim
@@ -0,0 +1,14 @@
+" Set update time to configured variable or default 20 seconds
+function! insert_timeout#Enter() abort
+ let s:updatetime = &updatetime
+ let &updatetime = get(g:, 'insert_timeout_duration', 20000)
+endfunction
+
+" Restore update time to its previous value
+function! insert_timeout#Leave() abort
+ if exists('s:updatetime')
+ return
+ endif
+ let &updatetime = s:updatetime
+ unlet s:updatetime
+endfunction
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