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

Error while trying to use the -zsh-completion-script #1827

Closed
PierreR opened this issue Jun 1, 2020 · 7 comments · Fixed by #1829
Closed

Error while trying to use the -zsh-completion-script #1827

PierreR opened this issue Jun 1, 2020 · 7 comments · Fixed by #1829

Comments

@PierreR
Copy link
Contributor

PierreR commented Jun 1, 2020

I am probably doing something wrong but I have not been able to make zsh completion work:

λ ~ → nix-shell -p dhall --run zsh
λ ~ → echo $0
zsh
λ ~ → source <(dhall            --zsh-completion-script dhall)
/proc/self/fd/11:compadd:24: can only be called from completion function

I have also tried to put this line in shellHook but then I have got:

/dev/fd/63: line 26: print: command not found
/dev/fd/63: line 27: compadd: command not foun

PS: The bash completion script is working fine.

Thanks for your help.

@Gabriella439
Copy link
Collaborator

Apparently we're not loading the zsh completion correctly. zsh is not designed to source completion scripts. I'll have a fix up later today.

Gabriella439 added a commit that referenced this issue Jun 2, 2020
@Gabriella439
Copy link
Collaborator

Fix is up here: #1829

@PierreR
Copy link
Contributor Author

PierreR commented Jun 2, 2020

@Gabriel439 Thanks.

Do you know if there is a way to reload zsh with the completion enabled without launching a new one with zsh -i ?

Unlike nix-shell, direnv is using the shell of the user. Creating a new one seems to cause problems with direnv.

If I just remove the line zsh -i I don't get any completion.

@PierreR
Copy link
Contributor Author

PierreR commented Jun 2, 2020

I guess this is more a direnv issue than anything else:
direnv/direnv#443

@Gabriella439
Copy link
Collaborator

@PierreR: There is not a way to avoid the zsh -i when using nix-shell, because nix-shell switches the shell to bash, regardless of what the original shell was. I think it might be worth making a request upstream to have nix-shell support shells other than bash

@PierreR
Copy link
Contributor Author

PierreR commented Jun 2, 2020

@Gabriel439 sure but that's not the case with direnv. direnv is going to read shell.nix and keep the user shell (zsh for me).

At this point I really believe it is more a direnv problem than anything else.

I believe your fix is quite valid for nix-shell usage in general.

I will probably try to fix this by creating a dhall nix derivation (or will upload _dhall in my .zsh). I even might go with bash instead.

Thanks for your help !

@PierreR PierreR closed this as completed Jun 2, 2020
@Gabriella439
Copy link
Collaborator

@PierreR: You're welcome! 🙂

mergify bot added a commit that referenced this issue Jun 5, 2020
* Fix `zsh` completion support

Fixes #1827

* Add `dhall-docs` to `shell.nix`

Co-authored-by: Simon Jakobi <simon.jakobi@gmail.com>

Co-authored-by: Simon Jakobi <simon.jakobi@gmail.com>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
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

Successfully merging a pull request may close this issue.

2 participants