zsh-users / zsh-completions

Additional completion definitions for Zsh.
Other
7k stars 714 forks source link

yarn completions don't seem to fire #519

Closed duro closed 6 years ago

duro commented 7 years ago

Followed .oh-my-zsh instructions and I can't seem to get any of the yarn completions to fire. When I tab, I'm only getting the files in the folder:

1__adamduro_adams-macbook-pro-3____workspace_projects_freebird_portal2__zsh_

nmccready commented 6 years ago

Any one digging into this?

okapia commented 6 years ago

This is undoubtedly an issue with the user's setup and more likely an oh-my-zsh issue than zsh-completions. First, avoid the oh-my-zsh yarn plugin. Run functions _yarn to see what _yarn contains and what its origins are. Do other completions from the zsh-completions project work? Or are they even installed. Wouldn't be surprised if not.

_get_comp_words_by_ref looks like something to do with a bash completion or layer to emulate bash completions on zsh. This is always best avoided.

nmccready commented 6 years ago

There is nothing special to my setup except that I am using zim to autoload completions.

https://github.com/zimfw/zimfw/tree/master/modules/completion

I moved _yarn out of the directory and installed https://github.com/dsifford/yarn-completion which is working better but still not perfect.

okapia commented 6 years ago

I don't understand how a bash specific yarn completion can be working at all, never mind "better". I also note that you're not the originator of this issue. Do you get the same behaviour as they mention: i.e. file completion?

Can I suggest trying _yarn in isolation of other things:

    mkdir -p /tmp/ztest
    cp ...../zsh-completions/src/_yarn .
    zsh -f
    fpath=( ~+ $fpath )
    autoload -U compinit; compinit
    yarn <tab>

I would also suggest typing: <Ctrl+X><?> and viewing the log trace it produces. Have you tried checking that it is using the correct _yarn with the functions builtin as I suggested before? The function works fine for me and looks fine to me so there isn't much more I can do besides suggesting things to check.

tkkcc commented 6 years ago

try change order, If I put fpath before oh-my-zsh like this, it works

zsh=$C/zsh
fpath=($zsh/zsh-completions/src $fpath)
ZSH=$zsh/oh-my-zsh;source $ZSH/oh-my-zsh.sh

If I put fpath under oh-my-zsh, it's the same with you

kachkaev commented 4 years ago

I also struggled with making yarn completion working today (just migrating to zsh from bash on macos).

Here is what I did first in my ~/.zshrc:

 plugins = (
   ...
+  zsh-completions
 )
+autoload -U compinit && compinit

source $ZSH/oh-my-zsh.sh

After starting a new terminal session and typing yarn<tab>, I was still offered files instead of commands. The trick was to swap autoload with source in ~/.zshrc:

 plugins = (
   ...
  zsh-completions
 )
-autoload -U compinit && compinit

source $ZSH/oh-my-zsh.sh

+autoload -U compinit && compinit

Command autocompletion works now 🎉