diff options
author | Tom Ryder <tom@sanctum.geek.nz> | 2019-05-25 22:48:27 +1200 |
---|---|---|
committer | Tom Ryder <tom@sanctum.geek.nz> | 2019-05-25 22:48:27 +1200 |
commit | 2d5dd9304a2c372e5519c67d2d600e874fceee1e (patch) | |
tree | d29a1ecda3d665fce94d6cebd959e11106d9a62d /plugin | |
parent | Merge branch 'release/v0.7.0' into develop (diff) | |
download | vim-insert-suspend-hlsearch-2d5dd9304a2c372e5519c67d2d600e874fceee1e.tar.gz vim-insert-suspend-hlsearch-2d5dd9304a2c372e5519c67d2d600e874fceee1e.zip |
Overhaul with autoloading for new version
Diffstat (limited to 'plugin')
-rw-r--r-- | plugin/insert_suspend_hlsearch.vim | 32 |
1 files changed, 5 insertions, 27 deletions
diff --git a/plugin/insert_suspend_hlsearch.vim b/plugin/insert_suspend_hlsearch.vim index 635ed8e..2a88e8a 100644 --- a/plugin/insert_suspend_hlsearch.vim +++ b/plugin/insert_suspend_hlsearch.vim @@ -6,39 +6,17 @@ " Author: Tom Ryder <tom@sanctum.geek.nz> " License: Same as Vim itself " -if exists('loaded_insert_suspend_hlsearch') || &compatible - finish -endif -if !has('autocmd') || !has('extra_search') || v:version < 700 +if exists('loaded_insert_suspend_hlsearch') || &compatible && v:version < 700 finish endif let loaded_insert_suspend_hlsearch = 1 -" Initialise option saving variable -let s:hlsearch_save = &hlsearch - -" Save the current value of the 'hlsearch' option in a script variable, and -" disable it if enabled. Note that :nohlsearch does not work for this; see -" :help autocmd-searchpat. -function! s:Suspend() abort - let s:hlsearch_save = &hlsearch - if &hlsearch - set nohlsearch - endif -endfunction - -" Restore the value of 'hlsearch' from the last time s:HlsearchSuspend was -" called. -function! s:Restore() abort - if !&hlsearch && s:hlsearch_save - set hlsearch - endif -endfunction - " Clear search highlighting as soon as I enter insert mode, and restore it " once left augroup insert_suspend_hlsearch autocmd! - autocmd InsertEnter * call s:Suspend() - autocmd InsertLeave * call s:Restore() + autocmd InsertEnter * + \ call insert_suspend_hlsearch#Suspend() + autocmd InsertLeave * + \ call insert_suspend_hlsearch#Restore() augroup END |