Cleanup #91
What about having:
# Enable autosuggestions
zle-line-init() {
autosuggest_start
}
zle -N zle-line-init
as
# Enable autosuggestions
autosuggest_start
To avoid such breaking change in the future?
I thought about this, but ultimately decided against it. I believe the original purpose of the more verbose zle-line-init definition was to allow more flexibility in case you wanted to add more plugins or other functions to your zle-line-init. For example:
# Enable autosuggestions
zle-line-init() {
another_thing_start
autosuggest_start
some_other_plugin_start
...
}
zle -N zle-line-init
I'm sorry, branch v0.1.x it seems broken for me…
- I don't get any autosuggestions, without warnings or errors
- The cursor disappears randomly, e.g. if I type "c" it disappears, typing "d" in appears again, with "space" it disappears for a few letters, and so on…
- The highlighting of other plugins is broken (history-substring-search again), however the syntax-highlighting plugin seems to work
BTW, for the zle-line-init, there is a plugin which provides such widgets as hooks: https://github.com/willghatch/zsh-hooks
This allows multiple plugins to extend those widgets.
I don't get any autosuggestions, without warnings or errors
The cursor disappears randomly, e.g. if I type "c" it disappears, typing "d" in appears again, with "space" it disappears for a few letters, and so on…
The highlighting of other plugins is broken (history-substring-search again), however the syntax-highlighting plugin seems to work
Well that's no good.
Can you open a separate issue with more information:
- what does your .zshrc look like?
- what other plugins are you using?
- what version of zsh?
- what operating system?
- a screenshot or gif/movie showing the problem would be great
As far as hooking built-in widgets goes, I did end up moving away from aliasing the dot-prefixed ones. It is a little bit less stable (introduces a possibility of triggering infinite recursion), but there was an issue getting autocompletions to work that was easily fixed by doing so.
I have been using the v0.1.x branch for the last week or so without issue
I have some issues that I reported. It's better but not yet great.
For one, is the zsh-autosuggestions.plugin.zsh used to work and now doesn't. Another issue is reported in #90.
@faceleg No, see my comment, there is too much auto-complete and it's a very frequent use case.
In order to integrate zsh-autosuggestions into Prezto, I have to added the following to modules/autosuggestions/init.zsh.
if zstyle -t ':prezto:module:history-substring-search' loaded; then
ZSH_AUTOSUGGEST_CLEAR_WIDGETS+=(
history-substring-search-up
history-substring-search-down
)
fiIn my testing, I have observed that the if statement is unnecessary because adding those widgets to the array, even when zsh-history-substring-search is not sourced, causes no errors. So, why not add the widgets directly to https://github.com/zsh-users/zsh-autosuggestions/blob/master/src/config.zsh#L15 and excuse the user from having to do it?
why not add the widgets directly
The idea was to avoid as much as possible supporting other plugins inside of this plugin, since it generally leads to bloat in the code. In this case though, I've gone ahead and added those widgets to the default configuration in v0.2.17, since the change is pretty minimal, and like you said, it doesn't cause any errors.
The following should be enough to integrate zsh-autosuggestions into Prezto.
pmodload 'editor'
source "${0:h}/external/zsh-autosuggestions.zsh" || return 1
zstyle -s ':prezto:module:autosuggestions:color' found \
'ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE' || ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE='fg=8'
if ! zstyle -t ':prezto:module:autosuggestions' color; then
ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE=''
fi
if [[ -n "$key_info" ]]; then
bindkey -M viins "$key_info[Control]F" vi-forward-word
bindkey -M viins "$key_info[Control]E" vi-add-eol
fi
Already pulled
ericfreese/zsh-autosuggestions#rewriteinto tarruda repo asv0.1.xbranch so that it is available viaantigen bundle tarruda/zsh-autosuggestions --branch=v0.1.x zsh-autosuggestions.zsh.This PR is for merging v0.1.x into master.
See PR #87 for history.
Fixes/changes:
Deprecations:
Note that installation instructions have changed slightly
Please check out the readme in the v0.1.x branch for more info.
No more
zle-line-init. Just callautosuggest_startsomewhere in your .zshrc after you source the plugin (and after you source zsh-syntax-highlighting, if you are using it):The config variables have changed:
AUTOSUGGESTION_HIGHLIGHT_COLORhas becomeZSH_AUTOSUGGEST_HIGHLIGHT_STYLE, and the other options have been removed.Old configurations will function for now, but will display deprecation warnings.
To use this:
antigen bundle tarruda/zsh-autosuggestions --branch=v0.1.x zsh-autosuggestions.zshOR
git clone -b v0.1.x https://github.com/tarruda/zsh-autosuggestions.git ~/.zsh/zsh-autosuggestionsand source as described in the readme.
TODO
zle autosuggest-startinit andAUTOSUGGESTION_HIGHLIGHT_COLORwork with deprecation warnings.end-of-linewidget should accept the autosuggestion, regardless of where in the buffer the cursor is.Nice-to-haves
forward-characcepts just one character,forward-wordaccepts just one word, etc. (#93)