From 2d5dd9304a2c372e5519c67d2d600e874fceee1e Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sat, 25 May 2019 22:48:27 +1200 Subject: Overhaul with autoloading for new version --- autoload/insert_suspend_hlsearch.vim | 14 ++++++++++++++ doc/insert_suspend_hlsearch.txt | 13 +++++++------ plugin/insert_suspend_hlsearch.vim | 32 +++++--------------------------- 3 files changed, 26 insertions(+), 33 deletions(-) create mode 100644 autoload/insert_suspend_hlsearch.vim diff --git a/autoload/insert_suspend_hlsearch.vim b/autoload/insert_suspend_hlsearch.vim new file mode 100644 index 0000000..4961ed9 --- /dev/null +++ b/autoload/insert_suspend_hlsearch.vim @@ -0,0 +1,14 @@ +" Save value of 'hlsearch' into a variable, and disable it +function! insert_suspend_hlsearch#Suspend() abort + let s:hlsearch = &hlsearch + let &hlsearch = 0 +endfunction + +" Restore the value of 'hlsearch' if suspended +function! insert_suspend_hlsearch#Restore() abort + if !exists('s:hlsearch') + return + endif + let &hlsearch = s:hlsearch + unlet s:hlsearch +endfunction diff --git a/doc/insert_suspend_hlsearch.txt b/doc/insert_suspend_hlsearch.txt index 56bee0e..304e8e2 100644 --- a/doc/insert_suspend_hlsearch.txt +++ b/doc/insert_suspend_hlsearch.txt @@ -1,15 +1,16 @@ -*insert_suspend_hlsearch.txt* For Vim version 7.0 Last change: 2018 June 17 +*insert_suspend_hlsearch.txt* For Vim version 7.0 Last change: 2019 May 25 DESCRIPTION *insert_suspend_hlsearch* -This plugin quietly disables 'hlsearch' search highlighting if enabled when an -insert operation is started, and puts it back once done, to avoid the -distracting effect the highlighting can cause while writing. +This plugin disables 'hlsearch' search highlighting if enabled when an insert +operation is started, and puts it back once done, to avoid the distracting +effect the highlighting can cause while writing. Its implementation is a +crude workaround for the |:nohlsearch| limitations described in +|autocmd-searchpat|. REQUIREMENTS *insert_suspend_hlsearch-requirements* -This plugin is only available if 'compatible' is not set. It also requires -the |+autocmd| and |+extra_search| features. +This plugin is only available if 'compatible' is not set. AUTHOR *insert_suspend_hlsearch-author* 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 " 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 -- cgit v1.2.3 From dff129a209be7262bfbe021a866d0569d5e65b21 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sat, 25 May 2019 22:49:08 +1200 Subject: Bump VERSION --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index faef31a..3eefcb9 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.7.0 +1.0.0 -- cgit v1.2.3