2021-09-07 18:02:20 +00:00
|
|
|
if (( $+commands[rustup] && $+commands[cargo] )); then
|
2021-09-15 16:18:25 +00:00
|
|
|
ver="$(cargo --version)"
|
|
|
|
ver_file="$ZSH_CACHE_DIR/cargo_version"
|
2021-09-15 16:41:44 +00: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 16:18:25 +00: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 18:02:20 +00:00
|
|
|
fi
|
2021-09-15 16:18:25 +00:00
|
|
|
|
|
|
|
declare -A _comps
|
2021-09-07 18:02:20 +00:00
|
|
|
autoload -Uz _cargo
|
|
|
|
_comps[cargo]=_cargo
|
2021-09-15 16:18:25 +00:00
|
|
|
|
|
|
|
unset ver ver_file comp_file
|
2021-09-07 18:02:20 +00:00
|
|
|
fi
|