From a9ebdcdbec77e261ead63f7d326b3fb0791d170c Mon Sep 17 00:00:00 2001 From: Shrikant Sharat Date: Wed, 13 Mar 2013 15:42:11 +0530 Subject: [PATCH] Don't load compinit module at startup. Kills the whole purpose of the compdef deferrer function introduced in #37. Completions are now correctly deferred and applied when `antigen-apply` is called. --- antigen.zsh | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/antigen.zsh b/antigen.zsh index 271981e..3296a3d 100644 --- a/antigen.zsh +++ b/antigen.zsh @@ -9,7 +9,7 @@ local _ANTIGEN_INSTALL_DIR="$(dirname $0)" # Used to defer compinit/compdef typeset -a __deferred_compdefs -compdef () { __deferred_compdefs=(${__deferred_compdefs} "${*}") } +compdef () { __deferred_compdefs=($__deferred_compdefs "$*") } # Syntaxes # antigen-bundle [=/] @@ -399,13 +399,22 @@ antigen-theme () { } antigen-apply () { + # Initialize completion. - local cd - for cd in $__deferred_compdefs; do - compdef $cd - done + local cdef + + # Load the compinit module. This will readefine the `compdef` function to + # the one that actually initializes completions. + autoload -U compinit + compinit -i + + # Apply all `compinit`s that have been deferred. + eval "$(for cdef in $__deferred_compdefs; do + echo compdef $cdef + done)" + unset __deferred_compdefs - compdef _antigen antigen + } antigen-list () { @@ -667,11 +676,6 @@ antigen () { https://github.com/robbyrussell/oh-my-zsh.git -set-default ADOTDIR $HOME/.antigen - # Load the compinit module. Required for `compdef` to be defined, which is - # used by many plugins to define completions. - autoload -U compinit - compinit -i - # Setup antigen's own completion. compdef _antigen antigen -- 2.0.0