Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

conflict with zsh-autosuggestions & zsh-syntax-highlighting #8

Closed
commiyou opened this issue Sep 9, 2018 · 9 comments
Closed

conflict with zsh-autosuggestions & zsh-syntax-highlighting #8

commiyou opened this issue Sep 9, 2018 · 9 comments

Comments

@commiyou
Copy link

commiyou commented Sep 9, 2018

No description provided.

@softmoth softmoth self-assigned this Sep 13, 2018
@softmoth
Copy link
Owner

Thanks for this bug report! I am not familiar zsh-autosuggestions, but it appears to work OK for me. I tried a .zshrc with just:

source ~/g/zsh-vim-mode/zsh-vim-mode.plugin.zsh
source ~/Downloads/zsh-autosuggestions.zsh

And it seems to work as expected:

Simple test screenshot

Can you please try the latest ZSH version and a simple test .zshrc? And then gradually add back things to your .zshrc until you can identify what causes the problem?

Then please describe the conflict you are getting, exact error message or exact behavior. Please include a screenshot if it would be illuminating.

@softmoth softmoth added the cant reproduce Unable to reproduce, please help label Sep 14, 2018
@softmoth softmoth removed their assignment Sep 14, 2018
@commiyou
Copy link
Author

image

@commiyou commiyou changed the title conflict with zsh-autosuggestions conflict with zsh-autosuggestions & zsh-syntax-highlighting Sep 28, 2018
@CallumHoward
Copy link

CallumHoward commented Oct 1, 2018

Hi, I'm also seeing this with similar configuration to @commiyou. From the screenshot I can deduce @commiyou is using oh-my-zsh to load plugins (so am I).

I have only observed a conflict with zsh-autosuggestions so far.

My .zshrc (with oh-my-zsh installed) is:

plugins=(zsh-vim-mode zsh-syntax-highlighting zsh-autosuggestions)
source $ZSH/oh-my-zsh.sh

After reading this I was inclined to put zsh-autosuggestions after zsh-syntax-highlighting, but I don't think it should affect anything.

My repro is:

  • type a command with multiple words
  • after the first word and spacebar is pressed, autosuggestion remains but dark grey highlighting reverts to default color (white)

I also discovered a workaround, it seems this autosuggestion highlighting issue doesn't happen if I load zsh-vim-mode after the other two plugins like:

plugins=(zsh-syntax-highlighting zsh-autosuggestions zsh-vim-mode)

@CallumHoward
Copy link

I have also noticed that the highlighting on history-search-multi-word plugin is now gone as well.

baodrate added a commit to baodrate/.dotfiles that referenced this issue Nov 27, 2018
diff --git a/zsh/plugins/keybindings.plugin.zsh b/zsh/plugins/keybindings.plugin.zsh
index f6cfc53..2446644 100644
--- a/zsh/plugins/keybindings.plugin.zsh
+++ b/zsh/plugins/keybindings.plugin.zsh
@@ -1,5 +1,8 @@
 typeset -A key

+# Make Vi mode transitions faster (KEYTIMEOUT is in hundredths of a second)
+export KEYTIMEOUT=1
+
 key[Home]=${terminfo[khome]}

 key[End]=${terminfo[kend]}
@@ -34,3 +37,12 @@ bindkey -v
 #             see: softmoth/zsh-vim-mode#8
 # zplugin load softmoth/zsh-vim-mode

+# Beginning search with arrow keys
+autoload -U up-line-or-beginning-search
+autoload -U down-line-or-beginning-search
+zle -N up-line-or-beginning-search
+zle -N down-line-or-beginning-search
+bindkey "^[OA" up-line-or-beginning-search
+bindkey "^[OB" down-line-or-beginning-search
+bindkey -M vicmd "k" up-line-or-beginning-search
+bindkey -M vicmd "j" down-line-or-beginning-search
diff --git a/zsh/zplugins.zsh b/zsh/zplugins.zsh
index fd3702c..bab2b68 100644
--- a/zsh/zplugins.zsh
+++ b/zsh/zplugins.zsh
@@ -22,8 +22,9 @@ zstyle ':completion:*' matcher-list 'm:{a-z}={A-Za-z}'
 # scripts
 # -------
 # ==> prettyping
