mirror of
https://github.com/zsh-users/zsh-autosuggestions.git
synced 2024-11-18 09:51:06 +01:00
Add ZSH_AUTOSUGGEST_IGNORE_WIDGETS array
This commit is contained in:
parent
472394681e
commit
25f4afb058
4 changed files with 45 additions and 4 deletions
|
@ -80,6 +80,7 @@ This plugin works by triggering custom behavior when certain [zle widgets](http:
|
||||||
- `ZSH_AUTOSUGGEST_ACCEPT_WIDGETS`: Widgets in this array will accept the suggestion when invoked.
|
- `ZSH_AUTOSUGGEST_ACCEPT_WIDGETS`: Widgets in this array will accept the suggestion when invoked.
|
||||||
- `ZSH_AUTOSUGGEST_EXECUTE_WIDGETS`: Widgets in this array will execute the suggestion when invoked.
|
- `ZSH_AUTOSUGGEST_EXECUTE_WIDGETS`: Widgets in this array will execute the suggestion when invoked.
|
||||||
- `ZSH_AUTOSUGGEST_PARTIAL_ACCEPT_WIDGETS`: Widgets in this array will partially accept the suggestion when invoked.
|
- `ZSH_AUTOSUGGEST_PARTIAL_ACCEPT_WIDGETS`: Widgets in this array will partially accept the suggestion when invoked.
|
||||||
|
- `ZSH_AUTOSUGGEST_IGNORE_WIDGETS`: Widgets in this array will not trigger any custom behavior.
|
||||||
|
|
||||||
Widgets not in any of these lists will update the suggestion when invoked.
|
Widgets not in any of these lists will update the suggestion when invoked.
|
||||||
|
|
||||||
|
|
14
src/bind.zsh
14
src/bind.zsh
|
@ -47,10 +47,20 @@ _zsh_autosuggest_bind_widget() {
|
||||||
|
|
||||||
# Map all configured widgets to the right autosuggest widgets
|
# Map all configured widgets to the right autosuggest widgets
|
||||||
_zsh_autosuggest_bind_widgets() {
|
_zsh_autosuggest_bind_widgets() {
|
||||||
local widget;
|
local widget
|
||||||
|
local ignore_widgets
|
||||||
|
|
||||||
|
ignore_widgets=(
|
||||||
|
.\*
|
||||||
|
_\*
|
||||||
|
zle-line-\*
|
||||||
|
autosuggest-\*
|
||||||
|
$ZSH_AUTOSUGGEST_ORIGINAL_WIDGET_PREFIX\*
|
||||||
|
$ZSH_AUTOSUGGEST_IGNORE_WIDGETS
|
||||||
|
)
|
||||||
|
|
||||||
# Find every widget we might want to bind and bind it appropriately
|
# Find every widget we might want to bind and bind it appropriately
|
||||||
for widget in ${${(f)"$(builtin zle -la)"}:#(.*|_*|orig-*|autosuggest-*|$ZSH_AUTOSUGGEST_ORIGINAL_WIDGET_PREFIX*|zle-line-*|run-help|which-command|beep|set-local-history|yank)}; do
|
for widget in ${${(f)"$(builtin zle -la)"}:#${(j:|:)~ignore_widgets}}; do
|
||||||
if [ ${ZSH_AUTOSUGGEST_CLEAR_WIDGETS[(r)$widget]} ]; then
|
if [ ${ZSH_AUTOSUGGEST_CLEAR_WIDGETS[(r)$widget]} ]; then
|
||||||
_zsh_autosuggest_bind_widget $widget clear
|
_zsh_autosuggest_bind_widget $widget clear
|
||||||
elif [ ${ZSH_AUTOSUGGEST_ACCEPT_WIDGETS[(r)$widget]} ]; then
|
elif [ ${ZSH_AUTOSUGGEST_ACCEPT_WIDGETS[(r)$widget]} ]; then
|
||||||
|
|
|
@ -48,5 +48,15 @@ ZSH_AUTOSUGGEST_PARTIAL_ACCEPT_WIDGETS=(
|
||||||
vi-forward-blank-word-end
|
vi-forward-blank-word-end
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Widgets that should be ignored (globbing supported but must be escaped)
|
||||||
|
ZSH_AUTOSUGGEST_IGNORE_WIDGETS=(
|
||||||
|
orig-\*
|
||||||
|
beep
|
||||||
|
run-help
|
||||||
|
set-local-history
|
||||||
|
which-command
|
||||||
|
yank
|
||||||
|
)
|
||||||
|
|
||||||
# Max size of buffer to trigger autosuggestion. Leave undefined for no upper bound.
|
# Max size of buffer to trigger autosuggestion. Leave undefined for no upper bound.
|
||||||
ZSH_AUTOSUGGEST_BUFFER_MAX_SIZE=
|
ZSH_AUTOSUGGEST_BUFFER_MAX_SIZE=
|
||||||
|
|
|
@ -74,6 +74,16 @@ ZSH_AUTOSUGGEST_PARTIAL_ACCEPT_WIDGETS=(
|
||||||
vi-forward-blank-word-end
|
vi-forward-blank-word-end
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Widgets that should be ignored (globbing supported but must be escaped)
|
||||||
|
ZSH_AUTOSUGGEST_IGNORE_WIDGETS=(
|
||||||
|
orig-\*
|
||||||
|
beep
|
||||||
|
run-help
|
||||||
|
set-local-history
|
||||||
|
which-command
|
||||||
|
yank
|
||||||
|
)
|
||||||
|
|
||||||
# Max size of buffer to trigger autosuggestion. Leave undefined for no upper bound.
|
# Max size of buffer to trigger autosuggestion. Leave undefined for no upper bound.
|
||||||
ZSH_AUTOSUGGEST_BUFFER_MAX_SIZE=
|
ZSH_AUTOSUGGEST_BUFFER_MAX_SIZE=
|
||||||
|
|
||||||
|
@ -161,10 +171,20 @@ _zsh_autosuggest_bind_widget() {
|
||||||
|
|
||||||
# Map all configured widgets to the right autosuggest widgets
|
# Map all configured widgets to the right autosuggest widgets
|
||||||
_zsh_autosuggest_bind_widgets() {
|
_zsh_autosuggest_bind_widgets() {
|
||||||
local widget;
|
local widget
|
||||||
|
local ignore_widgets
|
||||||
|
|
||||||
|
ignore_widgets=(
|
||||||
|
.\*
|
||||||
|
_\*
|
||||||
|
zle-line-\*
|
||||||
|
autosuggest-\*
|
||||||
|
$ZSH_AUTOSUGGEST_ORIGINAL_WIDGET_PREFIX\*
|
||||||
|
$ZSH_AUTOSUGGEST_IGNORE_WIDGETS
|
||||||
|
)
|
||||||
|
|
||||||
# Find every widget we might want to bind and bind it appropriately
|
# Find every widget we might want to bind and bind it appropriately
|
||||||
for widget in ${${(f)"$(builtin zle -la)"}:#(.*|_*|orig-*|autosuggest-*|$ZSH_AUTOSUGGEST_ORIGINAL_WIDGET_PREFIX*|zle-line-*|run-help|which-command|beep|set-local-history|yank)}; do
|
for widget in ${${(f)"$(builtin zle -la)"}:#${(j:|:)~ignore_widgets}}; do
|
||||||
if [ ${ZSH_AUTOSUGGEST_CLEAR_WIDGETS[(r)$widget]} ]; then
|
if [ ${ZSH_AUTOSUGGEST_CLEAR_WIDGETS[(r)$widget]} ]; then
|
||||||
_zsh_autosuggest_bind_widget $widget clear
|
_zsh_autosuggest_bind_widget $widget clear
|
||||||
elif [ ${ZSH_AUTOSUGGEST_ACCEPT_WIDGETS[(r)$widget]} ]; then
|
elif [ ${ZSH_AUTOSUGGEST_ACCEPT_WIDGETS[(r)$widget]} ]; then
|
||||||
|
|
Loading…
Reference in a new issue