mirror of
https://github.com/BurntSushi/ripgrep.git
synced 2025-11-23 21:54:45 +02:00
33 lines
1.2 KiB
Rust
33 lines
1.2 KiB
Rust
/*!
|
|
Provides completions for ripgrep's CLI for the zsh shell.
|
|
|
|
Unlike completion short for other shells (at time of writing), zsh's
|
|
completions for ripgrep are maintained by hand. This is because:
|
|
|
|
1. They are lovingly written by an expert in such things.
|
|
2. Are much higher in quality than the ones below that are auto-generated.
|
|
Namely, the zsh completions take application level context about flag
|
|
compatibility into account.
|
|
3. There is a CI script that fails if a new flag is added to ripgrep that
|
|
isn't included in the zsh completions.
|
|
4. There is a wealth of documentation in the zsh script explaining how it
|
|
works and how it can be extended.
|
|
|
|
In principle, I'd be open to maintaining any completion script by hand so
|
|
long as it meets criteria 3 and 4 above.
|
|
*/
|
|
|
|
/// Generate completions for zsh.
|
|
pub(crate) fn generate() -> String {
|
|
let hyperlink_alias_descriptions = grep::printer::hyperlink_aliases()
|
|
.iter()
|
|
.map(|alias| {
|
|
format!(r#" {}:"{}""#, alias.name(), alias.description())
|
|
})
|
|
.collect::<Vec<String>>()
|
|
.join("\n");
|
|
include_str!("rg.zsh")
|
|
.replace("!ENCODINGS!", super::ENCODINGS.trim_end())
|
|
.replace("!HYPERLINK_ALIASES!", &hyperlink_alias_descriptions)
|
|
}
|