-zplugin ice as"program" cp"prettyping -> ping" pick"prettyping"
-zplugin snippet https://github.com/denilsonsa/prettyping/raw/master/prettyping
+zplugin ice as"program" pick"prettyping"
+zplugin load "denilsonsa/prettyping"
+alias ping=prettyping

 # ==> httpstat
 zplugin ice as"program" cp"httpstat.sh -> httpstat" pick"httpstat"
@@ -34,18 +35,17 @@ zplugin ice as"program" pick"diff-so-fancy"
 zplugin load "so-fancy/diff-so-fancy"

 # ==> git-now
-zplugin ice wait"2" lucid as"program" pick"$ZPFX/bin/git-now" make"prefix=$ZPFX install"
+zplugin ice as"program" pick"$ZPFX/bin/git-*" make"prefix=$ZPFX"
 zplugin load iwata/git-now

 # ==> git extras
-zplugin ice wait"2" lucid as"program" pick"$ZPFX/bin/git-alias" make"PREFIX=$ZPFX" nocompile
-zplugin load tj/git-extras
-zplugin ice wait"2" lucid pick"etc/git-extras-completion.zsh"
+zplugin ice as"program" make"PREFIX=$ZPFX" pick"$ZPFX/bin/git-*"
 zplugin load tj/git-extras
+source "${ZPLGM[HOME_DIR]}/plugins/tj---git-extras/etc/git-extras-completion.zsh"
+
+# zplugin ice as"program" make"PREFIX=$ZPFX" pick"$ZPFX/bin/git-*"
+# zplugin load tj/git-extras

-# docker-machine-port-forwarder
-zplugin ice as"program" pick"pf"
-zplugin load "johanhaleby/docker-machine-port-forwarder"

 # -------------
 # basic plugins
