From 5057ab890b913f64f40e5800150c3bf47b7677a8 Mon Sep 17 00:00:00 2001 From: David Tomaschik Date: Mon, 9 Jun 2025 13:21:50 -0700 Subject: [PATCH] Async completion support --- dotfiles/zshrc | 4 ++++ dotfiles/zshrc.d/completions.zsh | 13 +++++++++++++ 2 files changed, 17 insertions(+) create mode 100644 dotfiles/zshrc.d/completions.zsh diff --git a/dotfiles/zshrc b/dotfiles/zshrc index 9105641..b182223 100755 --- a/dotfiles/zshrc +++ b/dotfiles/zshrc @@ -130,6 +130,10 @@ source_first_existing() { return 1 } +have_command() { + command -v "${1}" &>/dev/null +} + # Source extras and aliases if interactive if [[ $- == *i* ]] ; then source_if_existing $HOME/.aliases diff --git a/dotfiles/zshrc.d/completions.zsh b/dotfiles/zshrc.d/completions.zsh new file mode 100644 index 0000000..f757a25 --- /dev/null +++ b/dotfiles/zshrc.d/completions.zsh @@ -0,0 +1,13 @@ +# Build some completions if they don't exist +# We run in the background to reduce shell startup time +{ + COMPDIR=${HOME}/.zshrc.completions + function missing_comp() { + test ! -f "$COMPDIR/$1" + } + + have_command rustup && { + missing_comp _rustup && rustup completions zsh > $COMPDIR/_rustup + missing_comp _cargo && rustup completions zsh cargo > $COMPDIR/_cargo + } || true +} &>/dev/null &!