AutoYADM commit: 2025-07-16 22:30:28
This commit is contained in:
parent
6d29eef438
commit
a8c381e31f
1 changed files with 40 additions and 34 deletions
|
@ -38,48 +38,54 @@ provide-module search-highlight %—
|
||||||
|
|
||||||
# enable the plugin
|
# enable the plugin
|
||||||
define-command -hidden search-highlight-enable-impl %{
|
define-command -hidden search-highlight-enable-impl %{
|
||||||
# register hook to show highlighting during search
|
# we only watch the search register in / and reverse / searches
|
||||||
hook -group search-highlight window RegisterModified '/' %{
|
hook -group search-highlight window NormalKey (/|<a-/>) %{
|
||||||
# check whether already enabled
|
# register hook to show highlighting during search
|
||||||
try %{
|
hook -group search-highlight-impl window RegisterModified '/' %{
|
||||||
%opt{search_highlight_status}
|
# check whether already enabled
|
||||||
} catch %{
|
|
||||||
try %{
|
try %{
|
||||||
# if the user escapes search, we should immediately clear the highlight
|
%opt{search_highlight_status}
|
||||||
# in normal mode so we set the flag before escaping
|
} catch %{
|
||||||
# but only if the option is set
|
|
||||||
%opt{search_highlight_prompt_escape}
|
|
||||||
map window prompt <esc> '<a-;>: set-option window search_highlight_quit true<ret><esc>'
|
|
||||||
}
|
|
||||||
# if not already enabled, add the highlighter
|
|
||||||
add-highlighter window/search-highlight dynregex '%reg{/}' %exp{0:%opt{search_highlight_face}}
|
|
||||||
# update status tracker
|
|
||||||
set-option window search_highlight_status 'search-highlight-on'
|
|
||||||
|
|
||||||
# register hook to clear highlighter after leaving search
|
|
||||||
hook -once -group search-highlight window NormalIdle .* %{
|
|
||||||
# check if auto clear is set
|
|
||||||
try %{
|
try %{
|
||||||
%opt{search_highlight_auto_clear}
|
# if the user escapes search, we should immediately clear the highlight
|
||||||
search-highlight-clear
|
# in normal mode so we set the flag before escaping
|
||||||
} catch %{
|
# but only if the option is set
|
||||||
# check if user escaped search
|
%opt{search_highlight_prompt_escape}
|
||||||
|
map window prompt <esc> '<a-;>: set-option window search_highlight_quit true<ret><esc>'
|
||||||
|
}
|
||||||
|
# if not already enabled, add the highlighter
|
||||||
|
add-highlighter window/search-highlight dynregex '%reg{/}' %exp{0:%opt{search_highlight_face}}
|
||||||
|
# update status tracker
|
||||||
|
set-option window search_highlight_status 'search-highlight-on'
|
||||||
|
|
||||||
|
# register hook to clear highlighter after leaving search
|
||||||
|
hook -once -group search-highlight window NormalIdle .* %{
|
||||||
|
# stop watching the search register
|
||||||
|
# (we've left search now)
|
||||||
|
remove-hooks window search-highlight-impl
|
||||||
|
# check if auto clear is set
|
||||||
try %{
|
try %{
|
||||||
%opt{search_highlight_quit}
|
%opt{search_highlight_auto_clear}
|
||||||
# if so, clear immediately
|
|
||||||
search-highlight-clear
|
search-highlight-clear
|
||||||
} catch %{
|
} catch %{
|
||||||
# otherwise, we clear on escape
|
# check if user escaped search
|
||||||
hook -once -group search-highlight window NormalKey <esc> %{
|
try %{
|
||||||
|
%opt{search_highlight_quit}
|
||||||
|
# if so, clear immediately
|
||||||
search-highlight-clear
|
search-highlight-clear
|
||||||
|
} catch %{
|
||||||
|
# otherwise, we clear on escape
|
||||||
|
hook -once -group search-highlight window NormalKey <esc> %{
|
||||||
|
search-highlight-clear
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
# clear the prompt mapping so it doesn't conflict with
|
||||||
|
# other prompt types
|
||||||
|
unmap window prompt <esc>
|
||||||
|
# reset the quit-early flag
|
||||||
|
set-option window search_highlight_quit false
|
||||||
}
|
}
|
||||||
# clear the prompt mapping so it doesn't conflict with
|
|
||||||
# other prompt types
|
|
||||||
unmap window prompt <esc>
|
|
||||||
# reset the quit-early flag
|
|
||||||
set-option window search_highlight_quit false
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -87,7 +93,7 @@ provide-module search-highlight %—
|
||||||
|
|
||||||
# remove the plugin's hooks
|
# remove the plugin's hooks
|
||||||
define-command -hidden search-highlight-disable-impl %{
|
define-command -hidden search-highlight-disable-impl %{
|
||||||
remove-hooks window search-highlight
|
remove-hooks window search-highlight(-impl)?
|
||||||
}
|
}
|
||||||
|
|
||||||
## begin public commands
|
## begin public commands
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue