95579e3ca181036af31c0c9039fe3edc65c231b4

Author
Carlo Sala <carlosalag@protonmail.com>
Committer
Carlo Sala <carlosalag@protonmail.com>
Date

Message

feat(1password): make completion loading async

Diff

 1diff --git a/plugins/1password/1password.plugin.zsh b/plugins/1password/1password.plugin.zsh
 2index 941523ca8c1fec5d892901d0fb7552297ce7f6cb..e8f91f8fe67d005ab0bc930dddde43cdbae90d14 100644
 3--- a/plugins/1password/1password.plugin.zsh
 4+++ b/plugins/1password/1password.plugin.zsh
 5@@ -1,9 +1,15 @@
 6 # Do nothing if op is not installed
 7 (( ${+commands[op]} )) || return
 8 
 9-# Load op completion
10-eval "$(op completion zsh)"
11-compdef _op op
12+# If the completion file doesn't exist yet, we need to autoload it and
13+# bind it to `op`. Otherwise, compinit will have already done that.
14+if [[ ! -f "$ZSH_CACHE_DIR/completions/_op" ]]; then
15+  typeset -g -A _comps
16+  autoload -Uz _op
17+  _comps[op]=_op
18+fi
19+
20+op completion zsh >| "$ZSH_CACHE_DIR/completions/_op" &|
21 
22 # Load opswd function
23 autoload -Uz opswd