Zsh-autocomplete: Provide a way to customize all the key bindings

Created on 28 Jul 2020  路  22Comments  路  Source: marlonrichert/zsh-autocomplete

Is your feature request related to a problem? Please describe.

The default set of key bindings are fine for most users and provide a good out-of-the-box experience, but some users have very customized setups, into which these don't fit.

Describe the solution you'd like

  • Provide a setting to disable automatic keybindings.
  • Add a list of all the widgets that zsh-autocomplete provides to the Readme.

Describe alternatives you've considered

  • Make the whole system modular, but that's much harder to do. Doing the above will be a good step in the right direction.
  • Add a section to the Readme on how to set up a custom hook in which you define key bindings, but that's rather non-standard.
  • Allow the user to define key bindings through zstyle, but again, that's rather non-standard.

Additional context

See https://www.reddit.com/r/zsh/comments/gwp58m/zshautocomplete_goes_asynchronous_nonblocking/fzi221g?utm_source=share&utm_medium=web2x

Feature request

All 22 comments

Thanks for making this! (I'm the reddit user that requested the feature). I would have made an issue for it but my understanding of zsh is sort of lacking with regards to being able to describe how to achieve this.

Provide a setting to disable automatic keybindings.

Alternatively, you might simply provide a choice of two files to source in your .zshrc, one which includes default keybinds, and one that doesn't. E.g. consider this scheme:

source zsh-autocomplete.plugin.zsh - binds default keys to widgets (as it currently does)
source zsh-autocomplete.nobindkey.plugin.zsh - only provides the widgets

zsh-autocomplete.plugin.zsh may then be a simple wrapper which contains all your default bindkeys to your widgets and then sources zsh-autcomplete.nobindkey.plugin.zsh, which implements the core functionality and defines the widgets.

I personally prefer sourcing the file I need over any funky configuration. No need to worry whether to put my settings before or after sourcing the plugin and no need for you to implement any additional logic at all.

@slavistan Sometime in the future, I鈥檓 planning to split the plugin up into separate files, so you can source only what you need. However, that鈥檚 a bit more work; I鈥檓 not going to do that at this point.

I personally prefer sourcing the file I need over any funky configuration. No need to worry whether to put my settings before or after sourcing the plugin and no need for you to implement any additional logic at all.

@slavistan It currently doesn't matter whether you declare your settings before or after you source zsh-autocomplete. Both should work, as long as you do it in your .zshrc file. But declaring them on the command line won't. 馃檪

Hm, on closer inspection, this is going to be quite a bit more complex than I thought. There's a significant amount of logic that makes widgets on demand. Perhaps I'll first implement #65 after all.

@Oasixer @slavistan I pushed in a major rewrite with comprehensive documentation on the dev branch. Please try it out and let me know what you think.

Hi @marlonrichert, unfortunately the commit '1eb79b6[...] Modularize the software architecture' seems to break the plugin for me, resulting in the following output as soon as the user starts typing (triggering the plugin):

_autocomplete.main_complete:322: command not found: _autocomplete.extras autocomplete.main_complete:322: command not found: _autocomplete.handle_long_list

@Oasixer Sorry about that. This should be fixed now on the dev branch. Please try again.

@marlonrichert unfortunately it's not fixed for me.

@Oasixer Did you do

git pull
git checkout dev

?

Please make sure you're _not_ still on ~1eb79b6~. If you do

git rev-parse HEAD

, which commit hash do you get?

@Oasixer Oh wait, you probably need to delete your compdump before this will start working:

rm ~/.zcompdump

I guess I should somehow make that part of this update. But how? I'll have to think about that. 馃

@marlonrichert

rm ~/.zcompdump

did not fix either.

$git log
commit 7b9554e945697dccb1b0813fa55430bc9c58ab4f (HEAD -> dev, origin/dev)
Author: Marlon Richert <[email protected]>
Date:   Tue Aug 4 21:07:27 2020 +0300

    Make autocorrection deterministic

    * Make it synchronous again.
    * Use early screen refreshes to make it feel non-blocking.

$git rev-parse HEAD
7b9554e945697dccb1b0813fa55430bc9c58ab4f

@Oasixer How are you sourcing the plugin? Do you use

source /path/to/zsh-autocomplete.plugin.zsh

? Make sure you source the file that ends in .plugin.zsh, not just .zsh.

I am sourcing the plugin.

Here is my zshrc
https://github.com/Oasixer/dotfiles/blob/master/.zshrc

Thanks for sharing. I found the problem: You're manually doing autoload -U compinit && compinit _before_ sourcing zsh-autocomplete. That's what's throwing things off. You should either not run compinit yourself and let zsh-autocomplete do it for you (it does so automatically) _or_ run compinit _after_ sourcing any plugins that add completion code to your $fpath.

I'll have to see how I can work around this in a smart way.

@marlonrichert I removed that line, removed zcompdump again, and the issue persists.

@marlonrichert Okay I was able to fix the issue by sourcing zsh-autocomplete before sourcing oh-my-zsh. I'll push my working zshrc to the link above, if that helps you

No, that won't be necessary. I already know what the problem is: oh-my-zsh runs compinit, too. I'm working on a fix.

@Oasixer I pushed in another update to the dev branch. Please try again.

@Oasixer @slavistan Can you please try out the dev and let me know what you think? Documentation over here: https://github.com/marlonrichert/zsh-autocomplete/blob/dev/README.md#advanced-choose-your-own-key-bindings

@marlonrichert Yeah I've been using the customized keybinds for a while, but I wasn't updated to the latest version. I'll try it and let you know. Btw for some reason, zsh-autocomplete seems to override the built in binding for fzf '^k' which is equivalent to the up arrow. I haven't really investigated it yet though so I'll get back to you later and see if I can find a more precise cause

Merged to master.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

weilbith picture weilbith  路  7Comments

daxmc99 picture daxmc99  路  3Comments

g4cm4n picture g4cm4n  路  6Comments

jcassee picture jcassee  路  7Comments

mimoo picture mimoo  路  5Comments