summaryrefslogtreecommitdiff
path: root/dots/zsh/.config/zsh/plugins/zsh-autosuggestions/src/start.zsh
diff options
context:
space:
mode:
Diffstat (limited to 'dots/zsh/.config/zsh/plugins/zsh-autosuggestions/src/start.zsh')
-rw-r--r--dots/zsh/.config/zsh/plugins/zsh-autosuggestions/src/start.zsh33
1 files changed, 33 insertions, 0 deletions
diff --git a/dots/zsh/.config/zsh/plugins/zsh-autosuggestions/src/start.zsh b/dots/zsh/.config/zsh/plugins/zsh-autosuggestions/src/start.zsh
new file mode 100644
index 0000000..5d4ee52
--- /dev/null
+++ b/dots/zsh/.config/zsh/plugins/zsh-autosuggestions/src/start.zsh
@@ -0,0 +1,33 @@
+
+#--------------------------------------------------------------------#
+# Start #
+#--------------------------------------------------------------------#
+
+# Start the autosuggestion widgets
+_zsh_autosuggest_start() {
+ # By default we 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. However this has
+ # a decent performance hit, so users can set ZSH_AUTOSUGGEST_MANUAL_REBIND
+ # to disable the automatic re-binding.
+ if (( ${+ZSH_AUTOSUGGEST_MANUAL_REBIND} )); then
+ add-zsh-hook -d precmd _zsh_autosuggest_start
+ fi
+
+ _zsh_autosuggest_bind_widgets
+}
+
+# Mark for auto-loading the functions that we use
+autoload -Uz add-zsh-hook is-at-least
+
+# Automatically enable asynchronous mode in newer versions of zsh. Disable for
+# older versions because there is a bug when using async mode where ^C does not
+# work immediately after fetching a suggestion.
+# See https://github.com/zsh-users/zsh-autosuggestions/issues/364
+if is-at-least 5.0.8; then
+ typeset -g ZSH_AUTOSUGGEST_USE_ASYNC=
+fi
+
+# Start the autosuggestion widgets on the next precmd
+add-zsh-hook precmd _zsh_autosuggest_start