omelette icon indicating copy to clipboard operation
omelette copied to clipboard

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

Open tylers-username opened this issue 6 years ago • 6 comments

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?

tylers-username avatar Jan 13 '19 06:01 tylers-username

Same here +1

Roms1383 avatar Jan 19 '19 06:01 Roms1383

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

thangaram611 avatar Apr 24 '19 11:04 thangaram611

+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.

thangaram611 avatar Jun 30 '19 07:06 thangaram611

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.

kostyay avatar Aug 08 '19 10:08 kostyay

I have not revisited this.

tylers-username avatar Aug 08 '19 15:08 tylers-username

Running into this too

craigmulligan avatar Sep 08 '19 10:09 craigmulligan