@@ -102,9 +102,10 @@ export FZF_DEFAULT_OPTS='--preview "[[ $(file --mime {}) =~ binary ]] &&
            echo {} is a binary file ||
            (bat --color=\"always\" {} || cat {}) 2> /dev/null | head -500"'
 export FZF_CTRL_T_COMMAND="$FZF_DEFAULT_COMMAND"
-zplugin snippet "https://raw.githubusercontent.com/junegunn/fzf/master/shell/completion.zsh"
-zplugin snippet "https://raw.githubusercontent.com/junegunn/fzf/master/shell/key-bindings.zsh"
-zplugin ice from"gh-r" as"program"; zplugin load junegunn/fzf-bin
+zplugin ice from"gh-r" as"program"
+zplugin load junegunn/fzf-bin
+zplugin ice multisrc'shell/{completion,key-bindings}.zsh'
+zplugin load junegunn/fzf

 # ==> History Search Multi-Word
 #     set reset-prompt-protect to be able to use zle reset-prompt in your e.g.
@@ -136,6 +137,18 @@ zplugin load "zsh-users/zsh-completions"
 zplugin ice blockf
 zplugin load qubidt/emoji-cli

+# ==> zsh-autosuggestions
+#     Autosuggestions uses precmd hook that is called right after processing
+#     zshrc (before prompt). Turbo Mode will wait 1 second so precmd will be
+#     called earlier than load of the plugin. This makes autosuggestions
+#     inactive at first prompt. But the given atload Ice-mod fixes this, it
+#     calls the same function precmd would, right after loading autosuggestions
+# not working yet, conflicts with history serach
+# see https://github.com/zdharma/zplugin/issues/69
+#   bindkey '^\n' autosuggest-execute
+zplugin ice lucid atload'_zsh_autosuggest_start; bindkey "^ " autosuggest-execute'  # load after fast-syntax-highlighting
+zplugin load zsh-users/zsh-autosuggestions
+
 # ==> Syntax Highlighting
 #     If you load completions using wait'' mode then you can add
 #     atinit'zpcompinit' to syntax-highlighting plugin (which should be the last
@@ -148,18 +161,6 @@ zplugin load qubidt/emoji-cli
 #     ZPLGM[COMPINIT_OPTS]=-C skips compaudit (audit the fpath to assure that it
 #     contains all the directories needed by the completion system, and that
 #     those directories are at least unlikely to contain dangerous files)
-zplugin ice wait"1" lucid atload"zpcompinit; zpcdreplay"
+zplugin ice lucid atload"zpcompinit; zpcdreplay"
 zplugin load "zdharma/fast-syntax-highlighting"

-# ==> zsh-autosuggestions
-#     Autosuggestions uses precmd hook that is called right after processing
-#     zshrc (before prompt). Turbo Mode will wait 1 second so precmd will be
-#     called earlier than load of the plugin. This makes autosuggestions
-#     inactive at first prompt. But the given atload Ice-mod fixes this, it
-#     calls the same function precmd would, right after loading autosuggestions
-# not working yet, conflicts with history serach
-# see https://github.com/zdharma/zplugin/issues/69
-#   bindkey '^\n' autosuggest-execute
-zplugin ice wait'0' lucid atload'_zsh_autosuggest_start; bindkey "^ " autosuggest-execute'  # load after fast-syntax-highlighting
-zplugin load zsh-users/zsh-autosuggestions
-
diff --git a/zsh/zshrc b/zsh/zshrc
index 40037b7..7a78e55 100644
--- a/zsh/zshrc
+++ b/zsh/zshrc
@@ -63,8 +63,6 @@ fi
 # ------------
 # ==> correct commands
 setopt CORRECT
-# ==> Make Vi mode transitions faster (KEYTIMEOUT is in hundredths of a second)
-export KEYTIMEOUT=1

 # ==> General settings
 #     from zim:modules/environment
@gzrjzcx
Copy link

gzrjzcx commented Dec 31, 2018

same as me
how to solve these conflicts?

@softmoth softmoth removed the cant reproduce Unable to reproduce, please help label Feb 3, 2019
@softmoth
Copy link
Owner

softmoth commented Feb 3, 2019

I'm sorry for the long delay on fixing this. It looks like it is a conflict between the newish (zsh 5.3) add-zle-hook-widget that I'm using, vs. the old method of modifying ${widgets} directly. I've narrowed it down to the line add-zle-hook-widget line-pre-redraw vim-mode-line-pre-redraw. If that's removed, the conflicts go away (and all of vim-mode's tracking of the input mode is gone, of course).

But even setting that hook to vim-mode-line-pre-redraw () { true } causes the problem. So it's not the content of the hook, but its existence, that causes the problem. The funny thing is, neither zsh-autosuggestions nor zsh-syntax-highlighting mention redraw at all. So I have some more digging to do to find out how to work around this.

If you don't care about zsh-vim-mode's MODE_CURSOR_* or MODE_INDICATOR_* features, then commenting out line-pre-redraw here is a quick workaround for now.

@softmoth
Copy link
Owner

softmoth commented Feb 3, 2019

I should mention that ordering the plugins like this seems to work fully:

export ZSH=~/.oh-my-zsh
plugins=(
    history-search-multi-word
    zsh-autosuggestions
    zsh-syntax-highlighting
    zsh-vim-mode
)
source $ZSH/oh-my-zsh.sh
bindkey "^R" history-search-multi-word

@laggardkernel
Copy link

laggardkernel commented Jul 21, 2019

I got the same requirement of loading sequence as above after trial and error. But when I enable another plugin adding line-finish widget (before syntax-highlighting) with add-zle-hook-widget, the shell close at once after I press Enter. It seems that both zsh-syntax-highlighting and fast-syntax-highlighting have problem dealing with the add-zle-hook-widget method.

I guess we need to make sure all widgets enabled by add-zle-hook-widget should be added after syntax-highlighting?

laggardkernel added a commit to laggardkernel/spacezsh-prompt that referenced this issue Jul 21, 2019
1. Separate widgets into files.
2. Load ZLE widget with `add-zle-hook-widget`, which make it possible
   multiple widgets work at the same work without wrapping each other.

Using `add-zle-hook-widget` has one problem. Current highlighting
pluings `zsh-syntax-highlighting` and `fast-syntax-highlighting` are
not compatible with this method. Make sure widgets enabled by
`add-zle-hook-widget` are loaded after these highlighting pluigns.

Related issue: softmoth/zsh-vim-mode#8
laggardkernel added a commit to laggardkernel/spacezsh-prompt that referenced this issue Oct 9, 2019
1. Separate widgets into files.
2. Load ZLE widget with `add-zle-hook-widget`, which make it possible
   multiple widgets work at the same work without wrapping each other.

Using `add-zle-hook-widget` has one problem. Current highlighting
pluings `zsh-syntax-highlighting` and `fast-syntax-highlighting` are
not compatible with this method. Make sure widgets enabled by
`add-zle-hook-widget` are loaded after these highlighting pluigns.

Related issue: softmoth/zsh-vim-mode#8
@CallumHoward
Copy link

Seems to be all resolved for me! Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants