[template] zcompile only enabled modules
and don't zcompile the `.zcompdump` file in zlogin, since it's already being compiled by the completion module. We've been trying to zcompile it twice before this change. Also refactor the zim `init.zsh` script, and do not unset `zmodules` anymore because we need it in zlogin.
This commit is contained in:
parent
715f4a4e9c
commit
18696c67b3
2 changed files with 32 additions and 47 deletions
47
init.zsh
47
init.zsh
|
@ -9,44 +9,33 @@ if ! is-at-least 5.2; then
|
|||
fi
|
||||
|
||||
# Define zim location
|
||||
(( ! ${+ZIM_HOME} )) && export ZIM_HOME="${ZDOTDIR:-${HOME}}/.zim"
|
||||
(( ! ${+ZIM_HOME} )) && export ZIM_HOME=${ZDOTDIR:-${HOME}}/.zim
|
||||
|
||||
# Source user configuration
|
||||
if [[ -s "${ZDOTDIR:-${HOME}}/.zimrc" ]]; then
|
||||
source "${ZDOTDIR:-${HOME}}/.zimrc"
|
||||
fi
|
||||
[[ -s ${ZDOTDIR:-${HOME}}/.zimrc ]] && source ${ZDOTDIR:-${HOME}}/.zimrc
|
||||
|
||||
load_zim_module() {
|
||||
local wanted_module
|
||||
|
||||
for wanted_module (${zmodules}); do
|
||||
if [[ -s "${ZIM_HOME}/modules/${wanted_module}/init.zsh" ]]; then
|
||||
source "${ZIM_HOME}/modules/${wanted_module}/init.zsh"
|
||||
elif [[ ! -d "${ZIM_HOME}/modules/${wanted_module}" ]]; then
|
||||
print "No such module \"${wanted_module}\"." >&2
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
load_zim_function() {
|
||||
local function_glob='^([_.]*|prompt_*_setup|README*)(-.N:t)'
|
||||
# Autoload module functions
|
||||
() {
|
||||
local mod_function
|
||||
setopt LOCAL_OPTIONS EXTENDED_GLOB
|
||||
|
||||
# autoload searches fpath for function locations; add enabled module function paths
|
||||
fpath=(${ZIM_HOME}/functions.zwc ${ZIM_HOME}/modules/prompt/functions ${fpath})
|
||||
|
||||
function {
|
||||
setopt LOCAL_OPTIONS EXTENDED_GLOB
|
||||
|
||||
for mod_function in ${ZIM_HOME}/modules/${^zmodules}/functions/${~function_glob}; do
|
||||
for mod_function in ${ZIM_HOME}/modules/${^zmodules}/functions/^([_.]*|prompt_*_setup|README*)(-.N:t); do
|
||||
autoload -Uz ${mod_function}
|
||||
done
|
||||
}
|
||||
|
||||
# Initialize modules
|
||||
() {
|
||||
local zmodule
|
||||
|
||||
for zmodule (${zmodules}); do
|
||||
if [[ -s ${ZIM_HOME}/modules/${zmodule}/init.zsh ]]; then
|
||||
source ${ZIM_HOME}/modules/${zmodule}/init.zsh
|
||||
elif [[ ! -d ${ZIM_HOME}/modules/${zmodule} ]]; then
|
||||
print "No such module \"${zmodule}\"." >&2
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
# initialize zim modules
|
||||
load_zim_function
|
||||
load_zim_module
|
||||
|
||||
unset zmodules
|
||||
unfunction load_zim_{module,function}
|
||||
|
|
|
@ -8,38 +8,34 @@
|
|||
#
|
||||
|
||||
(
|
||||
local zim_mods=${ZIM_HOME}/modules
|
||||
setopt EXTENDED_GLOB
|
||||
local file
|
||||
local zmodule
|
||||
setopt LOCAL_OPTIONS EXTENDED_GLOB
|
||||
autoload -U zrecompile
|
||||
|
||||
# zcompile the completion cache; siginificant speedup.
|
||||
for file in ${ZDOTDIR:-${HOME}}/.zcomp^(*.zwc)(.); do
|
||||
zrecompile -pq ${file}
|
||||
done
|
||||
|
||||
# zcompile .zshrc
|
||||
zrecompile -pq ${ZDOTDIR:-${HOME}}/.zshrc
|
||||
|
||||
# zcompile all module init scripts
|
||||
for file in ${zim_mods}/*/init.zsh; do
|
||||
zrecompile -pq ${file}
|
||||
# zcompile enabled module autoloaded functions
|
||||
zrecompile -pq ${ZIM_HOME}/functions ${ZIM_HOME}/modules/${^zmodules}/functions/^([_.]*|prompt_*_setup|README*|*.zwc)(-.N)
|
||||
|
||||
# zcompile enabled module init scripts
|
||||
for zmodule (${zmodules}); do
|
||||
zrecompile -pq ${ZIM_HOME}/modules/${zmodule}/init.zsh
|
||||
done
|
||||
|
||||
# zcompile all autoloaded functions
|
||||
zrecompile -pq ${ZIM_HOME}/functions ${zim_mods}/*/functions/^([_.]*|prompt_*_setup|README*|*.zwc)(.)
|
||||
|
||||
# zcompile all prompt setup scripts
|
||||
for file in ${zim_mods}/prompt/functions/prompt_*_setup; do
|
||||
for file in ${ZIM_HOME}/modules/prompt/functions/prompt_*_setup; do
|
||||
zrecompile -pq ${file}
|
||||
done
|
||||
|
||||
# syntax-highlighting
|
||||
for file in ${zim_mods}/syntax-highlighting/external/highlighters/**^test-data/*.zsh; do
|
||||
for file in ${ZIM_HOME}/modules/syntax-highlighting/external/highlighters/**^test-data/*.zsh; do
|
||||
zrecompile -pq ${file}
|
||||
done
|
||||
zrecompile -pq ${zim_mods}/syntax-highlighting/external/zsh-syntax-highlighting.zsh
|
||||
zrecompile -pq ${ZIM_HOME}/modules/syntax-highlighting/external/zsh-syntax-highlighting.zsh
|
||||
|
||||
# zsh-histery-substring-search
|
||||
zrecompile -pq ${zim_mods}/history-substring-search/external/zsh-history-substring-search.zsh
|
||||
zrecompile -pq ${ZIM_HOME}/modules/history-substring-search/external/zsh-history-substring-search.zsh
|
||||
|
||||
) &!
|
||||
|
|
Loading…
Reference in a new issue