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
|
||||
define-command -hidden search-highlight-enable-impl %{
|
||||
# register hook to show highlighting during search
|
||||
hook -group search-highlight window RegisterModified '/' %{
|
||||
# check whether already enabled
|
||||
try %{
|
||||
%opt{search_highlight_status}
|
||||
} catch %{
|
||||
# we only watch the search register in / and reverse / searches
|
||||
hook -group search-highlight window NormalKey (/|<a-/>) %{
|
||||
# register hook to show highlighting during search
|
||||
hook -group search-highlight-impl window RegisterModified '/' %{
|
||||
# check whether already enabled
|
||||
try %{
|
||||
# if the user escapes search, we should immediately clear the highlight
|
||||
# in normal mode so we set the flag before escaping
|
||||
# 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
|
||||
%opt{search_highlight_status}
|
||||
} catch %{
|
||||
try %{
|
||||
%opt{search_highlight_auto_clear}
|
||||
search-highlight-clear
|
||||
} catch %{
|
||||
# check if user escaped search
|
||||
# if the user escapes search, we should immediately clear the highlight
|
||||
# in normal mode so we set the flag before escaping
|
||||
# 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 .* %{
|
||||
# stop watching the search register
|
||||
# (we've left search now)
|
||||
remove-hooks window search-highlight-impl
|
||||
# check if auto clear is set
|
||||
try %{
|
||||
%opt{search_highlight_quit}
|
||||
# if so, clear immediately
|
||||
%opt{search_highlight_auto_clear}
|
||||
search-highlight-clear
|
||||
} catch %{
|
||||
# otherwise, we clear on escape
|
||||
hook -once -group search-highlight window NormalKey <esc> %{
|
||||
# check if user escaped search
|
||||
try %{
|
||||
%opt{search_highlight_quit}
|
||||
# if so, clear immediately
|
||||
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
|
||||
define-command -hidden search-highlight-disable-impl %{
|
||||
remove-hooks window search-highlight
|
||||
remove-hooks window search-highlight(-impl)?
|
||||
}
|
||||
|
||||
## begin public commands
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue