-
Notifications
You must be signed in to change notification settings - Fork 2.6k
doc: Update instructions on using native-completions #15480
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
base: master
Are you sure you want to change the base?
Conversation
`~/.local/share/bash-completion/completions/cargo` is more sensible, and [recommended by rustup](https://github.com/rust-lang/rustup/blob/e4f3ad6f893e56ca10f0a329c401a5eafab69607/src/cli/help.rs#L275).
I'm not too familiar with how the different completion locations are loaded. So you are saying the following source <(CARGO_COMPLETE=bash cargo +nightly) Have you tested this? Its important to note that we are not telling people to $ CARGO_COMPLETE=bash cargo +nightly > ~/.local/share/bash-completion/completions/cargo And speaking of rustup, why does it have you append to the file? That seems bad if the person forgets and does it again |
Hmm, looking into that documentation in rustup, it is to conform to https://github.com/scop/bash-completion/blob/main/README.md My question would then be how often is that installed and used? |
@@ -1816,10 +1816,10 @@ When in doubt, you can discuss this in [#14520](https://github.com/rust-lang/car | |||
|
|||
### How to use native-completions feature: | |||
- bash: | |||
Add `source <(CARGO_COMPLETE=bash cargo +nightly)` to your .bashrc. | |||
Add `source <(CARGO_COMPLETE=bash cargo +nightly)` to `~/.local/share/bash-completion/completions/cargo`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or make it XDG_DATA_HOME
, which
- bash-completion recommends: https://github.com/scop/bash-completion/blob/89aa18b15462f117c20cde5f71e109c2f616bb62/README.md?plain=1#L153-L161
- We already did that for fish:
cargo/src/doc/src/reference/unstable.md
Lines 1824 to 1828 in 8b5c351
- fish: Add `source (CARGO_COMPLETE=fish cargo +nightly | psub)` to `$XDG_CONFIG_HOME/fish/completions/cargo.fish` - elvish: Add `eval (E:CARGO_COMPLETE=elvish cargo +nightly | slurp)` to `$XDG_CONFIG_HOME/elvish/rc.elv`
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or make it
XDG_DATA_HOME
Maybe some fallback method should be mentioned, in case the env var doesn't exist?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to the code, the .local/share
directory will be used as a fallback for XDG_DATA_HOME
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The suggested fallback of XDG_DATA_HOME
is exactly $HOME/.local/share
. I think saying XDG_DATA_HOME
is good enough, alike elvish and fish.
https://specifications.freedesktop.org/basedir-spec/latest/#variables
I've tested it on Ubuntu 24.04.2 LTS, with |
Regarding that they used |
~/.local/share/bash-completion/completions/cargo
is more sensible, and recommended by rustup.