Prefer the prezto module format
to avoid conflicts when we have Zim modules made to also be compatible with ohmyzsh, like https://github.com/zimfw/pvenv We don't want to be affected by the noise a `${module_name}.plugin.zsh` file creates, as we always want to source `init.zsh` when a module also has a `functions` subdir. Hope this better protects us from the "wild west out there".
This commit is contained in:
parent
1df02c57df
commit
f7c0bbeb36
4 changed files with 41 additions and 16 deletions
|
@ -7,7 +7,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
|
||||
## [Unreleased]
|
||||
|
||||
_No unreleased changes._
|
||||
### Fixed
|
||||
- Prefer the prezto module format when using defaults to initialize a module.
|
||||
This is the format we use in our Zim framework modules. It's is not well
|
||||
documented anywhere officially, but in short words a prezto module has:
|
||||
* a `functions` subdirectory that is added to the fpath by the framework,
|
||||
* files inside the `functions` subdirectory that are autoloaded by the
|
||||
framework (except for file names that match `_*` or `prompt_*_setup`),
|
||||
* an `init.zsh` file that is sourced by the framework.
|
||||
|
||||
## [1.4.2] - 2021-02-19
|
||||
|
||||
|
|
|
@ -132,15 +132,24 @@ Initialization options:
|
|||
_zfailed=1
|
||||
return 1
|
||||
fi
|
||||
if (( ! ${#zfpaths} )) zfpaths+=(${zdir}/functions(NF))
|
||||
local -ra prezto_fpaths=(${zdir}/functions(NF))
|
||||
local -ra prezto_scripts=(${zdir}/init.zsh(N))
|
||||
if (( ! ${#zfpaths} && ! ${#zcmds} && ${#prezto_fpaths} && ${#prezto_scripts} )); then
|
||||
# this follows the prezto module format, no need to check for other scripts
|
||||
zfpaths=(${prezto_fpaths})
|
||||
zcmds=("source ${^prezto_scripts[@]:A}")
|
||||
else
|
||||
if (( ! ${#zfpaths} )) zfpaths=(${prezto_fpaths})
|
||||
if (( ! ${#zcmds} )); then
|
||||
# get script with largest size (descending `O`rder by `L`ength, and return only `[1]` first)
|
||||
local -r zscript=(${zdir}/(init.zsh|${zmodule:t}.(zsh|plugin.zsh|zsh-theme|sh))(NOL[1]))
|
||||
zcmds=("source ${^zscript[@]:A}")
|
||||
fi
|
||||
fi
|
||||
if (( ! ${#zfunctions} )); then
|
||||
# _* functions are autoloaded by compinit
|
||||
# prompt_*_setup functions are autoloaded by promptinit
|
||||
zfunctions+=(${^zfpaths}/^(*~|*.zwc(|.old)|_*|prompt_*_setup)(N-.:t))
|
||||
fi
|
||||
if (( ! ${#zcmds} )); then
|
||||
local -r zscript=(${zdir}/(init.zsh|${zmodule:t}.(zsh|plugin.zsh|zsh-theme|sh))(NOL[1]))
|
||||
zcmds+=("source ${^zscript[@]:A}")
|
||||
zfunctions=(${^zfpaths}/^(*~|*.zwc(|.old)|_*|prompt_*_setup)(N-.:t))
|
||||
fi
|
||||
if (( ! ${#zfpaths} && ! ${#zfunctions} && ! ${#zcmds} )); then
|
||||
print -u2 -PR "%F{yellow}<%= warn %>${funcfiletrace[1]}:%B${zmodule}:%b Nothing found to be initialized. Customize the module name or initialization with %Bzmodule%b options.%f"$'\n\n'${zusage}
|
||||
|
|
|
@ -6,7 +6,7 @@ class Zim
|
|||
@home = "${ZDOTDIR:-${HOME}}"
|
||||
@min_zsh_version = "5.2"
|
||||
@startup_files_glob = ".z(shenv|profile|shrc|login|logout)"
|
||||
@version = "1.4.2"
|
||||
@version = "1.4.3-SNAPSHOT"
|
||||
@ellipsis = " ..."
|
||||
@okay = "%F{green})%f "
|
||||
@warn = "! "
|
||||
|
|
25
zimfw.zsh
25
zimfw.zsh
|
@ -239,15 +239,24 @@ Initialization options:
|
|||
_zfailed=1
|
||||
return 1
|
||||
fi
|
||||
if (( ! ${#zfpaths} )) zfpaths+=(${zdir}/functions(NF))
|
||||
local -ra prezto_fpaths=(${zdir}/functions(NF))
|
||||
local -ra prezto_scripts=(${zdir}/init.zsh(N))
|
||||
if (( ! ${#zfpaths} && ! ${#zcmds} && ${#prezto_fpaths} && ${#prezto_scripts} )); then
|
||||
# this follows the prezto module format, no need to check for other scripts
|
||||
zfpaths=(${prezto_fpaths})
|
||||
zcmds=("source ${^prezto_scripts[@]:A}")
|
||||
else
|
||||
if (( ! ${#zfpaths} )) zfpaths=(${prezto_fpaths})
|
||||
if (( ! ${#zcmds} )); then
|
||||
# get script with largest size (descending `O`rder by `L`ength, and return only `[1]` first)
|
||||
local -r zscript=(${zdir}/(init.zsh|${zmodule:t}.(zsh|plugin.zsh|zsh-theme|sh))(NOL[1]))
|
||||
zcmds=("source ${^zscript[@]:A}")
|
||||
fi
|
||||
fi
|
||||
if (( ! ${#zfunctions} )); then
|
||||
# _* functions are autoloaded by compinit
|
||||
# prompt_*_setup functions are autoloaded by promptinit
|
||||
zfunctions+=(${^zfpaths}/^(*~|*.zwc(|.old)|_*|prompt_*_setup)(N-.:t))
|
||||
fi
|
||||
if (( ! ${#zcmds} )); then
|
||||
local -r zscript=(${zdir}/(init.zsh|${zmodule:t}.(zsh|plugin.zsh|zsh-theme|sh))(NOL[1]))
|
||||
zcmds+=("source ${^zscript[@]:A}")
|
||||
zfunctions=(${^zfpaths}/^(*~|*.zwc(|.old)|_*|prompt_*_setup)(N-.:t))
|
||||
fi
|
||||
if (( ! ${#zfpaths} && ! ${#zfunctions} && ! ${#zcmds} )); then
|
||||
print -u2 -PR "%F{yellow}! ${funcfiletrace[1]}:%B${zmodule}:%b Nothing found to be initialized. Customize the module name or initialization with %Bzmodule%b options.%f"$'\n\n'${zusage}
|
||||
|
@ -319,7 +328,7 @@ _zimfw_compile() {
|
|||
}
|
||||
|
||||
_zimfw_info() {
|
||||
print -R 'zimfw version: '${_zversion}' (built at 2021-02-19 20:25:37 UTC, previous commit is 8afb0b9)'
|
||||
print -R 'zimfw version: '${_zversion}' (built at 2021-03-16 22:02:26 UTC, previous commit is 1df02c5)'
|
||||
print -R 'ZIM_HOME: '${ZIM_HOME}
|
||||
print -R 'Zsh version: '${ZSH_VERSION}
|
||||
print -R 'System info: '$(command uname -a)
|
||||
|
@ -366,7 +375,7 @@ _zimfw_upgrade() {
|
|||
}
|
||||
|
||||
zimfw() {
|
||||
local -r _zversion='1.4.2'
|
||||
local -r _zversion='1.4.3-SNAPSHOT'
|
||||
local -r zusage="Usage: %B${0}%b <action> [%B-q%b|%B-v%b]
|
||||
|
||||
Actions:
|
||||
|
|
Loading…
Reference in a new issue