-
Notifications
You must be signed in to change notification settings - Fork 950
Install zsh completions for rustc #387
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
Comments
I like this. |
Fine by me, though I'd like to understand better how they are supposed to be installed. You say we already install cargo zsh completions, but we don't do anything special for them - they're just buried in the toolchain directory. That's not so user-friendly. |
@brson The completions file needs to be in a directory contained in
On OS X, I believe this is where |
@freebroccolo Thanks for the tips. I see two problems that need to be solved: first, the completions could theoretically be toolchain-specific (and indeed the cargo zsh completions today come with the compiler, not rustup). So a single symlink isn't sufficient because it won't change when the active toolchain changes. Second, installing to /usr/local typically requires root, and rustup installation today does not require root, which I see as a strong advantage. I don't want to require root just to install completions. For the first, I'd suggest that the drift in the command sets of For the second I'm not sure. Maybe have a command |
I think I'd prefer the simplicity of removing completions from the toolchain installer and just making rustup responsible for them. This has the downside that maybe the completions aren't exactly right for any particular toolchain (or the completions have to support multiple toolchains). Here's what I'd suggest the next steps are:
cc @alexcrichton @nrc @aturon @japaric a strategy for distributing Rust tool shell-completions. |
Oh, probably also need a way to clean up the mess - |
@brson I may have missed this, but there's for sure no user-local place to install completions? I agree that rustup never calling sudo is quite nice :) Other than that I think we'd still want to continue to distribute the completions in the other installers we have (e.g. tarballs) but having a command that's baked into rustup also seems good to me. The completions don't really change all that often anyway, and when they do it's mostly just adding features. |
Good point. In principle, you could add a directory to
Being able to avoid |
Well, for zsh at least we can modify the |
It may also be ok to print out "just run this one command, maybe with sudo" as part of this command to install completions. |
I hacked together zsh completions for rustup itself. Worth a PR? Long term solution: https://github.com/kbknapp/clap-rs should support zsh completion generation (my 2c; clap issue for bash completion generation=clap-rs/clap#376). |
@nerdrew Yeah, if you have rustup zsh completions I'd like to have them in repo ... somewhere, with the intent of installing them with this |
I would suggest performing the installation like npm does it (https://docs.npmjs.com/cli/completion). That way, no root is required, and it is not hardcoded where completions are installed. |
I like this idea of |
If you want automatic updating, you could add something like |
@Rahix Good idea! |
I wonder if all shells have completions that fit in a single file. If we're expecting the user to redirect the completions to the right place themselves then we'll need to be able to tell them how to do the completions. In the npm example from the linked docs they pipe the same completions into both |
Why not a # ...
source $HOME/.cargo/.completion.zsh Each time you update rustup, the file is updated and you don't call rustup completion each time you open a new shell |
At least include completions for Cargo on Related: rust-lang/cargo/issues/5596, #1123, #1199. |
Happy to accept a PR for this. |
_arguments:comparguments:319: can only be called from completion function |
Yeah that is what I am getting too, the command runs fine if not in a zshrc file though (which is weird) |
You're not supposed to |
I put this in my .zshrc (inspired by the link above): if [ ! -e ~/.zfunc/_rustup -a $commands[rustup] ]; then
mkdir -p ~/.zfunc
rustup completions zsh > ~/.zfunc/_rustup
fpath+=~/.zfunc
fi
# ...
autoload -Uz compinit && compinit
# ... I think the idea behind generating |
We already install zsh completions for cargo. It would be nice if rustup also installed the rustc zsh completions from this repository.
The text was updated successfully, but these errors were encountered: