1
0
mirror of https://github.com/dcarrillo/prezto.git synced 2025-07-02 00:29:25 +00:00

python: Optimize completion for loading lazily on demand

Move `pip` to separate completion definition delegating to pip to do
all the completion work.

Since the completion is loaded lazily on-demand, it avoids the
performance overhead during Zsh initialization.

Implementation note:
The helper function `_pip_completion` implementation is based on the
official pip completion function (which can be generated with
`pip completion --zsh`) adhering to the newer compsys style.

See: 'man zshcompsys' for more details.
This commit is contained in:
Indrajit Raychaudhuri
2020-11-30 23:55:27 -06:00
committed by Indrajit Raychaudhuri
parent d686da3c03
commit f0942e6dda
3 changed files with 24 additions and 32 deletions

View File

@ -0,0 +1,19 @@
#compdef -P pip[0-9.]#
#autoload
#
# Pip completion, delegating to pip to do all the completion work.
#
# Authors:
# Indrajit Raychaudhuri <irc@indrajit.com>
#
if (( $+commands[$words[1]] )); then
function _pip_completion {
compadd -- $( COMP_WORDS="$words[*]" COMP_CWORD=$(( CURRENT - 1 )) \
PIP_AUTO_COMPLETE=1 $words[1] 2>/dev/null )
}
_pip_completion "$@"
fi