2016-02-06 06:14:08 +08:00
|
|
|
|
2016-02-14 15:29:43 +08:00
|
|
|
#--------------------------------------------------------------------#
|
|
|
|
# Start #
|
|
|
|
#--------------------------------------------------------------------#
|
2016-02-06 06:14:08 +08:00
|
|
|
|
|
|
|
# Start the autosuggestion widgets
|
2016-02-08 05:21:57 +08:00
|
|
|
_zsh_autosuggest_start() {
|
2017-02-19 01:47:53 +08:00
|
|
|
add-zsh-hook -d precmd _zsh_autosuggest_start
|
|
|
|
|
|
|
|
# Re-bind widgets on every precmd to ensure we wrap other wrappers.
|
|
|
|
# Specifically, highlighting breaks if our widgets are wrapped by
|
|
|
|
# zsh-syntax-highlighting widgets. This also allows modifications
|
|
|
|
# to the widget list variables to take effect on the next precmd.
|
2019-01-12 10:02:55 +08:00
|
|
|
_zsh_autosuggest_bind_autosuggest_widgets
|
|
|
|
add-zsh-hook precmd _zsh_autosuggest_bind_autosuggest_widgets
|
|
|
|
|
|
|
|
# If available, use a ZLE redraw hook to trigger fetching suggestions.
|
|
|
|
# Otherwise, we need to wrap all widgets and fetch suggestions after
|
|
|
|
# running them.
|
|
|
|
if is-at-least 5.4; then
|
|
|
|
add-zle-hook-widget line-pre-redraw autosuggest-redraw
|
|
|
|
else
|
|
|
|
_zsh_autosuggest_bind_modify_widgets
|
|
|
|
add-zsh-hook precmd _zsh_autosuggest_bind_modify_widgets
|
|
|
|
fi
|
2018-12-17 11:43:25 +08:00
|
|
|
|
|
|
|
if [[ -n "${ZSH_AUTOSUGGEST_USE_ASYNC+x}" ]]; then
|
|
|
|
_zsh_autosuggest_async_start
|
|
|
|
fi
|
2016-02-06 06:14:08 +08:00
|
|
|
}
|
2016-02-08 05:21:57 +08:00
|
|
|
|
2017-01-28 06:18:26 +08:00
|
|
|
# Start the autosuggestion widgets on the next precmd
|
2016-02-08 05:21:57 +08:00
|
|
|
add-zsh-hook precmd _zsh_autosuggest_start
|