-
Notifications
You must be signed in to change notification settings - Fork 408
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
Update zsh completion file #606
Conversation
I just modified the clap-generated completion file for `zsh` to make it working. Note that completion for `--set` calls `just --evaluate` to get the variables, so it can slow down the console a bit if you have heavy evaluation logic.
Thank you for doing this! I'd like to avoid running
The existing ZSH completions file is auto-generated, so to merge this I'll have to write a little code inside of the
Would be ideal, and the fewer changes to the generated existing code, the easier that will be. Would it be possible to refactor this to introduce slightly less churn to the generated code? |
I just landed #608, which adds a |
Oh, sorry. I thought the completion files are maintained manually since they are added to VCS. Should I modify the Anyway, here are the list of generated _arguments that should be changed:
|
No worries, it's a somewhat convoluted setup. The completion scripts are generated by clap, the command line argument parsing library that just uses. The
This is the implementation of Line 462 in 1dbc765
So I'll have to edit that function to modify the generated completions file with your changes. I think the best thing to do is to modify this PR to have fewer diffs, and then I'll modify the completions function so that it produces the right output. For example, there's this diff: - local ret=1
+ local context curcontext="$curcontext" state line ret=1
if is-at-least 5.2; then
_arguments_options=(-s -S -C)
else
_arguments_options=(-s -C)
fi
- local context curcontext="$curcontext" state line I think these changes could be avoided, since they move around existing code.
That makes sense. What I'll probably do is create an
And then replace the call to |
@casey Thank you for your response! I've just refactored the PR to include minimal changes to the completion file. Hopefully it will be easier to add.
Well, sorry I didn't get the point how this function would work. I left the |
I just pushed some diffs to your branch which modify the completions subcommand, now in Is there any way to test ZSH completion scripts? Also, I've never actually used ZSH completions. How do I tell zsh that I want to load the completion script? |
Thanks for your fast work!
Well, I don't know any automated approach to test a completion script. Most of the time I test the script by inserting lines e.g.
Afaik zsh uses By convention completion scripts are placed in mkdir -p /tmp/completions
cp /path/to/just/completions/just.zsh /tmp/completions/_just After that, simply paste the following to your zsh or fpath+=/tmp/completions
# The styles for completion descriptions and messages, zsh will hide them by default.
zstyle ':completion:*:descriptions' format "%U%B%d%b%u"
zstyle ':completion:*:messages' format "%F{green}%d%f"
autoload -Uz compinit
compinit -u |
You bet!
I searched a little bit, and that's my impression too, i.e. that it doesn't seem to be common to test zsh completion scripts. I'd like to add that eventually, since generating completion scripts from clap and then modifying them in code feels error-prone, but that can wait.
Sweet, worked for me. Pretty cool! It's awesome to see the recipes names and variable values complete. Also rad that it prints the whole recipe in green. Thanks so much for this! Better completions scripts is a frequent request, so this will definitely make zsh users happy. |
I just modified the clap-generated completion file for
zsh
to make it working.Note that completion for
--set
callsjust --evaluate
to get the variables, so it can slow down the console a bit if you have heavy evaluation logic.