jeffreytse / zsh-vi-mode

💻 A better and friendly vi(vim) mode plugin for ZSH.
MIT License
2.96k stars 103 forks source link

Interference between zsh-vi-mode and zsh-syntax-highlighting #154

Open xulongwu4 opened 2 years ago

xulongwu4 commented 2 years ago

General information

Please report the following information as possible as you can:

Basic examination

Problem description

zsh-vi-mode seems to alter the behavior of zsh-syntax-highlighting, and its impact depends on whether zsh-vi-mode is sourced before or after zsh-syntax-highlighting.

Reproduction steps

Firstly, I tried only installing zsh-autosuggestions and zsh-syntax-highlighting, but not installing zsh-vi-mode. I also customized the highlighting rule for shell aliases. My mininum zshrc file is as follows:

alias ls="ls --color=auto"
ZVM_INIT_MODE=sourcing
ZSH_HIGHLIGHT_HIGHLIGHTERS=(main brackets)

source $ZPLUG_HOME/init.zsh

zplug "zsh-users/zsh-autosuggestions"
zplug "zsh-users/zsh-syntax-highlighting", defer:2
#zplug "jeffreytse/zsh-vi-mode", defer:3

zplug load

ZSH_HIGHLIGHT_STYLES[alias]="fg=#88c0d0"

this is the behavior of the syntax highlight:

Peek 2021-12-26 17-49

Now I first tried to source zsh-vi-mode before zsh-syntax-highlighting. My zshrc file is as follows:

alias ls="ls --color=auto"
ZVM_INIT_MODE=sourcing
ZSH_HIGHLIGHT_HIGHLIGHTERS=(main brackets)

source $ZPLUG_HOME/init.zsh

zplug "jeffreytse/zsh-vi-mode"
zplug "zsh-users/zsh-autosuggestions"
zplug "zsh-users/zsh-syntax-highlighting", defer:2

zplug load

ZSH_HIGHLIGHT_STYLES[alias]="fg=#88c0d0"

The behavior of syntax highlighting becomes vi_first

The problem is that, when I typed ls, the test is the suggestion and it is supposed to be in a dimmed color. However, it the gif, test is highlighted as regular text instead of a dimmed color.

Then when I typed cd, test is in dimmed color. However, as soon as I typed the first letter in test, the word test becomes regular text color (white in my case). In the first gif, one can see that if we don't source zsh-vi-mode, cd t should still keep est in dimmed color.

Then I tried source zsh-vi-mode last. My zshrc becomes

alias ls="ls --color=auto"
ZVM_INIT_MODE=sourcing
ZSH_HIGHLIGHT_HIGHLIGHTERS=(main brackets)

source $ZPLUG_HOME/init.zsh

zplug "zsh-users/zsh-autosuggestions"
zplug "zsh-users/zsh-syntax-highlighting", defer:2
zplug "jeffreytse/zsh-vi-mode", defer:3

zplug load

ZSH_HIGHLIGHT_STYLES[alias]="fg=#88c0d0"

Now the behavior of ls<Tab> is shown below. vi_last

ls is a shell alias and is supposed to be in color #88c0d0 (cyan). This is correct before I typed <Tab>. However, when I typed <Tab>, the color of ls becomes some sort of pink color. This change of color with <Tab> does not happen if I do not load zsh-vi-mode at all.

Expected behavior

There should be a way to set up zsh-vi-mode such that it does not interfere with zsh-syntax-highlighting.

jeffreytse commented 2 years ago

Hi @xulongwu4

Thanks for your issue, and sorry for the late reply, currently I'm quite busy, I will research your issue when I am possible. Hope you have a good day! : )

Thanks and Regards

ghost commented 2 years ago

Hello ! I have a similar issue ! I only have zsh-syntax-highlighting and zsh-autosuggestions (+ completions), using no plugin manager. Whenever I add zvm to the mix, no matter the position, no more syntax highlighting at all. ls --color=auto works fine regardless though.

luisbc92 commented 2 years ago

The same thing happens to me. Can't get either to work.

mattiasbonte commented 2 years ago

Same issue for me as well. Using omz to manage plugins.

I love the plugin btw! Thanks for that. The syntax highlighting is not too important, but I do feel like I'm missing it though. Maybe you could guide us into the right direction of where to look for a solution? I understand you are busy.

Update: I installed this plugin instead https://github.com/zdharma-continuum/fast-syntax-highlighting and that seems to work.

Cheers

sidoverflow commented 1 year ago

Replaced zsh-syntax-highlighting with fast-syntax-highlighting to fix the interference with syntax highlighting!

Schievel1 commented 1 year ago

Replaced zsh-syntax-highlighting with fast-syntax-highlighting to fix the interference with syntax highlighting!

Thanks, that seems to work. For me at least.

erikkrieg commented 1 year ago

I've also encountered this issue with the combination of zsh-vi-mode and zsh-syntax-highlighting & zsh-autosuggestions.

Looks like what I'd expect before the command name has been written:

Screen Shot 2023-05-07 at 9 57 55 AM

But once the command name is written the suggestion is not styled as expected:

Screen Shot 2023-05-07 at 9 58 06 AM

Is this issue still on the radar? Are there any hunches about where the problem might be originating from?

rafaVls commented 1 year ago

Update: I installed this plugin instead https://github.com/zdharma-continuum/fast-syntax-highlighting and that seems to work.

Can confirm this worked for me as well

ryanmsnyder commented 1 year ago

Any update on this? I'd rather continue using zsh-syntax-highlighting because my custom theme depends on it. Thanks for the plugin.

jeffreytse commented 1 year ago

Hi @ryanmsnyder,

I'd love to have a check on this issue, as I'm quite busy recently, please be patient, I'll try to fix it as soon as possible.

Thanks & Regards

jeffreytse commented 11 months ago

Hi @xulongwu4

If your issue has been settled down with the HEAD version, let's close this issue.

Thanks & Regards