diff options
author | Alastair Rankine <alastair@girtby.net> | 2023-01-03 03:44:53 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-01-03 09:44:53 +0100 |
commit | 00c37b6991895aac0398a24d7d8b78cda63dec05 (patch) | |
tree | 6e77c75e918a51530fe7bba49d86a54433dcf063 | |
parent | 36f1055eeea0f455676381539fcb3e6e0a4da731 (diff) | |
download | zsh-00c37b6991895aac0398a24d7d8b78cda63dec05.tar.gz zsh-00c37b6991895aac0398a24d7d8b78cda63dec05.tar.bz2 zsh-00c37b6991895aac0398a24d7d8b78cda63dec05.zip |
feat(pipenv): standarize completion generation (#11424)
Co-authored-by: Carlo Sala <carlosalag@protonmail.com>
Closes #11423
-rw-r--r-- | plugins/pipenv/pipenv.plugin.zsh | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/plugins/pipenv/pipenv.plugin.zsh b/plugins/pipenv/pipenv.plugin.zsh index 4be61a920..244bd6b7c 100644 --- a/plugins/pipenv/pipenv.plugin.zsh +++ b/plugins/pipenv/pipenv.plugin.zsh @@ -1,8 +1,16 @@ -# Pipenv completion -_pipenv() { - eval $(env COMMANDLINE="${words[1,$CURRENT]}" _PIPENV_COMPLETE=complete-zsh pipenv) -} -compdef _pipenv pipenv +if (( ! $+commands[pipenv] )); then + return +fi + +# If the completion file doesn't exist yet, we need to autoload it and +# bind it to `pipenv`. Otherwise, compinit will have already done that. +if [[ ! -f "$ZSH_CACHE_DIR/completions/_pipenv" ]]; then + typeset -g -A _comps + autoload -Uz _pipenv + _comps[pipenv]=_pipenv +fi + +_PIPENV_COMPLETE=zsh_source pipenv >| "$ZSH_CACHE_DIR/completions/_pipenv" &| # Automatic pipenv shell activation/deactivation _togglePipenvShell() { |