]> git.proxmox.com Git - cargo.git/commitdiff
Auto merge of #7296 - okapia:zsh-completion, r=ehuss
authorbors <bors@rust-lang.org>
Tue, 27 Aug 2019 16:10:51 +0000 (16:10 +0000)
committerbors <bors@rust-lang.org>
Tue, 27 Aug 2019 16:10:51 +0000 (16:10 +0000)
Update and improve zsh completion

I went through the zsh completion to clean it up, adapt it to zsh conventions, and to bring it up-to-date for new cargo options. For context, I'm one of the zsh developers and do know what I'm doing with zsh completion functions. As for cargo, I do use it but was referring to documentation here.

I added new functions for completion of installed crates and unstable flags.
Many subcommands had out-of-date option lists which I've updated, This isn't yet comprehensive, however.

Factored out the definition of some common options into variables - this explains the greater number of lines deleted than added.

Corrected the syntax of option exclusion lists which erroneously contained commas. It was also common for option arguments to be missing and = to not be allowed before them.

--verbose can be repeated so now has * instead of the self-exclusion. It and --quiet appear to be mutually exclusive, however.

I've given internal functions an _cargo prefix as per zsh conventions. This avoids name clashes. I also removed _get from the names - zsh convention is a plural noun for what is completed.

Completion of normal arguments to many subcommands was missing. In many cases, this is now just a description - e.g. "crate". _guard is needed in some cases so as not to break option completion. For rustc and rustdoc, it'll dispatch to their respective completions if they ever gain one, otherwise using default completion.

It now passes -s to _arguments to allow clumping of short options, -S for correct
handling of -- and -C for correct context handling. _arguments also changes some variables which should be declared local and I've restored these - ShellCheck had persuaded someone to remove them.

For unknown cargo subcommands, it will now try a _cargo-<subcommand>
function if found and fallback to _default allowing cargo plugins to
define their own completion. This is common zsh practice, see e.g. _git. And fallbacks to default completion are always a good idea - users don't tend to like filename completion being broken.

$curcontext is now updated to include the sub-command which provides more flexibility to users configuring zsh completion with zstyle.


Trivial merge