1
0
Fork 0
mirror of synced 2024-06-01 06:41:12 -04:00
zimfw/src/stage1/50_zimfw_compile.zsh.erb
Eric Nielsen dfe35e1bfa
Generate static init.zsh script \o/
to autoloads the functions and sources the scripts, instead of executing
zimfw during startup, and having it always figuring out what do to on
the fly.

This takes out the worry about zimfw interfering with the startup time,
and allows room to add more features to it. So, zstyle was replaced by a
custom zmodule function to define the modules, with the extra ability of
allowing users to set custom fpath paths, autoloaded functions and
sourced scripts per module.
2020-01-02 12:58:01 -05:00

32 lines
870 B
Plaintext

_zimfw_compile() {
setopt LOCAL_OPTIONS EXTENDED_GLOB
autoload -U zrecompile
local zdumpfile zdir zfile
# Compile the completion cache; significant speedup
zstyle -s ':zim:completion' dumpfile 'zdumpfile' || zdumpfile="<%= home %>/.zcompdump"
if [[ -f ${zdumpfile} ]]; then
zrecompile -p ${1} ${zdumpfile} || return 1
fi
# Compile .zshrc
zrecompile -p ${1} <%= home %>/.zshrc || return 1
# Compile autoloaded functions
for zdir in ${fpath}; do
[[ ${zdir} == (.|..) || ${zdir} == (.|..)/* ]] && continue
if [[ -w ${zdir:h} ]]; then
zrecompile -p ${1} ${zdir}.zwc ${zdir}/^(*.*)(N-.) || return 1
fi
done
# Compile scripts
for zfile in ${ZIM_HOME}/(^*test*/)#*.zsh{,-theme}(N-.); do
zrecompile -p ${1} ${zfile} || return 1
done
if [[ ${1} != -q ]]; then
print -P '%F{green}✓%f Done with compile.'
fi
}