zsh-syntax-highlighting: syntax highlighting not working with zsh 5.9 and zsh-vi-mode
After updating to the latest zsh version. The zsh-syntax-highlighting does not work anymore.
OS: Archlinux
Version: zsh 5.9 (x86_64-pc-linux-gnu)
Related Config:
plugins=(
zsh-autosuggestions
zsh-syntax-highlighting
# vi-mode
zsh-vi-mode
git
# forgit
# sudo
# macos
web-search
# copydir
# copyfile
# copybuffer
dirhistory
colored-man-pages
# vscode
# xcode
)
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 4
- Comments: 27 (11 by maintainers)
Perhaps the following? I don’t have an environment to test it in:
I’m also running zsh 5.9. For me syntax highlighting works fine until I add zsh-vi-mode to the plugins list in my zshrc. (Using oh-my-zsh plugins). Before zsh 5.9 both zsh-syntax-highlighting and zsh-vi-mode worked like a charm together.
I’m using the latest commits for both plugins, and am experiencing the same bug. zsh-syntax-highlighting =
caa749dzsh-vi-mode =9e909d0If I set the zsh-vi-mode option,
ZVM_INIT_MODE='sourcing', then syntax highlighting works again.Hopefully this help debug.
Here is an alternative for
zsh-syntax-highlight. It works fine on my machine.https://github.com/zdharma-continuum/fast-syntax-highlighting
I guess the issue is casued by the deprecated zsh funcitons in version 5.9. There is a compatability section in 5.9 release note.
Thank you very much!! That solved the problem. Now I can use zsh-syntax-highlighting and zsh-vi-mode together without any problem.
This fixes the issue for me too,
It seems to work for me.
@kstolp Thanks a lot.
I’m going to tentatively assume that everyone here uses the zsh-vi-mode plugin. (The third-party plugin linked above; not merely the builtin
bindkey -vfunctionality.) If that’s not the case for anyone, speak up.I suspect the problem has to do with how the zsh-vi-mode plugin’s use of zle-line-pre-redraw, since that widget is used by default by z-sy-h under zsh 5.9 but not (by default) under older zsh’s.
There seem to be several problems with the zsh-vi-mode plugin’s approach:
eval.region_highlight=("0 5 fg=red" "0 5 bold,underline").) It should use thememo=feature of zsh 5.9 to only remove its own entries. (Note that z-sy-h doesn’t use redrawhook on zsh versions that lack thememo=feature precisely in order to avoid breaking other plugins.)The most important of these is (2) which, if I’m reading the zsh-vi-mode plugin’s correctly, causes that plugin to trample on plugins installed prior to itself.
I don’t see anything z-sy-h can do about a plugin that runs after z-sy-h’s init code and arranges for z-sy-h’s
add-zle-hook-widget-registered hook not to be called./cc @jeffreytse
Triage: issue is in another codebase; nothing we can do on our end to fix it or to work around it; patch for the other project has been devised, tested, and PR’d to that project; thus: closing as “nothing further for us to do”. The issue is still reproducible with latest z-sy-h and latest zsh-vi-mode, true; if that affects you, apply the above patch to your copy of zsh-vi-mode.
@fbearoff Thanks for submitting the patch upstream as a PR!
Same issue. Also on Arch. Updated zsh to 5.9 a few hours ago. Not using ohmyzsh or anything. Haven’t changed anything config related. Also using dracula zsh-syntax-highlighting theme