]> arthur.barton.de Git - ax-zsh.git/blobdiff - ax.zsh
50_axzsh: Fix completion of theme names
[ax-zsh.git] / ax.zsh
diff --git a/ax.zsh b/ax.zsh
index 556061a36f096b436c7df7196462467c7192145f..42c2792a6ae9a60a9ff606bff8bc1504a8945355 100644 (file)
--- a/ax.zsh
+++ b/ax.zsh
@@ -56,6 +56,10 @@ function axzsh_load_plugin {
                [[ -n "$AXZSH_DEBUG" ]] \
                        && echo "   - $plugin ($type): functions ..."
                axzsh_fpath+=("$dname/functions")
+
+               # Add function path to cache file.
+               [[ -n "$cache_file" ]] \
+                       && echo "axzsh_fpath+=('$dname/functions')" >>$cache_file
        fi
 
        if [[ -r "$fname" ]]; then
@@ -66,7 +70,7 @@ function axzsh_load_plugin {
 
                if [[ -n "$cache_file" ]]; then
                        # Add plugin data to cache
-                       printf "# BEGIN: %s\ninit()\n{\n" "$fname" >>"$cache_file"
+                       printf "# BEGIN: %s\nax_plugin_init()\n{\n" "$fname" >>"$cache_file"
                        case "$fname" in
                                *"/repos/"*)
                                        echo "[[ -n \"\$AXZSH_DEBUG\" ]] && echo '     - $plugin ($type): \"$fname\" ...'" >>$cache_file
@@ -76,7 +80,7 @@ function axzsh_load_plugin {
                                        echo "[[ -n \"\$AXZSH_DEBUG\" ]] && echo '     - $plugin ($type, cached) ...'" >>$cache_file
                                        "$cat_cmd" "$fname" >>"$cache_file"
                        esac
-                       printf "}\ninit\n# END: %s\n\n" "$fname" >>"$cache_file"
+                       printf "}\nax_plugin_init\n# END: %s\n\n" "$fname" >>"$cache_file"
                fi
        fi
 
@@ -116,9 +120,17 @@ cat_cmd=${commands[cat]:-cat}
 
 if [[ -r "$cache_file" ]]; then
        # Cache file exists, use it!
+       # But when in the "zshrc" stage, make sure that the "zprofile" stage
+       # has already been handled (this uses the "01_zprofile" plugin which
+       # is used in the "zshrc.cache" as well, but can't be used successfully
+       # there because it becomes sourced inside of a ZSH function; so we have
+       # to source it here in the global context manually ...):
+       [[ -z "$AXZSH_ZPROFILE_READ" && "$script_type" = "zshrc" ]] \
+               && source "$AXZSH/core/01_zprofile/01_zprofile.zshrc"
        [[ -n "$AXZSH_DEBUG" ]] \
                && echo "   - Reading cache file \"$cache_file\" ..."
        source "$cache_file"
+       unfunction ax_plugin_init
 else
        # No cache file available.
        # Setup list of plugins to load: