diff options
author | Tom Ryder <tom@sanctum.geek.nz> | 2018-07-12 12:45:42 +1200 |
---|---|---|
committer | Tom Ryder <tom@sanctum.geek.nz> | 2018-07-12 12:45:42 +1200 |
commit | 5e6c6ab6f6dd0bbd6f146a1b37fae7d6edcf5ad9 (patch) | |
tree | 243e7b7cd139bbcd405443a6e4c6d6b51bd2cd43 | |
parent | Merge branch 'release/v0.5.0' into develop (diff) | |
parent | Bump VERSION (diff) | |
download | vim-insert-suspend-hlsearch-5e6c6ab6f6dd0bbd6f146a1b37fae7d6edcf5ad9.tar.gz vim-insert-suspend-hlsearch-5e6c6ab6f6dd0bbd6f146a1b37fae7d6edcf5ad9.zip |
Merge branch 'release/v0.6.0' into develop
* release/v0.6.0:
Bump VERSION
Remove autoload
-rw-r--r-- | VERSION | 2 | ||||
-rw-r--r-- | autoload/insert_suspend_hlsearch.vim | 20 | ||||
-rw-r--r-- | plugin/insert_suspend_hlsearch.vim | 25 |
3 files changed, 24 insertions, 23 deletions
@@ -1 +1 @@ -0.5.0 +0.6.0 diff --git a/autoload/insert_suspend_hlsearch.vim b/autoload/insert_suspend_hlsearch.vim deleted file mode 100644 index 2638abc..0000000 --- a/autoload/insert_suspend_hlsearch.vim +++ /dev/null @@ -1,20 +0,0 @@ -" Initialise option saving variable -let s:hlsearch = &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! insert_suspend_hlsearch#Suspend() abort - let s:hlsearch = &hlsearch - if s:hlsearch - set nohlsearch - endif -endfunction - -" Restore the value of 'hlsearch' from the last time s:HlsearchSuspend was -" called. -function! insert_suspend_hlsearch#Restore() abort - if s:hlsearch - set hlsearch - endif -endfunction diff --git a/plugin/insert_suspend_hlsearch.vim b/plugin/insert_suspend_hlsearch.vim index 5dd1e74..5d199f7 100644 --- a/plugin/insert_suspend_hlsearch.vim +++ b/plugin/insert_suspend_hlsearch.vim @@ -14,10 +14,31 @@ if !has('autocmd') || !has('extra_search') || v:version < 700 endif let g: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 insert_suspend_hlsearch#Suspend() - autocmd InsertLeave * call insert_suspend_hlsearch#Restore() + autocmd InsertEnter * call s:Suspend() + autocmd InsertLeave * call s:Restore() augroup END |