1
0
Fork 0
mirror of https://github.com/zplug/zplug synced 2024-06-03 13:26:10 +02:00

Fix a bug related to prezto load path calculation

This commit is contained in:
b4b4r07 2016-12-07 16:21:31 +09:00
parent bd4b018f81
commit 08becca230
3 changed files with 108 additions and 34 deletions

View File

@ -69,15 +69,22 @@ __zplug::sources::oh-my-zsh::load_plugin()
local -a \
unclassified_plugins \
load_fpaths \
defer_1_plugins \
load_plugins \
lazy_plugins
lazy_plugins \
defer_1_plugins \
defer_2_plugins \
defer_3_plugins
__zplug::core::tags::parse "$repo"
tags=( "${reply[@]}" )
default_tags[use]="$(__zplug::core::core::run_interfaces 'use')"
unclassified_plugins=()
load_fpaths=()
load_plugins=()
lazy_plugins=()
defer_1_plugins=()
defer_2_plugins=()
defer_3_plugins=()
# Check if omz is loaded and set some necessary settings
if [[ -z $ZSH ]]; then
@ -119,18 +126,29 @@ __zplug::sources::oh-my-zsh::load_plugin()
"$tags[dir]/$tags[name]"/{_*,**/_*}(N-.:h)
)
# unclassified_plugins -> {defer_1_plugins,lazy_plugins,load_plugins}
if [[ $tags[defer] -gt 9 ]]; then
# the order of loading of plugin files
defer_1_plugins+=( "${unclassified_plugins[@]}" )
else
# autoload plugin / regular plugin
if (( $_zplug_boolean_true[(I)$tags[lazy]] )); then
lazy_plugins+=( "${unclassified_plugins[@]}" )
else
load_plugins+=( "${unclassified_plugins[@]}" )
fi
fi
# unclassified_plugins -> {defer_N_plugins,lazy_plugins,load_plugins}
# the order of loading of plugin files
case "$tags[defer]" in
0)
if (( $_zplug_boolean_true[(I)$tags[lazy]] )); then
lazy_plugins+=( "${unclassified_plugins[@]}" )
else
load_plugins+=( "${unclassified_plugins[@]}" )
fi
;;
1)
defer_1_plugins+=( "${unclassified_plugins[@]}" )
;;
2)
defer_2_plugins+=( "${unclassified_plugins[@]}" )
;;
3)
defer_3_plugins+=( "${unclassified_plugins[@]}" )
;;
*)
: # Error
;;
esac
unclassified_plugins=()
if [[ -n $tags[ignore] ]]; then
@ -147,6 +165,8 @@ __zplug::sources::oh-my-zsh::load_plugin()
# Plugins
load_plugins=( "${(R)load_plugins[@]:#$ignore}" )
defer_1_plugins=( "${(R)defer_1_plugins[@]:#$ignore}" )
defer_2_plugins=( "${(R)defer_2_plugins[@]:#$ignore}" )
defer_3_plugins=( "${(R)defer_3_plugins[@]:#$ignore}" )
lazy_plugins=( "${(R)lazy_plugins[@]:#$ignore}" )
# fpath
load_fpaths=( "${(R)load_fpaths[@]:#$ignore}" )

View File

