Skip to content

Commit

Permalink
[perf/fix]: ✨ performance (#240)
Browse files Browse the repository at this point in the history
* feat: ✨ User/Device specific directories.

Global/Optional parameter specifications define where these files should be looked for by specifying one or more base directories relative to which files should be located. This allows for verification/creation/set user preferred/default paths.

* perf(library): 🚀 Project terms/words.

Correction/Collection of project terms/words to prevent namespace pollution. Used for docs/tests/automation and other maintenance/improvements.

* fix: ✅ register atpull hook.

Fix to correctly register atpull hooks during the exclamation mark expansion.
  • Loading branch information
ss-o authored Nov 12, 2022
1 parent 25a223e commit 04310b2
Show file tree
Hide file tree
Showing 6 changed files with 97 additions and 43 deletions.
2 changes: 1 addition & 1 deletion lib/_zi
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ commands=(
icemods:"Shows ice-modifiers registered by annex"
zstatus:"Check and provide status information"
times:"Statistics on plugin loading times"
self-update:"Updates and compiles ❮ ZI ❯"
self-update:"Updates and compiles ❮ Zi ❯"
help:"Usage information"
man:"Manpage"
load:"Load plugin"
Expand Down
2 changes: 1 addition & 1 deletion lib/templates/example-script
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ if [[ $PMSPEC != *f* ]] {
# RUN ON UPDATE CALL
# #̶ =̶=̶=̶ =̶=̶=̶ =̶=̶=̶ #̶
# 𝟝 - https://wiki.zshell.dev/community/zsh_plugin_standard#activity-indicator
# ZI will set the $zsh_loaded_plugins array to contain all previously loaded plugins
# Zi will set the $zsh_loaded_plugins array to contain all previously loaded plugins
# and the plugin currently being loaded, as the last element.
if [[ ${zsh_loaded_plugins[-1]} != */kalc && -z ${fpath[(r)${0:h}]} ]] {
fpath+=( "${0:h}" )
Expand Down
28 changes: 14 additions & 14 deletions lib/zsh/autoload.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# vim: ft=zsh sw=2 ts=2 et
#
# Copyright (c) 2016-2020 Sebastian Gniazdowski and contributors.
# Copyright (c) 2021 Salvydas Lukosius and Z-Shell ZI contributors.
# Copyright (c) 2021 Salvydas Lukosius and Z-Shell Community.

builtin source "${ZI[BIN_DIR]}/lib/zsh/side.zsh" || { builtin print -P "${ZI[col-error]}ERROR:%f%b Couldn't find ${ZI[col-obj]}/lib/zsh/side.zsh%f%b."; return 1; }
ZI[EXTENDED_GLOB]=""
Expand Down Expand Up @@ -471,7 +471,7 @@ ZI[EXTENDED_GLOB]=""
reply=( "${ZI[PLUGINS_DIR]}/$uspl"/**/_[^_.]*~*(*.zwc|*.html|*.txt|*.png|*.jpg|*.jpeg|*.js|*.md|*.yml|*.ri|_zsh_highlight*|/zsdoc/*|*.ps1)(DN) )
} # ]]]
# FUNCTION: .zi-check-comp-consistency [[[
#ZI ❯ creates symlink for each installed completion.
#Zi ❯ creates symlink for each installed completion.
# This function checks whether given completion (i.e. file like "_mkdir") is indeed a symlink.
# Backup file is a completion that is disabled - has the leading "_" removed.
#
Expand Down Expand Up @@ -624,13 +624,13 @@ ZI[EXTENDED_GLOB]=""
fi
} # ]]]
# FUNCTION: .zi-self-update [[[
# Updates ❮ ZI ❯ code (does a git pull).
# Updates ❮ Zi ❯ code (does a git pull).
#
# User-action entry point.
.zi-self-update() {
builtin emulate -LR zsh ${=${options[xtrace]:#off}:+-o xtrace}
builtin setopt extendedglob typesetsilent warncreateglobal
[[ $1 = -q ]] && +zi-message "{profile}Updating »»»»{rst} ❮ {happy}ZI{rst} ❯ {…}{rst}"
[[ $1 = -q ]] && +zi-message "{profile}Updating »»»»{rst} ❮ {happy}Zi{rst} ❯ {…}{rst}"
local nl=$'\n' escape=$'\x1b[' current_branch=$(command git rev-parse --abbrev-ref HEAD 2>/dev/null)
local -a lines
( builtin cd -q "$ZI[BIN_DIR]" && command git checkout $current_branch &>/dev/null && command git fetch --quiet && \
Expand All @@ -656,7 +656,7 @@ ZI[EXTENDED_GLOB]=""
}
)
if [[ $1 != -q ]] {
+zi-message "{profile}Compiling »»»{rst} ❮ {happy}ZI{rst} ❯ {…}{rst}"
+zi-message "{profile}Compiling »»»{rst} ❮ {happy}Zi{rst} ❯ {…}{rst}"
}
command rm -f ${ZI[BIN_DIR]}/*.zwc(DN)
command rm -f ${ZI[BIN_DIR]}/lib/zsh/*.zwc(DN)
Expand All @@ -667,7 +667,7 @@ ZI[EXTENDED_GLOB]=""
zcompile -U ${ZI[BIN_DIR]}/lib/zsh/additional.zsh
zcompile -U ${ZI[BIN_DIR]}/lib/zsh/git-process-output.zsh
# Load for the current session
[[ $1 != -q ]] && +zi-message "{profile}Reloading »»»{rst} ❮ {happy}ZI{rst} ❯ {…}{rst}"
[[ $1 != -q ]] && +zi-message "{profile}Reloading »»»{rst} ❮ {happy}Zi{rst} ❯ {…}{rst}"
source ${ZI[BIN_DIR]}/zi.zsh
source ${ZI[BIN_DIR]}/lib/zsh/side.zsh
source ${ZI[BIN_DIR]}/lib/zsh/install.zsh
Expand Down Expand Up @@ -1527,9 +1527,9 @@ ZI[EXTENDED_GLOB]=""
# Run annexes' atpull hooks (the before atpull[^!]…-ice ones).
# Block common for Git and gh-r plugins.
reply=(
${(on)ZI_EXTS2[(I)zi hook:no-e-\\\!atpull-pre <->]}
${(on)ZI_EXTS2[(I)zi hook:no-e-\!atpull-pre <->]}
${${ICE[atpull]:#\!*}:+${(on)ZI_EXTS[(I)z-annex hook:\!atpull-<-> <->]}}
${(on)ZI_EXTS2[(I)zi hook:no-e-\\\!atpull-post <->]}
${(on)ZI_EXTS2[(I)zi hook:no-e-\!atpull-post <->]}
)
for key in "${reply[@]}"; do
arr=( "${(Q)${(z@)ZI_EXTS[$key]:-$ZI_EXTS2[$key]}[@]}" )
Expand Down Expand Up @@ -1654,7 +1654,7 @@ ZI[EXTENDED_GLOB]=""
}
# Reload ZI?
if [[ $2 != restart ]] && (( ZI[mtime] + ZI[mtime-side] + ZI[mtime-install] + ZI[mtime-autoload] != sum )) {
+zi-message "{info2}Detected {rst}❮ {happy}ZI{rst} ❯ {info2}update in another session -" "{pre}reloading {rst}{…}"
+zi-message "{info2}Detected {rst}❮ {happy}Zi{rst} ❯ {info2}update in another session -" "{pre}reloading {rst}{…}"
source ${ZI[BIN_DIR]}/zi.zsh
source ${ZI[BIN_DIR]}/lib/zsh/side.zsh
source ${ZI[BIN_DIR]}/lib/zsh/install.zsh
Expand Down Expand Up @@ -1844,7 +1844,7 @@ ZI[EXTENDED_GLOB]=""
}
} # ]]]
# FUNCTION: .zi-show-zstatus [[[
# Shows ❮ ZI ❯ status, i.e. number of loaded plugins,
# Shows ❮ Zi ❯ status, i.e. number of loaded plugins,
# of available completions, etc.
#
# User-action entry point.
Expand Down Expand Up @@ -2370,7 +2370,7 @@ ZI[EXTENDED_GLOB]=""
} # ]]]

# FUNCTION: .zi-cd [[[
# Jumps to plugin's directory (in ❮ ZI ❯ home directory).
# Jumps to plugin's directory (in ❮ Zi ❯ home directory).
#
# User-action entry point.
#
Expand Down Expand Up @@ -2415,7 +2415,7 @@ ZI[EXTENDED_GLOB]=""
done
} # ]]]
# FUNCTION: .zi-delete [[[
# Deletes plugin's or snippet's directory (in ❮ ZI ❯ home directory).
# Deletes plugin's or snippet's directory (in ❮ Zi ❯ home directory).
#
# User-action entry point.
#
Expand Down Expand Up @@ -2851,7 +2851,7 @@ EOF
} # ]]]
# FUNCTION: .zi-list-compdef-replay [[[
# Shows recorded compdefs (called by plugins loaded earlier). Plugins often call `compdef' hoping
# for `compinit' being already ran. ❮ ZI ❯ solves this by recording compdefs.
# for `compinit' being already ran. ❮ Zi ❯ solves this by recording compdefs.
#
# User-action entry point.
.zi-list-compdef-replay() {
Expand Down Expand Up @@ -2973,7 +2973,7 @@ EOF
"{p}zi module{rst} {info}build{rst} {p}[--clean]{rst}{nl}" \
"{p}zi module{rst} {info}info{rst} {p}[--link]{rst}{nl}" \
"{nl}" \
"To start using the ❮ ZI ❯ Zsh module run{rst}{obj}:{rst}{nl}" \
"To start using the zpmod module run{rst}{obj}:{rst}{nl}" \
"{p}zi module{rst} {info}build{rst}{nl}" \
"Append {p}--clean{rst} to run {cmd}make distclean{rst}{nl}" \
"To display the instructions on loading the module, run{rst}{obj}:{rst}{nl}" \
Expand Down
8 changes: 4 additions & 4 deletions lib/zsh/install.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# vim: ft=zsh sw=2 ts=2 et
#
# Copyright (c) 2016-2020 Sebastian Gniazdowski and contributors.
# Copyright (c) 2021 Salvydas Lukosius and Z-Shell ZI contributors.
# Copyright (c) 2021 Salvydas Lukosius and Z-Shell Community.

builtin source "${ZI[BIN_DIR]}/lib/zsh/side.zsh" || { builtin print -P "${ZI[col-error]}ERROR:%f%b Couldn't find ${ZI[col-obj]}/lib/zsh/side.zsh%f%b."; return 1; }

Expand Down Expand Up @@ -580,8 +580,8 @@ builtin source "${ZI[BIN_DIR]}/lib/zsh/side.zsh" || { builtin print -P "${ZI[col
.zi-compinit 1 1 &>/dev/null
} # ]]]
# FUNCTION: .zi-compinit [[[
# User-exposed `compinit' frontend which first ensures that all completions managed by ❮ ZI ❯ are forgotten by Z-shell.
# After that it runs normal `compinit', which should more easily detect ❮ ZI ❯ completions.
# User-exposed `compinit' frontend which first ensures that all completions managed by ❮ Zi ❯ are forgotten by Z-shell.
# After that it runs normal `compinit', which should more easily detect ❮ Zi ❯ completions.
#
# No arguments.
.zi-compinit() {
Expand Down Expand Up @@ -822,7 +822,7 @@ builtin source "${ZI[BIN_DIR]}/lib/zsh/side.zsh" || { builtin print -P "${ZI[col
builtin emulate -LR zsh -o extendedglob
if { ! zcompile -U "$first" } {
+zi-message "{error}Warning{ehi}:{rst} Compilation failed. Don't worry, the plugin will work also without compilation"
+zi-message "{error}Warning{ehi}:{rst} Consider submitting an error report to ❮ ZI ❯ or to the plugin's author"
+zi-message "{error}Warning{ehi}:{rst} Consider submitting an error report to ❮ Zi ❯ or to the plugin's author"
} else {
+zi-message " {version}✔{rst}"
}
Expand Down
4 changes: 2 additions & 2 deletions lib/zsh/side.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@
# Rename Zinit > ZI
if [[ ! -d $___zi_path && -d $___local_dir/._zinit ]]; then
(
builtin print -Pr -- "${ZI[col-pre]}UPGRADING THE DIRECTORY STRUCTURE" "FOR THE ZI -> ZI RENAME…%f"
builtin print -Pr -- "${ZI[col-pre]}UPGRADING THE DIRECTORY STRUCTURE" "FOR THE ZINIT -> ZI RENAME…%f"
builtin cd -q ${ZI[PLUGINS_DIR]} || return 1
autoload -Uz zmv
( zmv -W '**/.zinit' '**/._zi' ) &>/dev/null
Expand Down Expand Up @@ -367,7 +367,7 @@
local recompile_request_ts="$(<${ZI[ZMODULES_DIR]}/zpmod/RECOMPILE_REQUEST)"
if [[ ${recompile_request_ts:-1} -gt ${compiled_at_ts:-0} ]]; then
+zi-message "{u-warn}WARNING{b-warn}:{rst}{msg} A {lhi}recompilation{rst}" \
"of the ❮ ZI ❯ module has been requested… {hi}Building{rst}…"
"of the zpmod module has been requested… {hi}Building{rst}…"
(( ${+functions[.zi-confirm]} )) || builtin source "${ZI[BIN_DIR]}/lib/zsh/autoload.zsh" || return 1
command make -C "${ZI[ZMODULES_DIR]}/zpmod" distclean &>/dev/null
.zi-module build &>/dev/null
Expand Down
Loading

0 comments on commit 04310b2

Please sign in to comment.