2015-12-15 00:12:17 -05:00
|
|
|
#
|
|
|
|
# Zim initializition
|
|
|
|
#
|
|
|
|
|
2017-06-28 17:55:48 -04:00
|
|
|
autoload -Uz is-at-least
|
|
|
|
if ! is-at-least 5.2; then
|
|
|
|
print "WARNING: Support for zsh < 5.2 will be moved to an unsupported branch on the next update. Please consider updating your zsh version." >&2
|
|
|
|
fi
|
|
|
|
|
2015-12-15 00:12:17 -05:00
|
|
|
# Define zim location
|
2015-12-19 09:48:29 -05:00
|
|
|
ZIM="${ZDOTDIR:-${HOME}}/.zim"
|
2015-12-15 00:12:17 -05:00
|
|
|
|
|
|
|
# Source user configuration
|
2015-12-19 09:48:29 -05:00
|
|
|
if [[ -s "${ZDOTDIR:-${HOME}}/.zimrc" ]]; then
|
|
|
|
source "${ZDOTDIR:-${HOME}}/.zimrc"
|
2015-12-15 00:12:17 -05:00
|
|
|
fi
|
|
|
|
|
|
|
|
load_zim_module() {
|
|
|
|
local wanted_module
|
|
|
|
|
2015-12-19 09:48:29 -05:00
|
|
|
for wanted_module (${zmodules}); do
|
|
|
|
if [[ -s "${ZIM}/modules/${wanted_module}/init.zsh" ]]; then
|
|
|
|
source "${ZIM}/modules/${wanted_module}/init.zsh"
|
|
|
|
elif [[ ! -d "${ZIM}/modules/${wanted_module}" ]]; then
|
|
|
|
print "No such module \"${wanted_module}\"." >&2
|
2015-12-15 00:12:17 -05:00
|
|
|
fi
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
load_zim_function() {
|
|
|
|
local function_glob='^([_.]*|prompt_*_setup|README*)(-.N:t)'
|
|
|
|
local mod_function
|
|
|
|
|
|
|
|
# autoload searches fpath for function locations; add enabled module function paths
|
2015-12-30 10:14:10 -05:00
|
|
|
fpath=(${${zmodules}:+${ZIM}/modules/${^zmodules}/functions(/FN)} ${fpath})
|
2015-12-15 00:12:17 -05:00
|
|
|
|
|
|
|
function {
|
|
|
|
setopt LOCAL_OPTIONS EXTENDED_GLOB
|
|
|
|
|
2015-12-19 09:48:29 -05:00
|
|
|
for mod_function in ${ZIM}/modules/${^zmodules}/functions/${~function_glob}; do
|
2015-12-15 00:12:17 -05:00
|
|
|
autoload -Uz ${mod_function}
|
|
|
|
done
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-12-30 10:14:10 -05:00
|
|
|
# initialize zim modules
|
|
|
|
load_zim_function
|
|
|
|
load_zim_module
|
2015-12-15 00:12:17 -05:00
|
|
|
|
|
|
|
unset zmodules
|
2015-12-29 01:28:18 -05:00
|
|
|
unfunction load_zim_{module,function}
|