2021-09-07 20:02:20 +02:00
|
|
|
if (( $+commands[rustup] && $+commands[cargo] )); then
|
2021-09-15 18:18:25 +02:00
|
|
|
ver="$(cargo --version)"
|
|
|
|
ver_file="$ZSH_CACHE_DIR/cargo_version"
|
2021-09-15 18:41:44 +02:00
|
|
|
comp_file="$ZSH_CACHE_DIR/completions/_cargo"
|
|
|
|
|
|
|
|
mkdir -p "${comp_file:h}"
|
|
|
|
(( ${fpath[(Ie)${comp_file:h}]} )) || fpath=("${comp_file:h}" $fpath)
|
2021-09-15 18:18:25 +02:00
|
|
|
|
|
|
|
if [[ ! -f "$comp_file" || ! -f "$ver_file" || "$ver" != "$(< "$ver_file")" ]]; then
|
|
|
|
rustup completions zsh cargo >| "$comp_file"
|
|
|
|
echo "$ver" >| "$ver_file"
|
2021-09-07 20:02:20 +02:00
|
|
|
fi
|
2021-09-15 18:18:25 +02:00
|
|
|
|
|
|
|
declare -A _comps
|
2021-09-07 20:02:20 +02:00
|
|
|
autoload -Uz _cargo
|
|
|
|
_comps[cargo]=_cargo
|
2021-09-15 18:18:25 +02:00
|
|
|
|
|
|
|
unset ver ver_file comp_file
|
2021-09-07 20:02:20 +02:00
|
|
|
fi
|