[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
49
init.zsh
49
init.zsh
|
@ -9,44 +9,33 @@ if ! is-at-least 5.2; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Define zim location
|
# Define zim location
|
||||||
(( ! ${+ZIM_HOME} )) && export ZIM_HOME="${ZDOTDIR:-${HOME}}/.zim"
|
(( ! ${+ZIM_HOME} )) && export ZIM_HOME=${ZDOTDIR:-${HOME}}/.zim
|
||||||
|
|
||||||
# Source user configuration
|
# Source user configuration
|
||||||
if [[ -s "${ZDOTDIR:-${HOME}}/.zimrc" ]]; then
|
[[ -s ${ZDOTDIR:-${HOME}}/.zimrc ]] && source ${ZDOTDIR:-${HOME}}/.zimrc
|
||||||
source "${ZDOTDIR:-${HOME}}/.zimrc"
|
|
||||||
fi
|
|
||||||
|
|
||||||
load_zim_module() {
|
# Autoload module functions
|
||||||
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)'
|
|
||||||
local mod_function
|
local mod_function
|
||||||
|
setopt LOCAL_OPTIONS EXTENDED_GLOB
|
||||||
|
|
||||||
# autoload searches fpath for function locations; add enabled module function paths
|
# autoload searches fpath for function locations; add enabled module function paths
|
||||||
fpath=(${ZIM_HOME}/functions.zwc ${ZIM_HOME}/modules/prompt/functions ${fpath})
|
fpath=(${ZIM_HOME}/functions.zwc ${ZIM_HOME}/modules/prompt/functions ${fpath})
|
||||||
|
|
||||||
function {
|
for mod_function in ${ZIM_HOME}/modules/${^zmodules}/functions/^([_.]*|prompt_*_setup|README*)(-.N:t); do
|
||||||
setopt LOCAL_OPTIONS EXTENDED_GLOB
|
autoload -Uz ${mod_function}
|
||||||
|
done
|
||||||
for mod_function in ${ZIM_HOME}/modules/${^zmodules}/functions/${~function_glob}; do
|
|
||||||
autoload -Uz ${mod_function}
|
|
||||||
done
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# initialize zim modules
|
# Initialize modules
|
||||||
load_zim_function
|
() {
|
||||||
load_zim_module
|
local zmodule
|
||||||
|
|
||||||
unset zmodules
|
for zmodule (${zmodules}); do
|
||||||
unfunction load_zim_{module,function}
|
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
|
||||||
|
}
|
||||||
|
|
|
@ -8,38 +8,34 @@
|
||||||
#
|
#
|
||||||
|
|
||||||
(
|
(
|
||||||
local zim_mods=${ZIM_HOME}/modules
|
local file
|
||||||
setopt EXTENDED_GLOB
|
local zmodule
|
||||||
|
setopt LOCAL_OPTIONS EXTENDED_GLOB
|
||||||
autoload -U zrecompile
|
autoload -U zrecompile
|
||||||
|
|
||||||
# zcompile the completion cache; siginificant speedup.
|
|
||||||
for file in ${ZDOTDIR:-${HOME}}/.zcomp^(*.zwc)(.); do
|
|
||||||
zrecompile -pq ${file}
|
|
||||||
done
|
|
||||||
|
|
||||||
# zcompile .zshrc
|
# zcompile .zshrc
|
||||||
zrecompile -pq ${ZDOTDIR:-${HOME}}/.zshrc
|
zrecompile -pq ${ZDOTDIR:-${HOME}}/.zshrc
|
||||||
|
|
||||||
# zcompile all module init scripts
|
# zcompile enabled module autoloaded functions
|
||||||
for file in ${zim_mods}/*/init.zsh; do
|
zrecompile -pq ${ZIM_HOME}/functions ${ZIM_HOME}/modules/${^zmodules}/functions/^([_.]*|prompt_*_setup|README*|*.zwc)(-.N)
|
||||||
zrecompile -pq ${file}
|
|
||||||
|
# zcompile enabled module init scripts
|
||||||
|
for zmodule (${zmodules}); do
|
||||||
|
zrecompile -pq ${ZIM_HOME}/modules/${zmodule}/init.zsh
|
||||||
done
|
done
|
||||||
|
|
||||||
# zcompile all autoloaded functions
|
|
||||||
zrecompile -pq ${ZIM_HOME}/functions ${zim_mods}/*/functions/^([_.]*|prompt_*_setup|README*|*.zwc)(.)
|
|
||||||
|
|
||||||
# zcompile all prompt setup scripts
|
# 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}
|
zrecompile -pq ${file}
|
||||||
done
|
done
|
||||||
|
|
||||||
# syntax-highlighting
|
# 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}
|
zrecompile -pq ${file}
|
||||||
done
|
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
|
# 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