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

nvm completion not loading properly #85

Open
mrmanc opened this issue Jan 11, 2022 · 3 comments
Open

nvm completion not loading properly #85

mrmanc opened this issue Jan 11, 2022 · 3 comments

Comments

@mrmanc
Copy link

mrmanc commented Jan 11, 2022

When using this plugin (installed using antigen), and setting export NVM_COMPLETION=true, I don’t get proper completion when I type nvm <tab>. I get path based completion suggestions instead.

Zsh version: zsh 5.8 (x86_64-apple-darwin21.0)
MacOS version: 12.0.1
Macbook M1 Pro

I dug around in the code, and found that when I run the _zsh_nvm_completion function manually from my prompt, completion works fine (click to watch below recording). What is weird is when I edited the file to check that function was running, and sourcing $NVM_DIR/bash_completion successfully, I could see that it was.

  [[ -r $NVM_DIR/bash_completion ]] && source $NVM_DIR/bash_completion && echo "Successfully sourced bash completion"

asciicast

I took a look at $NVM_DIR/bash_completion to see what I could make out, and used set -x to get some debug. I can see that calling the function manually after opening a new shell seems to do a lot more. I’m not familiar enough with completion to understand where it’s going wrong. I can’t follow the complete:13 debug to see why nothing else runs. The call to complete on the last line of $NVM_DIR/bash_completion completes without error.

Here is the debug from opening a new shell:

+/Users/Mark.Crossfield/.nvm/bash_completion:6> command -v nvm
+/Users/Mark.Crossfield/.nvm/bash_completion:87> [[ -n 5.8 ]]
+/Users/Mark.Crossfield/.nvm/bash_completion:90> command -v compinit
+/Users/Mark.Crossfield/.nvm/bash_completion:97> autoload -U +X bashcompinit
+/Users/Mark.Crossfield/.nvm/bash_completion:97> bashcompinit
+bashcompinit:177> unfunction bashcompinit
+bashcompinit:178> autoload -Uz bashcompinit
+bashcompinit:179> return 0
+/Users/Mark.Crossfield/.nvm/bash_completion:100> complete -o default -F __nvm nvm
+complete:1> emulate -L zsh
+complete:2> local args void cmd print remove
+complete:3> args=( -o default -F __nvm nvm ) 
+complete:4> zparseopts -D -a void o: A: G: W: C: F: P: S: X: a b c d e f g j k u v 'p=print' 'r=remove'
+complete:6> [[ -n '' ]]
+complete:8> [[ -n '' ]]
+complete:13> compdef '_bash_complete -o default -F __nvm' nvm

And here’s the debug from calling the _zsh_nvm_completion function for comparison:

+/Users/Mark.Crossfield/.nvm/bash_completion:6> command -v nvm
+/Users/Mark.Crossfield/.nvm/bash_completion:87> [[ -n 5.8 ]]
+/Users/Mark.Crossfield/.nvm/bash_completion:90> command -v compinit
+/Users/Mark.Crossfield/.nvm/bash_completion:97> autoload -U +X bashcompinit
+/Users/Mark.Crossfield/.nvm/bash_completion:97> bashcompinit
+bashcompinit:177> unfunction bashcompinit
+bashcompinit:178> autoload -Uz bashcompinit
+bashcompinit:179> return 0
+/Users/Mark.Crossfield/.nvm/bash_completion:100> complete -o default -F __nvm nvm
+complete:1> emulate -L zsh
+complete:2> local args void cmd print remove
+complete:3> args=( -o default -F __nvm nvm ) 
+complete:4> zparseopts -D -a void o: A: G: W: C: F: P: S: X: a b c d e f g j k u v 'p=print' 'r=remove'
+complete:6> [[ -n '' ]]
+complete:8> [[ -n '' ]]
+complete:13> compdef '_bash_complete -o default -F __nvm' nvm
+compdef:1> local opt autol type func delete eval new i ret=0 cmd svc
+compdef:2> local -a match mbegin mend
+compdef:4> emulate -L zsh
+compdef:5> setopt extendedglob
+compdef:9> ((  ! 2  ))
+compdef:14> getopts anpPkKde opt
+compdef:38> shift OPTIND-1
+compdef:40> ((  ! 2  ))
+compdef:45> [[ -z '' ]]
+compdef:49> [[ -z '' ]]
+compdef:49> [[ '_bash_complete -o default -F __nvm' = *=* ]]
+compdef:79> func='_bash_complete -o default -F __nvm' 
+compdef:80> [[ -n '' ]]
+compdef:81> shift
+compdef:83> case  (widgetkey)
+compdef:83> case  (key)
+compdef:83> case  (*)
+compdef:131> ((  1  ))
+compdef:132> [[ nvm = -N ]]
+compdef:134> [[ nvm = -p ]]
+compdef:136> [[ nvm = -P ]]
+compdef:139> case  (pattern)
+compdef:139> case  (postpattern)
+compdef:139> case  (*)
+compdef:155> [[ nvm = *=* ]]
+compdef:159> cmd=nvm 
+compdef:160> svc='' 
+compdef:162> [[ -z '' ]]
+compdef:163> _comps[$cmd]='_bash_complete -o default -F __nvm' 
+compdef:164> [[ -n '' ]]
+compdef:169> shift
+compdef:131> ((  0  ))
@thisistouhid
Copy link

Same here 😟

@michael-mader
Copy link

same here, macbook with m1

@thowimmer
Copy link

thowimmer commented Mar 29, 2023

same here :-(
Cannot get zsh completion working even when calling the _zsh_nvm_completion function manually

Oscaner added a commit to Oscaner/zsh-nvm that referenced this issue Sep 13, 2023
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

4 participants