]> src.twobees.de Git - dotfiles.git/blob - stow/oh-my-zsh/.oh-my-zsh/plugins/rust/rust.plugin.zsh
...
[dotfiles.git] / stow / oh-my-zsh / .oh-my-zsh / plugins / rust / rust.plugin.zsh
1 if ! (( $+commands[rustup] && $+commands[cargo] )); then
2   return
3 fi
4
5 # If the completion file doesn't exist yet, we need to autoload it and
6 # bind it to `cargo`. Otherwise, compinit will have already done that
7 if [[ ! -f "$ZSH_CACHE_DIR/completions/_cargo" ]]; then
8   autoload -Uz _cargo
9   typeset -g -A _comps
10   _comps[cargo]=_cargo
11 fi
12
13 # If the completion file doesn't exist yet, we need to autoload it and
14 # bind it to `rustup`. Otherwise, compinit will have already done that
15 if [[ ! -f "$ZSH_CACHE_DIR/completions/_rustup" ]]; then
16   autoload -Uz _rustup
17   typeset -g -A _comps
18   _comps[rustup]=_rustup
19 fi
20
21 # Generate completion files in the background
22 rustup completions zsh >| "$ZSH_CACHE_DIR/completions/_rustup" &|
23 cat >| "$ZSH_CACHE_DIR/completions/_cargo" <<'EOF'
24 #compdef cargo
25 source "$(rustc +${${(z)$(rustup default)}[1]} --print sysroot)"/share/zsh/site-functions/_cargo
26 EOF