浏览代码

feat(asdf): support asdf v0.16 ahead

Co-authored-by: Valgard Trontheim <github@trontheim.de>

Closes #12964
Closes #12967
Carlo Sala 2 月之前
父节点
当前提交
4d9d346718
共有 1 个文件被更改,包括 18 次插入0 次删除
  1. 18 0
      plugins/asdf/asdf.plugin.zsh

+ 18 - 0
plugins/asdf/asdf.plugin.zsh

@@ -1,3 +1,21 @@
+if (( $+commands[asdf] )); then
+  export ASDF_DATA_DIR="${ASDF_DATA_DIR:-$HOME/.asdf}"
+  path=("$ASDF_DATA_DIR/shims" $path)
+
+  # If the completion file doesn't exist yet, we need to autoload it and
+  # bind it to `asdf`. Otherwise, compinit will have already done that.
+  if [[ ! -f "$ZSH_CACHE_DIR/completions/_asdf" ]]; then
+    typeset -g -A _comps
+    autoload -Uz _asdf
+    _comps[asdf]=_asdf
+  fi
+  asdf completion zsh >| "$ZSH_CACHE_DIR/completions/_asdf" &|
+
+  return
+fi
+
+# TODO:(2025-02-12): remove deprecated asdf <0.16 code
+
 # Find where asdf should be installed
 # Find where asdf should be installed
 ASDF_DIR="${ASDF_DIR:-$HOME/.asdf}"
 ASDF_DIR="${ASDF_DIR:-$HOME/.asdf}"
 ASDF_COMPLETIONS="$ASDF_DIR/completions"
 ASDF_COMPLETIONS="$ASDF_DIR/completions"