-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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 and improve zsh completion #7296
Conversation
Added completion of installed crates and unstable flags along with some newer options. Factored out the definition of some common options into variables. Corrected the syntax of option exclusion lists which contained commas --verbose can be repeated so now has * instead of the self-exclusion Internal functions given _cargo prefix as per zsh conventions Completion of normal arguments to many subcommands was missing Pass -s to _arguments to allow clumping of short options, -S for correct handling of -- and -C for correct context handling. 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.
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @alexcrichton (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see the contribution instructions for more information. |
@ehuss you seem like you actually review these files from time to time whereas I tend to just rubber stamp all PRs coming in which modify them, do you want to take a look at this? If not I don't mind rubber stamping :) |
Thanks! @bors r+ |
📌 Commit cdac4a8 has been approved by |
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.
☀️ Test successful - checks-azure |
Update cargo Update cargo 10 commits in 3f700ec43ce72305eb5315cfc710681f3469d4b4..22f7dd0495cd72ce2082d318d5a9b4dccb9c5b8c 2019-08-19 22:43:12 +0000 to 2019-08-27 16:10:51 +0000 - Update and improve zsh completion (rust-lang/cargo#7296) - Document that `package` can be used in `[patch]` (rust-lang/cargo#7263) - Fix `error:`/`warning:` coloring inconsistency with rustc (rust-lang/cargo#7294) - Tests: Import rustc_plugin from its new location (rust-lang/cargo#7287) - Update README azure badge. (rust-lang/cargo#7293) - Update home dependencies to v0.5 (rust-lang/cargo#7277) - Fix typo (rust-lang/cargo#7279) - Update libgit2 dependencies (rust-lang/cargo#7275) - Fix old lockfile encoding wrt newlines (rust-lang/cargo#7262) - Fix dSYM uplifting when symlink is broken (rust-lang/cargo#7268)
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-
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.