-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Autosuggestions do not work with zsh-syntax-highlighting #6
Comments
I have added some integration code, can you test it again to verify? |
Also when I move the cursor with |
Ok, those two cases should be fixed now. Can you update and try again? |
Thanks, this works perfect now. |
No. It appears that there are other widgets for moving around that you did not cover. But if I add all these widgets with diff --git a/autosuggestions.zsh b/autosuggestions.zsh
index f650486..1ece5ba 100644
--- a/autosuggestions.zsh
+++ b/autosuggestions.zsh
@@ -37,7 +37,10 @@ accept-and-menu-complete
ZLE_AUTOSUGGEST_ACCEPT_WIDGETS=(
vi-forward-char forward-char vi-forward-word forward-word vi-add-eol
-vi-add-next vi-forward-blank-word
+vi-add-next vi-forward-blank-word end-of-line vi-end-of-line
+vi-forward-blank-word vi-forward-blank-word-end vi-find-next-char
+vi-find-next-char-skip emacs-forward-word vi-forward-word-end vi-goto-column
+vi-goto-mark vi-goto-mark-line vi-repeat-find vi-rev-repeat-find
)
autosuggest-pause() {
@@ -52,7 +55,7 @@ autosuggest-pause() {
zle -A autosuggest-accept-line-orig accept-line
for widget in $ZLE_AUTOSUGGEST_ACCEPT_WIDGETS $ZLE_AUTOSUGGEST_SUSPEND_WIDGETS $ZLE_AUTOSUGGEST_COMPLETION_WIDGETS; do
[[ -z $widgets[$widget] || -z $widgets[autosuggest-${widget}-orig] ]] &&\
- continue
+ continue
eval "zle -A autosuggest-${widget}-orig ${widget}"
done
autosuggest-highlight-suggested-text I have a problem with custom function _-vi-digit-arg ()
{
emulate -L zsh
[[ -z "${NUMERIC}" ]] && NUMERIC=0
[[ -z "$1" ]] && num=0 || num=$(( $1 ))
shift
(( NUMERIC=NUMERIC*10+num )) && $@
}
function _-vi-ctrl-o()
{
emulate -L zsh
local keystr
read -k keystr
local -r keystr
local -ri key=$(( #keystr ))
if (( key==##A )) ; then zle end-of-line
elif (( key==##$ )) ; then zle end-of-line
elif (( key==##I )) ; then zle vi-first-non-blank
elif (( key==##d )) ; then _-vi-delete
elif (( key==##0 )) && [[ -z $NUMERIC ]] ;
then zle beginning-of-line
elif (( key>=##0 && key<=##9 ))
then _-vi-digit-arg $(( key - ##0 )) _-vi-ctrl-o
elif (( key==##s )) ; then zle perlsubstitute
elif (( key==##= )) ; then zle tailfor
else
zle ${${(z)$(bindkey -M vicmd $keystr)}[2]}
fi
} |
Yes, I've read zsh-syntax-highlighting source code and it binds to all widgets, even user-defined one. Unfortunately I cant do that because it would break a lot of editing behavior. Eg: go in normal mode and edit a previous character would 'unmaterialize' whatever is to the right of the cursor(accept-line would kill that part unless the cursor was explicitly moved to the end of the line). The best solution I found to cover most cases is simple:If any of the widgets in ZLE_AUTOSUGGEST_SUSPEND_WIDGETS are executed, autosuggestions is temporarily disabled until a character is inserted at the end of the line. Clearly we need a more generic/better logic to decide when pausing/resuming autosuggestions should happen. I'm gonna try to come up with something this week, but if you have ideas I'm all ears :) |
hello, how can fix this issue for me ? roko__@CLDX [ 18:36:26 ] [ 08/07/14 ] [ pts/3 ] ~ % nano .zshrc |
@tarruda I'm experiencing the same problem :( Have to live on detached HEAD because up-to-date versions of zsh-autosuggestions and zsh-syntax-highlighting don't play well together. Is there any chance you could look into this problem once again, please? |
Not in the foreseeable future, sorry. |
@balta2ar we need someone with time & zsh experience to refactor some of this 🎱 |
Just in case others are struggling with this one while using prezto. If when you submit commands with active auto-suggestions, they loose their highlighting and get confusing with the actual command that was run: (notice, I had typed and submitted The following |
I was struggling with this issue, then I loaded the 'autosuggestions' module after the 'syntax-highlighting' module then both the modules seems to be working fine. I also enabled the coloring for 'autosuggestions' by uncommenting the below line |
@iamsandesh that sounds really good! can you explain where to find this zstyle line? |
@schlichtanders I am updating it in the "~/.zprezto/runcoms/.zpreztorc" file which is present in $HOME folder. The line is already present in the file but commented out, so the line needs to be uncommented and the color has to be specified in that line as it is not already specified. |
I've debugged my _zsh_highlight_call_widget()
{
- builtin zle "$@" && _zsh_highlight
+ # Changed for compatibility with zsh-autosuggestions
+ # Was: builtin zle "$@" && _zsh_highlight
+ builtin zle "$@"
+ _zsh_highlight I think there is no situation when not-highlighting after user action is a good choice. You can test |
It is somewhat expected since both plugins are using the same zle widgets. I guess you need to cooperate and work out some standard that will allow using both plugins.
Fish has both completion and highlighting and it looks nice. I do not like much more limited capabilities of it though.
The text was updated successfully, but these errors were encountered: