|
|
|
@ -58,6 +58,10 @@ ZSH_AUTOSUGGEST_ACCEPT_WIDGETS=(
|
|
|
|
|
vi-end-of-line
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
# Widgets that accept the entire suggestion and execute it
|
|
|
|
|
ZSH_AUTOSUGGEST_EXECUTE_WIDGETS=(
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
# Widgets that accept the suggestion as far as the cursor moves
|
|
|
|
|
ZSH_AUTOSUGGEST_PARTIAL_ACCEPT_WIDGETS=(
|
|
|
|
|
forward-word
|
|
|
|
@ -159,6 +163,8 @@ _zsh_autosuggest_bind_widgets() {
|
|
|
|
|
_zsh_autosuggest_bind_widget $widget clear
|
|
|
|
|
elif [ ${ZSH_AUTOSUGGEST_ACCEPT_WIDGETS[(r)$widget]} ]; then
|
|
|
|
|
_zsh_autosuggest_bind_widget $widget accept
|
|
|
|
|
elif [ ${ZSH_AUTOSUGGEST_EXECUTE_WIDGETS[(r)$widget]} ]; then
|
|
|
|
|
_zsh_autosuggest_bind_widget $widget execute
|
|
|
|
|
elif [ ${ZSH_AUTOSUGGEST_PARTIAL_ACCEPT_WIDGETS[(r)$widget]} ]; then
|
|
|
|
|
_zsh_autosuggest_bind_widget $widget partial_accept
|
|
|
|
|
else
|
|
|
|
@ -252,6 +258,19 @@ _zsh_autosuggest_accept() {
|
|
|
|
|
_zsh_autosuggest_invoke_original_widget $@
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Accept the entire suggestion and execute it
|
|
|
|
|
_zsh_autosuggest_execute() {
|
|
|
|
|
# Add the suggestion to the buffer
|
|
|
|
|
BUFFER="$BUFFER$POSTDISPLAY"
|
|
|
|
|
|
|
|
|
|
# Remove the suggestion
|
|
|
|
|
unset POSTDISPLAY
|
|
|
|
|
|
|
|
|
|
# Call the original `accept-line` to handle syntax highlighting or
|
|
|
|
|
# other potential custom behavior
|
|
|
|
|
_zsh_autosuggest_invoke_original_widget "accept-line"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Partially accept the suggestion
|
|
|
|
|
_zsh_autosuggest_partial_accept() {
|
|
|
|
|
# Save the contents of the buffer so we can restore later if needed
|
|
|
|
@ -276,7 +295,7 @@ _zsh_autosuggest_partial_accept() {
|
|
|
|
|
fi
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for action in clear modify accept partial_accept; do
|
|
|
|
|
for action in clear modify accept partial_accept execute; do
|
|
|
|
|
eval "_zsh_autosuggest_widget_$action() {
|
|
|
|
|
_zsh_autosuggest_highlight_reset
|
|
|
|
|
_zsh_autosuggest_$action \$@
|
|
|
|
@ -286,6 +305,7 @@ done
|
|
|
|
|
|
|
|
|
|
zle -N autosuggest-accept _zsh_autosuggest_widget_accept
|
|
|
|
|
zle -N autosuggest-clear _zsh_autosuggest_widget_clear
|
|
|
|
|
zle -N autosuggest-execute _zsh_autosuggest_widget_execute
|
|
|
|
|
|
|
|
|
|
#--------------------------------------------------------------------#
|
|
|
|
|
# Suggestion #
|
|
|
|
|