00d0735704d8e1070a51bbd1334db32d2e822fe6

Author
kronion <kronion@users.noreply.github.com>
Committer
GitHub <noreply@github.com>
Date

Message

feat(poetry): add plugin to provide completion for Poetry (#10595)

Diff

 1diff --git a/plugins/poetry/README.md b/plugins/poetry/README.md
 2new file mode 100644
 3index 0000000000000000000000000000000000000000..51780cbeda8d59b2c92fca6b7014392bf4806e79
 4--- /dev/null
 5+++ b/plugins/poetry/README.md
 6@@ -0,0 +1,9 @@
 7+# Poetry Plugin
 8+
 9+This plugin automatically installs [Poetry](https://python-poetry.org/)'s completions for you, and keeps them up to date as your Poetry version changes.
10+
11+To use it, add `poetry` to the plugins array in your zshrc file:
12+
13+```zsh
14+plugins=(... poetry)
15+```
16diff --git a/plugins/poetry/poetry.plugin.zsh b/plugins/poetry/poetry.plugin.zsh
17new file mode 100644
18index 0000000000000000000000000000000000000000..e872e9fd6ec7fa034209973122feed2bffa28205
19--- /dev/null
20+++ b/plugins/poetry/poetry.plugin.zsh
21@@ -0,0 +1,16 @@
22+# Return immediately if poetry is not found
23+if (( ! $+commands[poetry] )); then
24+  return
25+fi
26+
27+# If the completion file doesn't exist yet, we need to autoload it and
28+# bind it to `poetry`. Otherwise, compinit will have already done that.
29+if [[ ! -f "$ZSH_CACHE_DIR/completions/_poetry" ]]; then
30+  typeset -g -A _comps
31+  autoload -Uz _poetry
32+  _comps[gh]=_poetry
33+fi
34+
35+poetry completions zsh >| "$ZSH_CACHE_DIR/completions/_poetry" &|
36+
37+unset comp_file