@ -67,26 +67,28 @@ __zplug::sources::prezto::load_plugin()
local repo="${1:?}"
local -A tags
local -A default_tags
local -a load_fpaths
local -a unclassified_plugins
local -a lazy_plugins
local -a defer_1_plugins defer_2_plugins defer_3_plugins
local module_name
local dependency
local -a \
unclassified_plugins \
load_fpaths \
load_plugins \
lazy_plugins \
defer_1_plugins \
defer_2_plugins \
defer_3_plugins
__zplug::core::tags::parse "$repo"
tags=( "${reply[@]}" )
default_tags[use]="$(__zplug::core::core::run_interfaces 'use')"
load_fpaths=()
unclassified_plugins=()
load_fpaths=()
load_plugins=()
lazy_plugins=()
defer_1_plugins=()
defer_2_plugins=()
defer_3_plugins=()
module_name="${tags[name]#*/}"
if [[ ! -d $tags[dir] ]]; then
zstyle ":prezto:module:$module_name" loaded "no"
return 1
@ -98,22 +100,25 @@ __zplug::sources::prezto::load_plugin()
}
}
for dependency in ${(@f)"$( __zplug::utils::prezto::depends "$module_name" )"}
# module/command-not-found -> command-not-found
module_name="${tags[name]#*/}"
for dependency in ${(@f)"$(__zplug::utils::prezto::depends "$module_name")"}
do
unclassified_plugins+=( "$tags[dir]/modules/$dependency"/init.zsh(N-.) )
done
if [[ $tags[use] != $default_tags[use] ]]; then
unclassified_plugins+=( "$tags[dir]"/${~tags[use]}(N-.) )
elif [[ -f $tags[dir]/$tags[name]/init.zsh ]]; then
unclassified_plugins+=( "$tags[dir]/$tags[name]"/init.zsh(N-.) )
fi
# modules/prompt's init.zsh must be sourced AFTER fpath is added (i.e.
# after compinit in __load__)
if [[ $tags[name] == modules/prompt ]]; then
defer_1_plugins=( $unclassified_plugins[@] )
unclassified_plugins=()
defer_2_plugins+=( "$tags[dir]/$tags[name]"/init.zsh(N-.) )
else
# Default modules
if [[ $tags[use] != $default_tags[use] ]]; then
unclassified_plugins+=( "$tags[dir]"/${~tags[use]}(N-.) )
elif [[ -f $tags[dir]/$tags[name]/init.zsh ]]; then
unclassified_plugins+=( "$tags[dir]/$tags[name]"/init.zsh(N-.) )
fi
fi
# Add functions directory to FPATH if it exists
@ -137,10 +142,56 @@ __zplug::sources::prezto::load_plugin()
zstyle ":prezto:module:prompt" theme "off"
fi
# unclassified_plugins -> {defer_N_plugins,lazy_plugins,load_plugins}
# the order of loading of plugin files
case "$tags[defer]" in
0)
if (( $_zplug_boolean_true[(I)$tags[lazy]] )); then
lazy_plugins+=( "${unclassified_plugins[@]}" )
else
load_plugins+=( "${unclassified_plugins[@]}" )
fi
;;
1)
defer_1_plugins+=( "${unclassified_plugins[@]}" )
;;
2)
defer_2_plugins+=( "${unclassified_plugins[@]}" )
;;
3)
defer_3_plugins+=( "${unclassified_plugins[@]}" )
;;
*)
: # Error
;;
esac
unclassified_plugins=()
if [[ -n $tags[ignore] ]]; then
ignore_patterns=( $(
zsh -c "$_ZPLUG_CONFIG_SUBSHELL; echo ${tags[dir]}/${~tags[ignore]}" \
2> >(__zplug::io::log::capture)
)(N) )
for ignore in "${ignore_patterns[@]}"
do
# Commands
if [[ -n $load_commands[(i)$ignore] ]]; then
unset "load_commands[$ignore]"
fi
# Plugins
load_plugins=( "${(R)load_plugins[@]:#$ignore}" )
defer_1_plugins=( "${(R)defer_1_plugins[@]:#$ignore}" )
defer_2_plugins=( "${(R)defer_2_plugins[@]:#$ignore}" )
defer_3_plugins=( "${(R)defer_3_plugins[@]:#$ignore}" )
lazy_plugins=( "${(R)lazy_plugins[@]:#$ignore}" )
# fpath
load_fpaths=( "${(R)load_fpaths[@]:#$ignore}" )
done
fi
reply=()
#[[ -n $unclassified_plugins ]] && reply+=( "unclassified_plugins" "${(F)unclassified_plugins}" )
[[ -n $load_fpaths ]] && reply+=( "load_fpaths" "${(F)load_fpaths}" )
[[ -n $load_plugins ]] && reply+=( "load_plugins" "${(F)unclassified_plugins}" ) # TODO
[[ -n $load_plugins ]] && reply+=( "load_plugins" "${(F)load_plugins}" )
[[ -n $lazy_plugins ]] && reply+=( "lazy_plugins" "${(F)lazy_plugins}" )
[[ -n $defer_1_plugins ]] && reply+=( "defer_1_plugins" "${(F)defer_1_plugins}" )
[[ -n $defer_2_plugins ]] && reply+=( "defer_2_plugins" "${(F)defer_2_plugins}" )

View File

@ -66,6 +66,7 @@ zplug clear
zplug "plugins/cp", from:oh-my-zsh
# prezto
zplug "modules/tmux", from:prezto
zplug "modules/git", from:prezto
# gh-r
zplug "junegunn/fzf-bin", \
as:command, \
@ -90,7 +91,9 @@ zplug clear
'(( $+aliases[gba] ))'
'(( $+functions[cpv] ))'
'(( $+functions[random_emoji] ))'
'(( $+aliases[tmuxa] ))'
'(( $+aliases[tmuxa] ))' # "prezto" modules/tmux
'(( $+aliases[gbS] ))' # "prezto" modules/git
'(( $+functions[git-dir] ))' # "prezto" modules/git
'[[ -x $ZPLUG_HOME/bin/fzf ]]'
'[[ -x $ZPLUG_HOME/bin/peco ]]'
'[[ -x $ZPLUG_HOME/bin/get_last_pane_path.sh ]]'