Skip to content
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

How do I go about troubleshooting autocompletion not working in Zsh? #35

Open
tylers-username opened this issue Jan 13, 2019 · 6 comments

Comments

@tylers-username
Copy link

tylers-username commented Jan 13, 2019

I have a setup/cleanup script that successfully adds and removes:

# begin app completion
. <(app --completion)
# end app completion

I have also setup this alias in ~/.zshrc: alias lando='bin/app.js'.

app --completion outputs:

### app completion - begin. generated by omelette.js ###
if type compdef &>/dev/null; then
  _app_completion() {
    compadd -- `app --compzsh --compgen "${CURRENT}" "${words[CURRENT-1]}" "${BUFFER}"`
  }
  compdef _app_completion app
elif type complete &>/dev/null; then
  _app_completion() {
    local cur prev nb_colon
    _get_comp_words_by_ref -n : cur prev
    nb_colon=$(grep -o ":" <<< "$COMP_LINE" | wc -l)

    COMPREPLY=( $(compgen -W '$(app --compbash --compgen "$((COMP_CWORD - (nb_colon * 2)))" "$prev" "${COMP_LINE}")' -- "$cur") )

    __ltrim_colon_completions "$cur"
  }
  complete -F _app_completion app
fi
### app completion - end ###

My app.js contains:

    // Write your CLI template.
    var completion = omelette('app <test> <test2>')

// This is your logic
    completion.on('test', ({reply}) => { reply(['option1', 'option2']) });
    completion.on('test2', ({reply}) => { reply(['option3', 'option4']) });

    completion.init();

Now, I expect when that when I type app<tab> that I will see the options, but I do not. What are my next steps to troubleshooting? What command outputs the options that I hope to see? Is it possible that my JS is outputting garbage prematurely that breaks Zsh's autocompletion?

@Roms1383
Copy link

Same here +1

@thangaram611
Copy link

+1
I'm also facing the same issue and i am not sure how to proceed.

@thangaram611
Copy link

thangaram611 commented Jun 30, 2019

+1
I'm also facing the same issue and i am not sure how to proceed.

Debugged my code and found that the issue was with my code actually.
While running . <(app --completion) it ran through my code and stopped at a point where i have set

process.stdin.setRawMode( true )
process.stdin.resume()

After removing this line the completion began to work properly.
I am not sure why but thought this may help someone.

@kostyay
Copy link

kostyay commented Aug 8, 2019

Were you able to get this to work?
Its not working for me either. Thinking if it could be related to oh-my-zsh installed.

@tylers-username
Copy link
Author

I have not revisited this.

@craigmulligan
Copy link

Running into this too

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants