style: fix fold markers, typos, and comments

- Fix function typos in asciidoc comments
- Fix asciidoc fold markers
- Fix function args typos/style in asciidoc comments

Signed-off-by: Vladislav Doster <mvdoster@gmail.com>
This commit is contained in:
Vladislav Doster 2022-10-30 05:04:06 -05:00
parent bc56e757db
commit 62c07b7326
5 changed files with 295 additions and 322 deletions

View file

@ -30,8 +30,7 @@
}
builtin eval "$___data"
}
# ]]]
} # ]]]
# FUNCTION: .zinit-service [[[
# Handles given service, i.e. obtains lock, runs it, or waits if no lock
#
@ -76,8 +75,8 @@
) || break
builtin read -t 1 ___tmp <>"${___fle:r}.fifo2"
done >>! "$ZSRV_WORK_DIR/$ZSRV_ID".log 2>&1
}
# ]]]
} # ]]]
# FUNCTION: .zinit-wrap-track-functions [[[
.zinit-wrap-track-functions() {
local user="$1" plugin="$2" id_as="$3" f
@ -99,8 +98,7 @@ function $f {
ZINIT[CUR_USR]= ZINIT[CUR_PLUGIN]= ZINIT[CUR_USPL2]=
}"
done
}
# ]]]
} # ]]]
#
# Dtrace
@ -122,7 +120,7 @@ function $f {
.zinit-tmp-subst-on dtrace
} # ]]]
# FUNCTION: .zinit-debug-stop [[[
# Stops Dtrace, i.e. session tracking for changes in Zsh state.
# Stops Dtrace (i.e., session tracking for changes in Zsh state).
.zinit-debug-stop() {
ZINIT[DTRACE]=0

View file

@ -700,13 +700,10 @@ ZINIT[EXTENDED_GLOB]=""
}
(( $? )) && cat
return 0
}
# ]]]
} # ]]]
# FUNCTION: .zinit-self-update [[[
# Updates Zinit code (does a git pull).
#
# User-action entry point.
# Updates Zinit code (does a git pull)
.zinit-self-update() {
builtin emulate -LR zsh ${=${options[xtrace]:#off}:+-o xtrace}
setopt extendedglob typesetsilent warncreateglobal
@ -763,9 +760,7 @@ ZINIT[EXTENDED_GLOB]=""
}
} # ]]]
# FUNCTION: .zinit-show-registered-plugins [[[
# Lists loaded plugins (subcommands list, lodaded).
#
# User-action entry point.
# Lists loaded plugins (subcommands list, lodaded)
.zinit-show-registered-plugins() {
builtin emulate -LR zsh ${=${options[xtrace]:#off}:+-o xtrace}
setopt extendedglob warncreateglobal typesetsilent noshortloops
@ -792,19 +787,17 @@ ZINIT[EXTENDED_GLOB]=""
done
} # ]]]
# FUNCTION: .zinit-unload [[[
# 0. Call the Zsh Plugin's Standard *_plugin_unload function
# 0. Call the code provided by the Zsh Plugin's Standard @zsh-plugin-run-at-update
# 1. Delete bindkeys (...)
# 2. Delete Zstyles
# 3. Restore options
# 4. Remove aliases
# 5. Restore Zle state
# 6. Unfunction functions (created by plugin)
# 7. Clean-up FPATH and PATH
# 8. Delete created variables
# 9. Forget the plugin
#
# User-action entry point.
# 1. call the zsh plugin's standard *_plugin_unload function
# 2. call the code provided by the zsh plugin's standard @zsh-plugin-run-at-update
# 3. delete bindkeys (...)
# 4. delete zstyles
# 5. restore options
# 6. remove aliases
# 7. restore zle state
# 8. unfunction functions (created by plugin)
# 9. clean-up fpath and path
# 10. delete created variables
# 11. forget the plugin
#
# $1 - plugin spec (4 formats: user---plugin, user/plugin, user, plugin)
# $2 - plugin (only when $1 - i.e. user - given)
@ -835,16 +828,10 @@ ZINIT[EXTENDED_GLOB]=""
typeset -g LASTREPORT
LASTREPORT=`.zinit-show-report "$1" "$2"`
#
# Call the Zsh Plugin's Standard *_plugin_unload function
#
(( ${+functions[${plugin}_plugin_unload]} )) && ${plugin}_plugin_unload
#
# Call the code provided by the Zsh Plugin's Standard @zsh-plugin-run-at-update
#
local -a tmp
local -A sice
tmp=( "${(z@)ZINIT_SICE[$uspl2]}" )
@ -858,10 +845,7 @@ ZINIT[EXTENDED_GLOB]=""
() { setopt localoptions noautopushd; builtin cd -q "$___oldcd"; }
fi
#
# 1. Delete done bindkeys
#
typeset -a string_widget
string_widget=( "${(z)ZINIT[BINDKEYS__$uspl2]}" )
local sw
@ -927,9 +911,7 @@ ZINIT[EXTENDED_GLOB]=""
fi
done
#
# 2. Delete created Zstyles
#
typeset -a pattern_style
pattern_style=( "${(z)ZINIT[ZSTYLES__$uspl2]}" )
@ -950,11 +932,8 @@ ZINIT[EXTENDED_GLOB]=""
zstyle -d "$ps_arr1" "$ps_arr2"
done
#
# 3. Restore changed options
#
# Paranoid, don't want bad key/value pair error
# paranoid, don't want bad key/value pair error
.zinit-diff-options-compute "$uspl2"
integer empty=0
.zinit-save-set-extendedglob
@ -978,10 +957,7 @@ ZINIT[EXTENDED_GLOB]=""
done
fi
#
# 4. Delete aliases
#
typeset -a aname_avalue
aname_avalue=( "${(z)ZINIT[ALIASES__$uspl2]}" )
local nv
@ -1075,10 +1051,11 @@ ZINIT[EXTENDED_GLOB]=""
if (( found_idx || found_idx2 ))
then
# Skip multiple loads of the same plugin
# TODO: Fully handle multiple plugin loads
# TODO: fully handle multiple plugin loads
if [[ "$oth_uspl2" != "$uspl2" ]]; then
to_process_plugin="$oth_uspl2"
break # Only the first one is needed
# only the first one is needed
break
fi
fi
done
@ -1092,9 +1069,8 @@ ZINIT[EXTENDED_GLOB]=""
if (( found_idx )) {
oth_orig_saved=( "${(z)${(Q)entry_splitted[found_idx]}}" )
local oth_fun="${oth_orig_saved[4]}"
# oth_orig_saved[2]="${(q)orig_saved2}" # not do this, because
# we don't want to call other
# plugin's function at any moment
# below is wrong because we don't want to call other plugins function at any moment
# oth_orig_saved[2]="${(q)orig_saved2}"
oth_orig_saved[5]="${(q)orig_saved3}" # chain up the widget
entry_splitted[found_idx]="${(q)${(j: :)oth_orig_saved}}"
ZINIT[WIDGETS_SAVED__$oth_uspl2]="${(j: :)entry_splitted}"
@ -1123,10 +1099,9 @@ ZINIT[EXTENDED_GLOB]=""
zle -N "$oth_prefix_uspl2_X" "${widgets[$prefix_X]#user:}"
fi
fi
# The alternate method
#skip_delete+=( "${match[1]}" )
#functions[$oth_fun]="${functions[$oth_fun]//[^\{[:space:]]#$orig_saved1/${match[1]}}"
# skip_delete+=( "${match[1]}" )
# functions[$oth_fun]="${functions[$oth_fun]//[^\{[:space:]]#$orig_saved1/${match[1]}}"
fi
else
(( quiet )) || builtin print "Restoring Zle widget $orig_saved1"
@ -1162,10 +1137,7 @@ ZINIT[EXTENDED_GLOB]=""
zle -D "$wid"
done
#
# 6. Unfunction
#
.zinit-diff-functions-compute "$uspl2"
typeset -a func
func=( "${(z)ZINIT[FUNCTIONS__$uspl2]}" )
@ -1183,14 +1155,9 @@ ZINIT[EXTENDED_GLOB]=""
(( ${+zshexit_functions} )) && zshexit_functions=( ${zshexit_functions[@]:#$f} )
done
#
# 7. Clean up FPATH and PATH
#
.zinit-diff-env-compute "$uspl2"
# Have to iterate over $path elements and
# skip those that were added by the plugin
# iterate over $path elements and skip those that were added by the plugin
typeset -a new elem p
elem=( "${(z)ZINIT[PATH__$uspl2]}" )
for p in "${path[@]}"; do
@ -1216,10 +1183,7 @@ ZINIT[EXTENDED_GLOB]=""
}
fpath=( "${new[@]}" )
#
# 8. Delete created variables
#
.zinit-diff-parameter-compute "$uspl2"
empty=0
.zinit-save-set-extendedglob
@ -1245,8 +1209,7 @@ ZINIT[EXTENDED_GLOB]=""
# Don't unset readonly variables
[[ ${(tP)k} == *-readonly(|-*) ]] && continue
# Don't unset arrays managed by add-zsh-hook,
# also ignore a few special parameters
# Don't unset arrays managed by add-zsh-hook, also ignore a few special parameters
# TODO: remember and remove hooks
case "$k" in
(chpwd_functions|precmd_functions|preexec_functions|periodic_functions|zshaddhistory_functions|zshexit_functions|zsh_directory_name_functions)
@ -1256,10 +1219,8 @@ ZINIT[EXTENDED_GLOB]=""
;;
esac
# Don't unset redefined variables, only newly defined
# "" means variable didn't exist before plugin load
# (didn't have a type).
# Do an exception for the prompt variables.
# Don't unset redefined variables, only newly defined "" means variable didn't exist before plugin load (didn't have a type).
# Do an exception for the prompt variables
if [[ $v1 = '""' || ( $k = (RPROMPT|RPS1|RPS2|PROMPT|PS1|PS2|PS3|PS4) && $v1 != $v2 ) ]]; then
found=0
for wl in "${whitelist[@]}"; do
@ -1270,9 +1231,7 @@ ZINIT[EXTENDED_GLOB]=""
done
if (( !found )); then
(( quiet )) || builtin print "Unsetting variable $k"
# Checked that 4.3.17 does support "--"
# There cannot be parameter starting with
# "-" but let's defensively use "--" here
# checked that 4.3.17 does support "--"; cannot be parameter starting with "-" but let's defensively use "--" here
unset -- "$k"
else
builtin print "Skipping unset of variable $k (whitelist)"
@ -1282,10 +1241,7 @@ ZINIT[EXTENDED_GLOB]=""
done
fi
#
# 9. Forget the plugin
#
if [[ "$uspl2" = "_dtrace/_dtrace" ]]; then
.zinit-clear-debug-report
(( quiet )) || builtin print "dtrace report saved to \$LASTREPORT"
@ -1296,13 +1252,10 @@ ZINIT[EXTENDED_GLOB]=""
.zinit-clear-report-for "$user" "$plugin"
(( quiet )) || builtin print "Plugin's report saved to \$LASTREPORT"
fi
} # ]]]
# FUNCTION: .zinit-show-report [[[
# Displays report of the plugin given.
#
# User-action entry point.
#
# $1 - plugin spec (4 formats: user---plugin, user/plugin, user (+ plugin in $2), plugin)
# $2 - plugin (only when $1 - i.e. user - given)
.zinit-show-report() {
@ -1823,8 +1776,7 @@ ZINIT[EXTENDED_GLOB]=""
}
return $retval
}
# ]]]
} # ]]]
# FUNCTION: .zinit-update-or-status-all [[[
# Updates (git pull) or does `git status` for all existing plugins.
# This includes also plugins that are not loaded into Zsh (but exist
@ -1974,7 +1926,7 @@ ZINIT[EXTENDED_GLOB]=""
return "$retval"
} # ]]]
# FUNCTION: .zinit-update-in-parallel [[[
# FUNCTION: .zinit-update-all-parallel [[[
.zinit-update-all-parallel() {
builtin emulate -LR zsh ${=${options[xtrace]:#off}:+-o xtrace}
setopt extendedglob warncreateglobal typesetsilent \
@ -1992,8 +1944,7 @@ ZINIT[EXTENDED_GLOB]=""
if (( OPTS[opt_-s,--snippets] || !OPTS[opt_-l,--plugins] )) {
for snip ( "${files[@]}" ) {
main_counter=main_counter-1
# The continue may cause the tail of processes to
# fall-through to the following plugins-specific `wait'
# The continue may cause the tail of processes to fall-through to the following plugins-specific `wait'
# Should happen only in a very special conditions
# TODO handle this
[[ ! -f ${snip:h}/url ]] && continue
@ -2073,8 +2024,7 @@ ZINIT[EXTENDED_GLOB]=""
}
# Shouldn't happen
# (( ${#PUAssocArray} > 0 )) && wait ${(k)PUAssocArray}
}
# ]]]
} # ]]]
# FUNCTION: .zinit-wait-for-update-jobs [[[
.zinit-wait-for-update-jobs() {
local tpe=$1
@ -2095,8 +2045,7 @@ ZINIT[EXTENDED_GLOB]=""
"${OPTS[value]}{obj} concurrent update jobs" \
"({msg2}${tpe}{obj}){…}{rst}"
}
}
# ]]]
} # ]]]
# FUNCTION: .zinit-show-zstatus [[[
# Shows Zinit status, i.e. number of loaded plugins,
# of available completions, etc.
@ -2239,8 +2188,7 @@ ZINIT[EXTENDED_GLOB]=""
(( sum += ZINIT[$entry] ))
done
builtin print "Total: $sum sec"
}
# ]]]
} # ]]]
# FUNCTION: .zinit-list-bindkeys [[[
.zinit-list-bindkeys() {
local uspl2 uspl2col sw first=1
@ -2292,9 +2240,7 @@ ZINIT[EXTENDED_GLOB]=""
fi
done
done
}
# ]]]
} # ]]]
# FUNCTION: .zinit-compiled [[[
# Displays list of plugins that are compiled.
#
@ -2698,7 +2644,6 @@ ZINIT[EXTENDED_GLOB]=""
return 0
} # ]]]
# FUNCTION: .zinit-cd [[[
# Jumps to plugin's directory (in Zinit's home directory).
#
@ -2744,8 +2689,7 @@ ZINIT[EXTENDED_GLOB]=""
arr=( "${(Q)${(z@)ZINIT_EXTS[$key]:-$ZINIT_EXTS2[$key]}[@]}" )
"${arr[5]}" "$1" "$2" $3 "$4" "$5" "${${key##(zinit|z-annex) hook:}%% <->}" delete:TODO
done
}
# ]]]
} # ]]]
# FUNCTION: .zinit-delete [[[
# Deletes plugin's or snippet's directory (in Zinit's home directory).
#
@ -2907,8 +2851,7 @@ builtin print -Pr \"\$ZINIT[col-obj]Done (with the exit code: \$_retval).%f%b\""
}
fi
return 0
}
# ]]]
} # ]]]
# FUNCTION: .zinit-changes [[[
# Shows `git log` of given plugin.
#
@ -3269,8 +3212,7 @@ EOF
list[-1]+=", located at ZINIT[SNIPPETS_DIR], i.e. ${ZINIT[SNIPPETS_DIR]}"
builtin print -rl -- "${list[@]}"
)
}
# ]]]
} # ]]]
# FUNCTION: .zinit-get-path [[[
# Returns path of given ID-string, which may be a plugin-spec
# (like "user/plugin" or "user" "plugin"), an absolute path
@ -3285,8 +3227,7 @@ EOF
.zinit-get-object-path plugin "$id_as"
return $(( 1 - reply[3] ))
}
# ]]]
} # ]]]
# FUNCTION: .zinit-recall [[[
.zinit-recall() {
builtin emulate -LR zsh ${=${options[xtrace]:#off}:+-o xtrace}
@ -3335,8 +3276,7 @@ EOF
fi
+zinit-deploy-message @rst
} || builtin print -r -- "No such plugin or snippet"
}
# ]]]
} # ]]]
# FUNCTION: .zinit-module [[[
# Function that has sub-commands passed as long-options (with two dashes, --).
# It's an attempt to plugin only this one function into `zinit' function
@ -3366,8 +3306,7 @@ EOF
builtin print -r "to be run. To display the instructions on loading the module, run:"
builtin print -r "\`zinit module info'."
fi
}
# ]]]
} # ]]]
# FUNCTION: .zinit-build-module [[[
# Performs ./configure && make on the module and displays information
# how to load the module in .zshrc.
@ -3411,8 +3350,7 @@ EOF
}
builtin print $EPOCHSECONDS >! "${ZINIT[MAN_DIR]}/COMPILED_AT"
)
}
# ]]]
} # ]]]
#
# Help function

View file

@ -22,6 +22,7 @@ builtin source "${ZINIT[BIN_DIR]}/zinit-side.zsh" || {
} # ]]]
# FUNCTION: .zinit-json-get-value [[[
# Wrapper around jq that return the value of a property
#
# $1: JSON structure
# $2: jq path
.zinit-json-get-value() {
@ -33,6 +34,7 @@ builtin source "${ZINIT[BIN_DIR]}/zinit-side.zsh" || {
# FUNCTION: .zinit-json-to-array [[[
# Wrapper around jq that sets key/values of an associative array, replicating
# the structure of a given JSON object
#
# $1: JSON structure
# $2: jq path
# $3: name of the associative array to store the key/value pairs in
@ -68,8 +70,7 @@ builtin source "${ZINIT[BIN_DIR]}/zinit-side.zsh" || {
pkgjson tmpfile=${$(mktemp):-${TMPDIR:-/tmp}/zsh.xYzAbc123}
local URL=https://raw.githubusercontent.com/${ZINIT[PACKAGES_REPO]}/${ver:-${ZINIT[PACKAGES_BRANCH]}}/${pkg}/package.json
# Consume, ie delete the ver ice to avoid being consumed again at
# git-clone time
# Consume (i.e., delete) the ver ice to avoid being consumed again at git-clone time
[[ -n "$ver" ]] && unset 'ICE[ver]'
local pro_sep="{rst}, {profile}" epro_sep="{error}, {profile}" \
@ -523,13 +524,13 @@ builtin source "${ZINIT[BIN_DIR]}/zinit-side.zsh" || {
} # ]]]
# FUNCTION: .zinit-install-completions [[[
# Installs all completions of given plugin. After that they are
# visible to `compinit'. Visible completions can be selectively
# visible to 'compinit'. Visible completions can be selectively
# disabled and enabled. User can access completion data with
# `clist' or `completions' subcommand.
# 'clist' or 'completions' subcommand.
#
# $1 - plugin spec (4 formats: user---plugin, user/plugin, user, plugin)
# $2 - plugin (only when $1 - i.e. user - given)
# $3 - if 1, then reinstall, otherwise only install completions that aren't there
# $2 - plugin if $1 (i.e., user) given
# $3 - if 1, then reinstall, otherwise only install completions that are not present
.zinit-install-completions() {
builtin emulate -LR zsh ${=${options[xtrace]:#off}:+-o xtrace}
setopt nullglob extendedglob warncreateglobal typesetsilent noshortloops
@ -549,10 +550,10 @@ builtin source "${ZINIT[BIN_DIR]}/zinit-side.zsh" || {
.zinit-exists-physically-message "$id_as" "" || return 1
# Symlink any completion files included in plugin's directory
# Symlink any completion files included in the plugin directory
typeset -a completions already_symlinked backup_comps
local c cfile bkpfile
# The plugin == . is a semi-hack/trick to handle `creinstall .' properly
# The plugin == . is a semi-hack/trick to handle 'creinstall .' properly
[[ $user == % || ( -z $user && $plugin == . ) ]] && \
completions=( "${plugin}"/**/_[^_.]*~*(*.zwc|*.html|*.txt|*.png|*.jpg|*.jpeg|*.js|*.md|*.yml|*.ri|_zsh_highlight*|/zsdoc/*|*.ps1)(DN^/) ) || \
completions=( "${ZINIT[PLUGINS_DIR]}/${id_as//\//---}"/**/_[^_.]*~*(*.zwc|*.html|*.txt|*.png|*.jpg|*.jpeg|*.js|*.md|*.yml|*.ri|_zsh_highlight*|/zsdoc/*|*.ps1)(DN^/) )
@ -561,7 +562,7 @@ builtin source "${ZINIT[BIN_DIR]}/zinit-side.zsh" || {
# Symlink completions if they are not already there
# either as completions (_fname) or as backups (fname)
# OR - if it's a reinstall
# OR - if its a reinstall
for c in "${completions[@]}"; do
cfile="${c:t}"
bkpfile="${cfile#_}"
@ -670,7 +671,7 @@ builtin source "${ZINIT[BIN_DIR]}/zinit-side.zsh" || {
if (( ${+commands[curl]} )); then
if [[ -n $progress ]]; then
command curl --progress-bar -fSL "$url" 2> >($ZINIT[BIN_DIR]/share/single-line.zsh >&2) || return 1
command curl --progress-bar -fSL "$url" 2> >(.zinit-single-line >&2) || return 1
else
command curl -fsSL "$url" || return 1
fi
@ -689,7 +690,7 @@ builtin source "${ZINIT[BIN_DIR]}/zinit-side.zsh" || {
} else {
if type curl 2>/dev/null 1>&2; then
if [[ -n $progress ]]; then
command curl --progress-bar -fSL "$url" 2> >($ZINIT[BIN_DIR]/share/single-line.zsh >&2) || return 1
command curl --progress-bar -fSL "$url" 2> >(.zinit-single-line >&2) || return 1
else
command curl -fsSL "$url" || return 1
fi
@ -910,10 +911,12 @@ builtin source "${ZINIT[BIN_DIR]}/zinit-side.zsh" || {
return 0
} # ]]]
# FUNCTION: .zinit-download-snippet [[[
# Downloads snippet  either a file with curl, wget, lftp or lynx,
# or a directory, with Subversion when svn-ICE is active. Github
# supports Subversion protocol and allows to clone subdirectories.
# This is used to provide a layer of support for Oh-My-Zsh and Prezto.
# Downloads snippet
# file with curl, wget, lftp or lynx,
# directory, with Subversion when svn-ICE is active.
#
# Github supports Subversion protocol and allows to clone subdirectories.
# This is used to provide a layer of support for Oh-My-Zsh and Prezto.
.zinit-download-snippet() {
builtin emulate -LR zsh ${=${options[xtrace]:#off}:+-o xtrace}
setopt extendedglob warncreateglobal typesetsilent
@ -1451,6 +1454,32 @@ builtin source "${ZINIT[BIN_DIR]}/zinit-side.zsh" || {
return $?
} # ]]]
# FUNCTION: .zinit-single-line [[[
# Display cURL progress bar on a single line
.zinit-single-line() {
emulate -LR zsh
setopt extendedglob noshortloops nowarncreateglobal rcquotes typesetsilent
local IFS= n=$'\n' r=$'\r' zero=$'\0'
{
command perl -pe 'BEGIN { $|++; $/ = \1 }; tr/\r\n/\n\0/' \
|| gstdbuf -o0 gtr '\r\n' '\n\0' \
|| stdbuf -o0 tr '\r\n' '\n\0';
print
} 2>/dev/null | while read -r line;
do
if [[ $line == *$zero* ]]; then
# cURL doesn't add a newline to progress bars
# print -nr -- "${r}${(l:COLUMNS:: :):-}${r}${line##*${zero}}"
print -nr -- "${r}${(l:COLUMNS:: :):-}${r}${line%${zero}}"
else
print -nr -- "${r}${(l:COLUMNS:: :):-}${r}${${line//[${r}${n}]/}%\%*}${${(M)line%\%}:+%}"
fi
done
print
} # ]]]
# FUNCTION: .zinit-get-latest-gh-r-url-part [[[
# Gets version string of latest release of given Github
# package. Connects to Github releases page.
@ -1944,8 +1973,9 @@ ziextract() {
)
} # ]]]
# FUNCTION: zpextract [[[
zpextract() { ziextract "$@"; }
# ]]]
zpextract() {
ziextract "$@"
} # ]]]
# FUNCTION: .zinit-at-eval [[[
.zinit-at-eval() {
local atpull="$1" atclone="$2"
@ -2075,17 +2105,16 @@ zicp() {
return $retval
)
return
}
} # ]]]
# FUNCTION: zimv [[[
zimv() {
local dir
if [[ $1 = (-d|--dir) ]] { dir=$2; shift 2; }
zicp --mv ${dir:+--dir} $dir "$@"
} # ]]]
# FUNCTION: .zinit-configure-run-autoconf [[[
# Called either because # flag given to configure'', or because
# there's no ./configure script. Runs autoconf, autoreconf,
# autogen.sh as needed.
# Called either because "#" flag given to configure'', or because
# theres no ./configure script. Runs autoconf, autoreconf, and autogen.sh as needed.
.zinit-configure-run-autoconf() {
local dir=$1 flags=$2
integer q
@ -2158,7 +2187,7 @@ ${${${(M)flags:#*\#*}:+$msg}:-$msg_}
fi
fi
} # ]]]
# FUNCTION: ∞zinit-reset-opt-hook [[[
# FUNCTION: ∞zinit-reset-hook [[[
∞zinit-reset-hook() {
# File
if [[ "$1" = plugin ]] {
@ -2359,7 +2388,7 @@ for its found {file}meson.build{pre} input file}:-because {flag}m{pre} \
∞zinit-make-hook() {
∞zinit-make-base-hook "$@" ""
} # ]]]
# FUNCTION: ∞zinit-make-hook [[[
# FUNCTION: ∞zinit-make-base-hook [[[
∞zinit-make-base-hook() {
[[ "$1" = plugin ]] && \
local dir="${5#%}" hook="$6" subtype="$7" ex="$8" || \

View file

@ -9,7 +9,8 @@
#
# $1 - plugin spec (4 formats: user---plugin, user/plugin, user, plugin)
# $2 - plugin (only when $1 - i.e. user - given)
# $REPLY = ANSI-colorified "user/plugin" string
#
# $REPLY - ANSI-colorified "user/plugin" string
.zinit-any-colorify-as-uspl2() {
.zinit-any-to-user-plugin "$1" "$2"
local user="${reply[-2]}" plugin="${reply[-1]}"
@ -78,7 +79,7 @@
# strip whitespace from beginning of url
___URL="${${___URL#"${___URL%%[! $'\t']*}"}%/}"
# snippet
.zinit-two-paths "$___URL"
local ___s_path="${reply[-4]}" ___s_svn="${reply[-3]}" ___path="${reply[-2]}" ___filename="${reply[-1]}" ___local_dir
@ -133,7 +134,6 @@
fi
local ___zinit_path="$___local_dir/._zinit"
# read disk-ice
local -A ___mdata
local ___key
@ -217,7 +217,6 @@
+zinit-message -r -- "{b}{error}0 <running now>{rst}{…}"
return 0
} # ]]]
# FUNCTION: .zinit-exists-physically [[[
# Checks if directory of given plugin exists in PLUGIN_DIR.
#
@ -266,7 +265,6 @@
fi
return 0
} # ]]]
# FUNCTION: .zinit-first [[[
# Finds the main file of plugin. There are multiple file name formats, they are
# ordered in order starting from more correct ones, and matched.
@ -306,17 +304,17 @@
# FUNCTION: .zinit-store-ices [[[
# Saves ice mods in given hash onto disk.
#
# $1 - directory where to create/delete files
# $1 - directory where to create or delete files
# $2 - name of hash that holds values
# $3 - additional keys of hash to store, space separated
# $4 - additional keys of hash to store, empty-meaningful ices, space separated
# $5 the URL, if applicable
# $6 the mode 1 - svn, 0 - single file), if applicable
# $5 URL, if applicable
# $6 mode, svn=1, 0=single file
.zinit-store-ices() {
local ___pfx="$1" ___ice_var="$2" ___add_ices="$3" ___add_ices2="$4"
local url="$5" mode="$6"
# Copy from .zinit-recall
# Copy from zinit-recall response
local -a ice_order nval_ices
ice_order=(
${(s.|.)ZINIT[ice-list]}
@ -370,7 +368,7 @@
# remove leading whitespace and trailing /
url="${${url#"${url%%[! $'\t']*}"}%/}"
url1=$url
url1=$url
url2=$url
.zinit-get-object-path snippet "$url1"

366
zinit.zsh
View file

@ -121,10 +121,11 @@ builtin autoload -Uz is-at-least
is-at-least 5.1 && ZINIT[NEW_AUTOLOAD]=1 || ZINIT[NEW_AUTOLOAD]=0
#is-at-least 5.4 && ZINIT[NEW_AUTOLOAD]=2
# Parameters - temporary substituting of functions. [[[
ZINIT[TMP_SUBST]=inactive ZINIT[DTRACE]=0 ZINIT[CUR_PLUGIN]=
# ]]]
# Parameters - ICE. [[[
# Parameters [[[
# temporary substituting of functions
ZINIT[TMP_SUBST]=inactive ZINIT[DTRACE]=0 ZINIT[CUR_PLUGIN]=
# ice
declare -gA ZINIT_1MAP ZINIT_2MAP
ZINIT_1MAP=(
OMZ:: https://github.com/ohmyzsh/ohmyzsh/trunk/
@ -144,7 +145,7 @@ ZINIT_2MAP=(
)
# ]]]
# Init. [[[
# Init [[[
zmodload zsh/zutil || { builtin print -P "%F{196}zsh/zutil module is required, aborting Zinit set up.%f"; return 1; }
zmodload zsh/parameter || { builtin print -P "%F{196}zsh/parameter module is required, aborting Zinit set up.%f"; return 1; }
zmodload zsh/terminfo 2>/dev/null
@ -196,7 +197,7 @@ if [[ -z $SOURCED && ( ${+terminfo} -eq 1 && -n ${terminfo[colors]} ) || \
}
}
# List of hooks.
# Hooks
typeset -gAH ZINIT_ZLE_HOOKS_LIST
ZINIT_ZLE_HOOKS_LIST=(
zle-isearch-exit 1
@ -208,16 +209,14 @@ ZINIT_ZLE_HOOKS_LIST=(
zle-keymap-select 1
paste-insert 1
)
builtin setopt noaliases
# ]]]
#
# Temporary substituting of functions-related functions.
#
# FUNCTION: :zinit-reload-and-run. [[[
# FUNCTION: :zinit-reload-and-run [[[
# Marks given function ($3) for autoloading, and executes it triggering the
# load. $1 is the fpath dedicated to the function, $2 are autoload options.
# This function replaces "autoload -X", because using that on older Zsh
@ -226,12 +225,12 @@ builtin setopt noaliases
# So basically one creates function stub that calls :zinit-reload-and-run()
# instead of "autoload -X".
#
# Author: Bart Schaefer
#
# $1 - FPATH dedicated to function
# $2 - autoload options
# $3 - function name (one that needs autoloading)
#
# Author: Bart Schaefer
:zinit-reload-and-run () {
:zinit-reload-and-run() {
local fpath_prefix="$1" autoload_opts="$2" func="$3"
shift 3
@ -251,12 +250,11 @@ builtin setopt noaliases
# User wanted to call the function, not only load it.
"$func" "$@"
} # ]]]
# FUNCTION: :zinit-tmp-subst-autoload. [[[
# Function defined to hijack plugin's calls to the `autoload' builtin.
# FUNCTION: :zinit-tmp-subst-autoload [[[
# Hijack plugin's calls to the 'autoload' builtin.
#
# The hijacking is not only to gather report data, but also to.
# run custom `autoload' function, that doesn't need FPATH.
:zinit-tmp-subst-autoload () {
# The hijacking gathers report data and runs custom `autoload' function, that doesn't need FPATH.
:zinit-tmp-subst-autoload() {
builtin emulate -LR zsh ${=${options[xtrace]:#off}:+-o xtrace}
builtin setopt extendedglob warncreateglobal typesetsilent rcquotes
local -a opts opts2 custom reply
@ -382,7 +380,7 @@ builtin setopt noaliases
return $retval
} # ]]]
# FUNCTION: :zinit-tmp-subst-bindkey. [[[
# FUNCTION: :zinit-tmp-subst-bindkey [[[
# Function defined to hijack plugin's calls to the `bindkey' builtin.
#
# The hijacking is to gather report data (which is used in unload).
@ -534,7 +532,7 @@ builtin setopt noaliases
builtin bindkey "${pos[@]}"
return $? # testable
} # ]]]
# FUNCTION: :zinit-tmp-subst-zstyle. [[[
# FUNCTION: :zinit-tmp-subst-zstyle [[[
# Function defined to hijack plugin's calls to the `zstyle' builtin.
#
# The hijacking is to gather report data (which is used in unload).
@ -574,7 +572,7 @@ builtin setopt noaliases
builtin zstyle "${pos[@]}"
return $? # testable
} # ]]]
# FUNCTION: :zinit-tmp-subst-alias. [[[
# FUNCTION: :zinit-tmp-subst-alias [[[
# Function defined to hijack plugin's calls to the `alias' builtin.
#
# The hijacking is to gather report data (which is used in unload).
@ -625,7 +623,7 @@ builtin setopt noaliases
builtin alias "${pos[@]}"
return $? # testable
} # ]]]
# FUNCTION: :zinit-tmp-subst-zle. [[[.
# FUNCTION: :zinit-tmp-subst-zle [[[.
# Function defined to hijack plugin's calls to the `zle' builtin.
#
# The hijacking is to gather report data (which is used in unload).
@ -684,7 +682,7 @@ builtin setopt noaliases
builtin zle "${pos[@]}"
return $? # testable
} # ]]]
# FUNCTION: :zinit-tmp-subst-compdef. [[[
# FUNCTION: :zinit-tmp-subst-compdef [[[
# Function defined to hijack plugin's calls to the `compdef' function.
# The hijacking is not only for reporting, but also to save compdef
# calls so that `compinit' can be called after loading plugins.
@ -696,11 +694,10 @@ builtin setopt noaliases
return 0 # testable
} # ]]]
# FUNCTION: .zinit-tmp-subst-on. [[[
# FUNCTION: .zinit-tmp-subst-on [[[
# Turn on temporary substituting of functions of builtins and functions according to passed
# mode ("load", "light", "light-b" or "compdef"). The temporary substituting of functions is
# to gather report data, and to hijack `autoload', `bindkey' and
# `compdef' calls.
# to gather report data, and to hijack 'autoload', 'bindkey' and 'compdef' calls.
.zinit-tmp-subst-on() {
local mode="$1"
@ -768,7 +765,7 @@ builtin setopt noaliases
builtin return 0
} # ]]]
# FUNCTION: .zinit-tmp-subst-off. [[[
# FUNCTION: .zinit-tmp-subst-off [[[
# Turn off temporary substituting of functions completely for a given mode ("load", "light",
# "light-b" (i.e. the `trackbinds' mode) or "compdef").
.zinit-tmp-subst-off() {
@ -814,8 +811,8 @@ builtin setopt noaliases
return 0
} # ]]]
# FUNCTION: pmodload. [[[
# {function:pmodload} Compatibility with Prezto. Calls can be recursive.
# FUNCTION: pmodload [[[
# Compatibility with Prezto. Calls can be recursive
(( ${+functions[pmodload]} )) || pmodload() {
local -A ices
(( ${+ICE} )) && ices=( "${(kv)ICE[@]}" teleid '' )
@ -832,14 +829,13 @@ builtin setopt noaliases
shift
fi
done
}
# ]]]
} # ]]]
#
# Diff functions.
#
# FUNCTION: .zinit-diff-functions. [[[
# FUNCTION: .zinit-diff-functions [[[
# Implements detection of newly created functions. Performs
# data gathering, computation is done in *-compute().
#
@ -855,7 +851,7 @@ builtin setopt noaliases
} || \
ZINIT[FUNCTIONS_AFTER__$uspl2]+=" ${(j: :)${(qk)functions[@]}}"
} # ]]]
# FUNCTION: .zinit-diff-options. [[[
# FUNCTION: .zinit-diff-options [[[
# Implements detection of change in option state. Performs
# data gathering, computation is done in *-compute().
#
@ -870,7 +866,7 @@ builtin setopt noaliases
} || \
ZINIT[OPTIONS_AFTER__$1]+=" ${(kv)options[@]}"
} # ]]]
# FUNCTION: .zinit-diff-env. [[[
# FUNCTION: .zinit-diff-env [[[
# Implements detection of change in PATH and FPATH.
#
# $1 - user/plugin (i.e. uspl2 format)
@ -895,7 +891,7 @@ builtin setopt noaliases
ZINIT[FPATH_AFTER__$1]+=" ${tmp[*]}"
}
} # ]]]
# FUNCTION: .zinit-diff-parameter. [[[
# FUNCTION: .zinit-diff-parameter [[[
# Implements detection of change in any parameter's existence and type.
# Performs data gathering, computation is done in *-compute().
#
@ -912,21 +908,20 @@ builtin setopt noaliases
ZINIT[PARAMETERS_AFTER__$1]+=" ${(j: :)${(qkv)parameters[@]}}"
}
} # ]]]
# FUNCTION: .zinit-diff. [[[
# FUNCTION: .zinit-diff [[[
# Performs diff actions of all types
.zinit-diff() {
.zinit-diff-functions "$1" "$2"
.zinit-diff-options "$1" "$2"
.zinit-diff-env "$1" "$2"
.zinit-diff-parameter "$1" "$2"
}
# ]]]
} # ]]]
#
# Utility functions.
#
# FUNCTION: .zinit-get-mtime-into. [[[
# FUNCTION: .zinit-get-mtime-into [[[
.zinit-get-mtime-into() {
if (( ZINIT[HAVE_ZSTAT] )) {
local -a arr
@ -936,14 +931,13 @@ builtin setopt noaliases
{ : ${(P)2::="$(stat -c %Y "$1")"}; } 2>/dev/null
}
} # ]]]
# FUNCTION: .zinit-any-to-user-plugin. [[[
# FUNCTION: .zinit-any-to-user-plugin [[[
# Allows elastic plugin-spec across the code.
#
# $1 - plugin spec (4 formats: user---plugin, user/plugin, user, plugin)
# $2 - plugin (only when $1 - i.e. user - given)
#
# Returns user and plugin in $reply.
#
# $REPLY - user and plugin
.zinit-any-to-user-plugin() {
builtin emulate -LR zsh ${=${options[xtrace]:#off}:+-o xtrace}
builtin setopt extendedglob typesetsilent noshortloops rcquotes \
@ -985,7 +979,7 @@ builtin setopt noaliases
return 0
} # ]]]
# FUNCTION: .zinit-any-to-pid. [[[
# FUNCTION: .zinit-any-to-pid [[[
.zinit-any-to-pid() {
builtin emulate -LR zsh ${=${options[xtrace]:#off}:+-o xtrace}
builtin setopt extendedglob typesetsilent noshortloops rcquotes \
@ -1016,7 +1010,7 @@ builtin setopt noaliases
return 0
} # ]]]
# FUNCTION: .zinit-util-shands-path. [[[
# FUNCTION: .zinit-util-shands-path [[[
# Replaces parts of path with %HOME, etc.
.zinit-util-shands-path() {
builtin emulate -LR zsh ${=${options[xtrace]:#off}:+-o xtrace}
@ -1029,7 +1023,7 @@ builtin setopt noaliases
REPLY=${${1/(#b)(#s)(%|)(${(~j:|:)${(@k)map:#$HOME}}|$HOME|)/$map[$match[2]]}}
return 0
} # ]]]
# FUNCTION: .zinit-find-other-matches. [[[
# FUNCTION: .zinit-find-other-matches [[[
# Plugin's main source file is in general `name.plugin.zsh'. However,
# there can be different conventions, if that file is not found, then
# this functions examines other conventions in the most sane order.
@ -1059,7 +1053,7 @@ builtin setopt noaliases
return $(( ${#reply} > 0 ? 0 : 1 ))
} # ]]]
# FUNCTION: .zinit-register-plugin. [[[
# FUNCTION: .zinit-register-plugin [[[
# Adds the plugin to ZINIT_REGISTERED_PLUGINS array and to the
# zsh_loaded_plugins array (managed according to the plugin standard:
# https://zdharma-continuum.github.io/Zsh-100-Commits-Club/Zsh-Plugin-Standard.html).
@ -1097,7 +1091,7 @@ builtin setopt noaliases
return ret
} # ]]]
# FUNCTION: .zinit-get-object-path. [[[
# FUNCTION: .zinit-get-object-path [[[
.zinit-get-object-path() {
local type="$1" id_as="$2" local_dir dirname
integer exists
@ -1129,9 +1123,8 @@ builtin setopt noaliases
REPLY="$local_dir${dirname:+/$dirname}"
return $(( 1 - exists ))
}
# ]]]
# FUNCTION: @zinit-substitute. [[[
} # ]]]
# FUNCTION: @zinit-substitute [[[
@zinit-substitute() {
builtin emulate -LR zsh ${=${options[xtrace]:#off}:+-o xtrace}
builtin setopt extendedglob warncreateglobal typesetsilent noshortloops
@ -1175,7 +1168,7 @@ builtin setopt noaliases
done
}
# ]]]
# FUNCTION: @zinit-register-annex. [[[
# FUNCTION: @zinit-register-annex [[[
# Registers the z-annex inside Zinit i.e. an Zinit extension
@zinit-register-annex() {
builtin emulate -LR zsh ${=${options[xtrace]:#off}:+-o xtrace}
@ -1191,10 +1184,9 @@ builtin setopt noaliases
integer index="${type##[%a-zA-Z:_!-]##}"
ZINIT_EXTS[ice-mods]="${ZINIT_EXTS[ice-mods]}${icemods:+|}${(j:|:)${(@)${(@s:|:)icemods}/(#b)(#s)(?)/$index-$match[1]}}"
}
}
# ]]]
# FUNCTION: @zinit-register-hook. [[[
# Registers the z-annex inside Zinit i.e. an Zinit extension
} # ]]]
# FUNCTION: @zinit-register-hook [[[
# Registers the z-annex inside Zinit (i.e., an Zinit extension)
@zinit-register-hook() {
builtin emulate -LR zsh ${=${options[xtrace]:#off}:+-o xtrace}
# zsh per default behaves differently in interactive sessions (escapes !) and
@ -1206,29 +1198,26 @@ builtin setopt noaliases
ZINIT_EXTS2[seqno]=$(( ${ZINIT_EXTS2[seqno]:-0} + 1 ))
ZINIT_EXTS2[$key${${(M)type#hook:}:+ ${ZINIT_EXTS2[seqno]}}]="${ZINIT_EXTS2[seqno]} z-annex-data: ${(q)name} ${(q)type} ${(q)handler} '' ${(q)icemods}"
ZINIT_EXTS2[ice-mods]="${ZINIT_EXTS2[ice-mods]}${icemods:+|}$icemods"
}
# ]]]
# FUNCTION: @zsh-plugin-run-on-update. [[[
} # ]]]
# FUNCTION: @zsh-plugin-run-on-unload [[[
# The Plugin Standard required mechanism, see:
# https://zdharma-continuum.github.io/Zsh-100-Commits-Club/Zsh-Plugin-Standard.html
@zsh-plugin-run-on-unload() {
ICE[ps-on-unload]="${(j.; .)@}"
.zinit-pack-ice "$id_as" ""
}
# ]]]
# FUNCTION: @zsh-plugin-run-on-update. [[[
} # ]]]
# FUNCTION: @zsh-plugin-run-on-update [[[
# The Plugin Standard required mechanism
@zsh-plugin-run-on-update() {
ICE[ps-on-update]="${(j.; .)@}"
.zinit-pack-ice "$id_as" ""
}
# ]]]
} # ]]]
#
# Remaining functions.
#
# FUNCTION: .zinit-prepare-home. [[[
# FUNCTION: .zinit-prepare-home [[[
# Creates all directories needed by Zinit, first checks if they
# already exist.
.zinit-prepare-home() {
@ -1287,12 +1276,13 @@ builtin setopt noaliases
command mkdir 2>/dev/null -p ${~ZINIT[MAN_DIR]}/man{1..9}
}
# Copy Zinit manpage so that man is able to find it
[[ ! -f $ZINIT[MAN_DIR]/man1/zinit.1 ]] && {
[[ ! -f $ZINIT[MAN_DIR]/man1/zinit.1 || \
$ZINIT[MAN_DIR]/man1/zinit.1 -ot $ZINIT[BIN_DIR]/doc/zinit.1 ]] && {
command mkdir -p $ZINIT[MAN_DIR]/man1
command cp $ZINIT[BIN_DIR]/doc/zinit.1 $ZINIT[MAN_DIR]/man1
command cp -f $ZINIT[BIN_DIR]/doc/zinit.1 $ZINIT[MAN_DIR]/man1
}
} # ]]]
# FUNCTION: .zinit-load-object. [[[
# FUNCTION: .zinit-load-object [[[
.zinit-load-object() {
local ___type="$1" ___id=$2
local -a ___opt
@ -1308,7 +1298,7 @@ builtin setopt noaliases
return __retval
}
# ]]]
# FUNCTION:.zinit-set-m-func() [[[
# FUNCTION: .zinit-set-m-func [[[
# Sets and withdraws the temporary, atclone/atpull time function `m`.
.zinit-set-m-func() {
if [[ $1 == set ]]; then
@ -1330,7 +1320,7 @@ builtin setopt noaliases
fi
} # ]]]
# FUNCTION: .zinit-load-snippet. [[[
# FUNCTION: .zinit-load-snippet [[[
# Implements the exposed-to-user action of loading a snippet.
#
# $1 - url (can be local, absolute path).
@ -1571,12 +1561,12 @@ builtin setopt noaliases
return retval
} # ]]]
# FUNCTION: .zinit-load. [[[
# FUNCTION: .zinit-load [[[
# Implements the exposed-to-user action of loading a plugin.
#
# $1 - plugin spec (4 formats: user---plugin, user/plugin, user, plugin)
# $2 - plugin name, if the third format is used
.zinit-load () {
.zinit-load() {
typeset -F 3 SECONDS=0
local ___mode="$3" ___limit="$4" ___rst=0 ___retval=0 ___key
.zinit-any-to-user-plugin "$1" "$2"
@ -1680,7 +1670,7 @@ builtin setopt noaliases
return ___retval
} # ]]]
# FUNCTION: .zinit-load-plugin. [[[
# FUNCTION: .zinit-load-plugin [[[
# Lower-level function for loading a plugin.
#
# $1 - user
@ -1835,9 +1825,8 @@ builtin setopt noaliases
return ___retval
} # ]]]
# FUNCTION: .zinit-compdef-replay. [[[
# Runs gathered compdef calls. This allows to run `compinit'
# after loading plugins.
# FUNCTION: .zinit-compdef-replay [[[
# Runs gathered compdef calls. This allows to run 'compinit' after loading plugins.
.zinit-compdef-replay() {
local quiet="$1"
typeset -a pos
@ -1863,7 +1852,7 @@ builtin setopt noaliases
return 0
} # ]]]
# FUNCTION: .zinit-compdef-clear. [[[
# FUNCTION: .zinit-compdef-clear [[[
# Implements user-exposed functionality to clear gathered compdefs.
.zinit-compdef-clear() {
local quiet="$1" count="${#ZINIT_COMPDEF_REPLAY}"
@ -1871,11 +1860,11 @@ builtin setopt noaliases
[[ $quiet = -q ]] || +zinit-message "Compdef-replay cleared (it had {num}${count}{rst} entries)."
} # ]]]
# FUNCTION: .zinit-add-report. [[[
# FUNCTION: .zinit-add-report [[[
# Adds a report line for given plugin.
#
# $1 - uspl2, i.e. user/plugin
# $2, ... - the text
# $2 - the text
.zinit-add-report() {
# Use zinit binary module if available.
[[ -n $1 ]] && { (( ${+builtins[zpmod]} && 0 )) && zpmod report-append "$1" "$2"$'\n' || ZINIT_REPORTS[$1]+="$2"$'\n'; }
@ -1883,7 +1872,7 @@ builtin setopt noaliases
return 0
} # ]]]
# FUNCTION: .zinit-add-fpath. [[[
# FUNCTION: .zinit-add-fpath [[[
.zinit-add-fpath() {
[[ $1 = (-f|--front) ]] && { shift; integer front=1; }
.zinit-any-to-user-plugin "$1" ""
@ -1897,9 +1886,9 @@ builtin setopt noaliases
}
} # ]]]
# FUNCTION: .zinit-run. [[[
# Run code inside plugin's folder
# It uses the `correct' parameter from upper's scope zinit().
# FUNCTION: .zinit-run [[[
# Run code inside plugins folder
# It uses the 'correct' parameter from uppers scope zinit().
.zinit-run() {
if [[ $1 = (-l|--last) ]]; then
{ set -- "${ZINIT[last-run-plugin]:-$(<${ZINIT[BIN_DIR]}/last-run-object.txt)}" "${@[2-correct,-1]}"; } &>/dev/null
@ -1927,9 +1916,9 @@ builtin setopt noaliases
fi
} # ]]]
# FUNCTION: +zinit-deploy-message. [[[
# Deploys a sub-prompt message to be displayed OR a `zle
# .reset-prompt' call to be invoked
# FUNCTION: +zinit-deploy-message [[[
# Deploys a sub-prompt message to be displayed OR a 'zle .reset-prompt'
# call to be invoked
+zinit-deploy-message() {
[[ $1 = <-> && ( ${#} = 1 || ( $2 = (hup|nval|err) && ${#} = 2 ) ) ]] && { zle && {
local alltext text IFS=$'\n' nl=$'\n'
@ -1941,14 +1930,14 @@ builtin setopt noaliases
return 0
}
local THEFD=13371337 hasw
# The expansion is: if there is @sleep: pfx, then use what's after.
# The expansion is: if there is @sleep: pfx, then use what is after.
# it, otherwise substitute 0
exec {THEFD} < <(LANG=C sleep $(( 0.01 + ${${${(M)1#@sleep:}:+${1#@sleep:}}:-0} )); builtin print -r -- ${1:#(@msg|@sleep:*)} "${@[2,-1]}"; )
command true # workaround a Zsh bug, see: https://www.zsh.org/mla/workers/2018/msg00966.html
builtin zle -F "$THEFD" +zinit-deploy-message
} # ]]]
# FUNCTION: .zinit-formatter-dbg. [[[
# FUNCTION: .zinit-formatter-dbg [[[
.zinit-formatter-dbg() {
builtin emulate -L zsh -o extendedglob
REPLY=
@ -1957,7 +1946,7 @@ builtin setopt noaliases
fi
} # ]]]
# FUNCTION: .zinit-formatter-auto. [[[
# FUNCTION: .zinit-formatter-auto [[[
.zinit-formatter-auto() {
emulate -L zsh -o extendedglob -o warncreateglobal -o typesetsilent
local out in=$1 i wrk match spaces rest
@ -1977,7 +1966,7 @@ builtin setopt noaliases
rest=$match[3]
wrk=${match[2]//---//}
REPLY=$wrk
# Is it a time ?
# Is it a time?
if [[ $wrk == ([[:space:]]##|(#s))[0-9.]##([[:space:]]##|(#e)) &&
$rest == ([[:space:]]#|(#s))[sm]([[:space:]]##*|(#e)) || $wrk == ([[:space:]]##|(#s))[0-9.]##[sm]([[:space:]]##|(#e)) ]]; then
REPLY=$ZINIT[col-time]$wrk$ZINIT[col-rst]
@ -1985,7 +1974,8 @@ builtin setopt noaliases
if [[ $wrk != *[sm]* ]]; then
rest=$ZINIT[col-time]${(M)rest##[[:space:]]#[sm]}$ZINIT[col-rst]${rest##[[:space:]]#[sm]}
fi
# Is it a number? TODO: differentiate floats
# Is it a number?
# TODO: differentiate floats
elif [[ $wrk == ([[:space:]]##|(#s))[0-9.]##([[:space:]]##|(#e)) ]]; then
REPLY=$ZINIT[col-num]$wrk$ZINIT[col-rst]
# Is it a URL?
@ -2024,7 +2014,7 @@ builtin setopt noaliases
REPLY=${out//$'\u00a0'/ }
} # ]]]
# FUNCTION: .zinit-formatter-pid. [[[
# FUNCTION: .zinit-formatter-pid [[[
.zinit-formatter-pid() {
builtin emulate -L zsh -o extendedglob ${=${options[xtrace]:#off}:+-o xtrace}
@ -2047,17 +2037,17 @@ builtin setopt noaliases
REPLY=$pbz$REPLY$kbz
} # ]]]
# FUNCTION: .zinit-formatter-bar. [[[
# FUNCTION: .zinit-formatter-bar [[[
.zinit-formatter-bar() {
.zinit-formatter-bar-util ─ bar
} # ]]]
# FUNCTION: .zinit-formatter-th-bar. [[[
# FUNCTION: .zinit-formatter-th-bar [[[
.zinit-formatter-th-bar() {
.zinit-formatter-bar-util ━ th-bar
} # ]]]
# FUNCTION: .zinit-formatter-bar-util. [[[
# FUNCTION: .zinit-formatter-bar-util [[[
.zinit-formatter-bar-util() {
if [[ $LANG == (#i)*utf-8* ]]; then
ch=$1
@ -2068,7 +2058,7 @@ builtin setopt noaliases
REPLY=$ZINIT[col-$2]${(pl:COLUMNS-1::$ch:):-}$ZINIT[col-rst]
} # ]]]
# FUNCTION: .zinit-formatter-url. [[[
# FUNCTION: .zinit-formatter-url [[[
.zinit-formatter-url() {
builtin emulate -LR zsh -o extendedglob ${=${options[xtrace]:#off}:+-o xtrace}
# 1:proto 3:domain/5:start 6:end-of-it 7:no-dot-domain 9:file-path
@ -2096,7 +2086,7 @@ builtin setopt noaliases
}
} # ]]]
# FUNCTION: +zinit-message-formatter [[[
# FUNCTION: .zinit-main-message-formatter [[[
.zinit-main-message-formatter() {
if [[ -z $1 && -z $2 && -z $3 ]]; then
REPLY=""
@ -2123,7 +2113,7 @@ builtin setopt noaliases
REPLY=$in_prepend${ZINIT[col-$2]:-$1}$influx$3$append
# Replace new lines with characters that work the same but are not
# deleted in the substitution $ (...) - vertical tab 0xB 13 in the system
# deleted in the substitution $ (...) - vertical tab 0xB <-> 13 in the system
# octagonal connected back carriage (015).
local nl=$'\n' vertical=$'\013' carriager=$'\015'
REPLY=${REPLY//$nl/$vertical$carriager}
@ -2131,7 +2121,7 @@ builtin setopt noaliases
# REPLY+="x(${3}…)"
} # ]]]
# FUNCTION: +zinit-message. [[[
# FUNCTION: +zinit-message [[[
+zinit-message() {
builtin emulate -LR zsh -o extendedglob ${=${options[xtrace]:#off}:+-o xtrace}
local opt msg
@ -2164,7 +2154,7 @@ $match[7]}:-${ZINIT[__last-formatter-code]}}}:+}}}//←→}
fi
} # ]]]
# FUNCTION: +zinit-prehelp-usage-message. [[[
# FUNCTION: +zinit-prehelp-usage-message [[[
+zinit-prehelp-usage-message() {
builtin emulate -LR zsh -o extendedglob ${=${options[xtrace]:#off}:+-o xtrace}
local cmd=$1 allowed=$2 sep="$ZINIT[col-msg2], $ZINIT[col-ehi]" \
@ -2209,18 +2199,15 @@ $match[7]}:-${ZINIT[__last-formatter-code]}}}:+}}}//←→}
"the list of the {cmd}subcommands$bcol.{rst}"
}
} # ]]]
# FUNCTION: +zinit-parse-opts. [[[
# FUNCTION: .zinit-parse-opts [[[
.zinit-parse-opts() {
builtin emulate -LR zsh -o extendedglob ${=${options[xtrace]:#off}:+-o xtrace}
reply=( "${(@)${@[2,-1]//([  $'\t']##|(#s))(#b)(${(~j.|.)${(@s.|.)___opt_map[$1]}})(#B)([  $'\t']##|(#e))/${OPTS[${___opt_map[${match[1]}]%%:*}]::=1}ß←↓→}:#1ß←↓→}" )
} # ]]]
#
# Ice support.
#
# Ice support
# FUNCTION: .zinit-ice. [[[
# FUNCTION: .zinit-ice [[[
# Parses ICE specification, puts the result into ICE global hash.
# The ice-spec is valid for next command only (i.e. it "melts"), but
# it can then stick to plugin and activate e.g. at update.
@ -2240,19 +2227,17 @@ $match[7]}:-${ZINIT[__last-formatter-code]}}}:+}}}//←→}
return retval
} # ]]]
# FUNCTION: .zinit-pack-ice. [[[
# FUNCTION: .zinit-pack-ice [[[
# Remembers all ice-mods, assigns them to concrete plugin. Ice spec
# is in general forgotten for second-next command (that's why it's
# called "ice" - it melts), however they glue to the object (plugin
# or snippet) mentioned in the next command for later use with e.g.
# `zinit update ...'.
# is in general forgotten for second-next command (i.e., ice melts quickly), however they
# glue to the object (plugin or snippet) mentioned in the next command for later use with (e.g. 'zinit update ...').
.zinit-pack-ice() {
ZINIT_SICE[$1${1:+${2:+/}}$2]+="${(j: :)${(qkv)ICE[@]}} "
ZINIT_SICE[$1${1:+${2:+/}}$2]="${ZINIT_SICE[$1${1:+${2:+/}}$2]# }"
return 0
} # ]]]
# FUNCTION: .zinit-load-ices. [[[
# FUNCTION: .zinit-load-ices [[[
.zinit-load-ices() {
local id_as="$1" ___key ___path
local -a ice_order
@ -2261,7 +2246,7 @@ $match[7]}:-${ZINIT[__last-formatter-code]}}}:+}}}//←→}
${(@)${(A@kons:|:)${ZINIT_EXTS[ice-mods]//\'\'/}}/(#s)<->-/}
)
___path="${ZINIT[PLUGINS_DIR]}/${id_as//\//---}"/._zinit
# TODO snippet's dir computation
# TODO: snippets dir computation
if [[ ! -d $___path ]] {
if ! .zinit-get-object-path snippet "${id_as//\//---}"; then
return 1
@ -2279,7 +2264,7 @@ $match[7]}:-${ZINIT[__last-formatter-code]}}}:+}}}//←→}
return 0
} # ]]]
# FUNCTION: .zinit-setup-params. [[[
# FUNCTION: .zinit-setup-params [[[
.zinit-setup-params() {
builtin emulate -LR zsh -o extendedglob ${=${options[xtrace]:#off}:+-o xtrace}
reply=( ${(@)${(@s.;.)ICE[param]}/(#m)*/${${MATCH%%(-\>|→|=\>)*}//((#s)[[:space:]]##|[[:space:]]##(#e))}${${(M)MATCH#*(-\>|→|=\>)}:+\=${${MATCH#*(-\>|→|=\>)}//((#s)[[:space:]]##|[[:space:]]##(#e))}}} )
@ -2290,18 +2275,18 @@ $match[7]}:-${ZINIT[__last-formatter-code]}}}:+}}}//←→}
# Turbo.
#
# FUNCTION: .zinit-run-task. [[[
# FUNCTION: .zinit-run-task [[[
# A backend, worker function of .zinit-scheduler. It obtains the tasks
# index and a few of its properties (like the type: plugin, snippet,
# service plugin, service snippet) and executes it first checking for
# additional conditions (like non-numeric wait'' ice).
#
# $1 - the pass number, either 1st or 2nd pass
# $2 - the time assigned to the task
# $3 - type: plugin, snippet, service plugin, service snippet
# $4 - task's index in the ZINIT[WAIT_ICE_...] fields
# $5 - mode: load or light
# $6 - the plugin-spec or snippet URL or alias name (from id-as'')
# $1 - current pass: 1 or 2
# $2 - time assigned to the task
# $3 - type: plugin, service plugin, service snippet, snippet
# $4 - tasks index in the ZINIT[WAIT_ICE_...] fields
# $5 - mode: load, light
# $6 - details: alias name (derived from id-as''), plugin-spec, or snippet URL
.zinit-run-task() {
local ___pass="$1" ___t="$2" ___tpe="$3" ___idx="$4" ___mode="$5" ___id="${(Q)6}" ___opt="${(Q)7}" ___action ___s=1 ___retval=0
@ -2350,15 +2335,14 @@ $match[7]}:-${ZINIT[__last-formatter-code]}}}:+}}}//←→}
[[ ${REPLY::=$___action} = \!* ]] && zle && zle .reset-prompt
return ___s
}
# ]]]
} # ]]]
# FUNCTION: .zinit-submit-turbo. [[[
# FUNCTION: .zinit-submit-turbo [[[
# If `zinit load`, `zinit light` or `zinit snippet` will be
# preceded with `wait', `load', `unload' or `on-update-of`/`subscribe'
# preceded with 'wait', 'load', 'unload' or 'on-update-of'/'subscribe'
# ice-mods then the plugin or snipped is to be loaded in turbo-mode,
# and this function adds it to internal data structures, so that
# @zinit-scheduler can run (load, unload) this as a task.
# and this function adds it to internal data structures. @zinit-scheduler uses the data to
# create load or unload tasks.
.zinit-submit-turbo() {
local tpe="$1" mode="$2" opt_uspl2="$3" opt_plugin="$4"
@ -2377,7 +2361,7 @@ $match[7]}:-${ZINIT[__last-formatter-code]}}}:+}}}//←→}
ZINIT_TASKS+=( "${${ICE[wait]:+0}:-1}+0+1 $tpe ${ZINIT[WAIT_IDX]} ${mode:-_} ${(q)id} ${opt_plugin:+${(q)opt_uspl2}}" )
fi
} # ]]]
# FUNCTION: -zinit_scheduler_add_sh. [[[
# FUNCTION: -zinit_scheduler_add_sh [[[
# Copies task into ZINIT_RUN array, called when a task timeouts.
# A small function ran from pattern in /-substitution as a math
# function.
@ -2390,14 +2374,14 @@ $match[7]}:-${ZINIT[__last-formatter-code]}}}:+}}}//←→}
return idx
fi
} # ]]]
# FUNCTION: @zinit-scheduler. [[[
# Searches for timeout tasks, executes them. There's an array of tasks
# FUNCTION: @zinit-scheduler [[[
# Searches for timeout tasks, executes them. Theres an array of tasks
# waiting for execution, this scheduler manages them, detects which ones
# should be run at current moment, decides to remove (or not) them from
# the array after execution.
#
# $1 - if "following", then it is non-first (second and more)
# invocation of the scheduler; this results in chain of `sched'
# invocation of the scheduler; this results in chain of 'sched'
# invocations that results in repetitive @zinit-scheduler activity.
#
# if "burst", then all tasks are marked timeout and executed one
@ -2405,7 +2389,6 @@ $match[7]}:-${ZINIT[__last-formatter-code]}}}:+}}}//←→}
# needs to install all turbo-mode plugins without any hesitation
# (delay), i.e. "burst" allows to run package installations from
# script, not from prompt.
#
@zinit-scheduler() {
integer ___ret="${${ZINIT[lro-data]%:*}##*:}"
# lro stands for lastarg-retval-option.
@ -2428,7 +2411,7 @@ $match[7]}:-${ZINIT[__last-formatter-code]}}}:+}}}//←→}
# Example entry:
# 1531252764+2+1 p 18 light zdharma/zsh-diff-so-fancy
#
# This either doesn't change ZINIT_TASKS entry - when
# This either doesnt change ZINIT_TASKS entry - when
# ___i is used in the ternary expression, or replaces
# an entry with "<no-data>", i.e. ZINIT_TASKS[1] entry.
integer ___idx1 ___idx2
@ -2472,9 +2455,9 @@ $match[7]}:-${ZINIT[__last-formatter-code]}}}:+}}}//←→}
# in "1531252764+2" and replace it with current time.
ZINIT_TASKS=( ${ZINIT_TASKS[@]/(#b)([0-9]##)(*)/$(( ${match[1]} <= 1 ? ${match[1]} : ___t ))${match[2]}} )
}
# There's a bug in Zsh: first sched call would not be issued
# Theres a bug in Zsh: first sched call would not be issued
# until a key-press, if "sched +1 ..." would be called inside
# zle -F handler. So it's done here, in precmd-handle code.
# zle -F handler. So its done here, in precmd-handle code.
sched +1 'ZINIT[lro-data]="$_:$?:${options[printexitvalue]}"; @zinit-scheduler following ${ZINIT[lro-data]%:*:*}'
AFD=13371337 # for older Zsh + noclobber option
@ -2513,9 +2496,9 @@ $match[7]}:-${ZINIT[__last-formatter-code]}}}:+}}}//←→}
# Exposed functions.
#
# FUNCTION: zinit. [[[
# Main function directly exposed to user, obtains subcommand and its
# arguments, has completion.
# FUNCTION: zinit [[[
# Entrypoint function directly exposed to user, consumes subcommands with respective arguments,
# and completion.
zinit() {
local -A ICE ZINIT_ICE
ICE=( "${(kv)ZINIT_ICES[@]}" )
@ -2526,7 +2509,7 @@ zinit() {
local -a match mbegin mend
local MATCH cmd ___q="\`" ___q2="'" IFS=$' \t\n\0'; integer MBEGIN MEND
# An annex's subcommand might use the reply vars.
# An annexs subcommand might use the reply vars.
match=( ${ZINIT_EXTS[(I)z-annex subcommand:$1]} )
if (( !${#match} )) {
local -a reply; local REPLY
@ -3117,43 +3100,71 @@ You can try to prepend {apo}${___q}{lhi}@{apo}'{error} to the ID if the last ice
return ___retval
} # ]]]
# FUNCTION: zicdreplay. [[[
# A function that can be invoked from within `atinit', `atload', etc.
# ice-mod. It works like `zinit cdreplay', which cannot be invoked
# from such hook ices.
zicdreplay() { .zinit-compdef-replay -q; }
# ]]]
# FUNCTION: zicdclear. [[[
# A wrapper for `zinit cdclear -q' which can be called from hook
# ices like the atinit'', atload'', etc. ices.
zicdclear() { .zinit-compdef-clear -q; }
# ]]]
# FUNCTION: zicompinit. [[[
# A function that can be invoked from within `atinit', `atload', etc.
# ice-mod. It runs `autoload compinit; compinit' and respects
# FUNCTION: zicdreplay [[[
# A function that can be invoked from within "atinit", "atload", etc.
# ice-mod. It works like "zinit cdreplay", which cannot be invoked from such hook ices
zicdreplay() {
.zinit-compdef-replay -q
} # ]]]
# FUNCTION: zicdclear [[[
# A wrapper for "zinit cdclear -q" which can be called from hook
# ices like the atinit"", atload"", etc. ices.
zicdclear() {
.zinit-compdef-clear -q
} # ]]]
# FUNCTION: zicompinit [[[
# A function that can be invoked from within "atinit", "atload", etc.
# ice-mod. It runs "autoload compinit; compinit" and respects
# ZINIT[ZCOMPDUMP_PATH] and ZINIT[COMPINIT_OPTS].
zicompinit() { autoload -Uz compinit; compinit -d ${ZINIT[ZCOMPDUMP_PATH]:-${ZDOTDIR:-$HOME}/.zcompdump} "${(Q@)${(z@)ZINIT[COMPINIT_OPTS]}}"; }
# ]]]
# FUNCTION: zicompdef. [[[
# Stores compdef for a replay with `zicdreplay' (turbo mode) or
# with `zinit cdreplay' (normal mode). An utility functton of
# an undefined use case.
zicompdef() { ZINIT_COMPDEF_REPLAY+=( "${(j: :)${(q)@}}" ); }
# ]]]
# FUNCTION: @autoload. [[[
zicompinit() {
autoload -Uz compinit
compinit -d ${ZINIT[ZCOMPDUMP_PATH]:-${ZDOTDIR:-$HOME}/.zcompdump} "${(Q@)${(z@)ZINIT[COMPINIT_OPTS]}}"
} # ]]]
# FUNCTION: zicompdef [[[
# Stores compdef for a replay with "zicdreplay" (turbo mode) or
# with "zinit cdreplay" (normal mode). An utility functton of an undefined use case.
zicompdef() {
ZINIT_COMPDEF_REPLAY+=( "${(j: :)${(q)@}}" )
} # ]]]
# FUNCTION: @autoload [[[
@autoload() {
:zinit-tmp-subst-autoload -Uz \
${(s: :)${${(j: :)${@#\!}}//(#b)((*)(->|=>|→)(*)|(*))/${match[2]:+$match[2] -S $match[4]}${match[5]:+${match[5]} -S ${match[5]}}}} \
${${${(@M)${@#\!}:#*(->|=>|→)*}}:+-C} ${${@#\!}:+-C}
${(s: :)${${(j: :)${@#\!}}//(#b)((*)(->|=>|→)(*)|(*))/${match[2]:+$match[2] \
-S $match[4]}${match[5]:+${match[5]} \
-S ${match[5]}}}} \
${${${(@M)${@#\!}:#*(->|=>|→)*}}:+-C} \
${${@#\!}:+-C}
} # ]]]
# Compatibility functions. [[[
zplugin() { zinit "$@"; }
zpcdreplay() { .zinit-compdef-replay -q; }
zpcdclear() { .zinit-compdef-clear -q; }
zpcompinit() { autoload -Uz compinit; compinit -d ${ZINIT[ZCOMPDUMP_PATH]:-${ZDOTDIR:-$HOME}/.zcompdump} "${(Q@)${(z@)ZINIT[COMPINIT_OPTS]}}"; }
zpcompdef() { ZINIT_COMPDEF_REPLAY+=( "${(j: :)${(q)@}}" ); }
# ]]]
#
# Compatibility functions
#
# FUNCTION: zplugin [[[
zplugin() {
zinit "$@"
} # ]]]
# FUNCTION: zpcdreplay [[[
zpcdreplay() {
.zinit-compdef-replay -q
} # ]]]
# FUNCTION: zpcdclear [[[
zpcdclear() {
.zinit-compdef-clear -q
} # ]]]
# FUNCTION: zpcompinit [[[
zpcompinit() {
autoload -Uz compinit
compinit -d ${ZINIT[ZCOMPDUMP_PATH]:-${ZDOTDIR:-$HOME}/.zcompdump} "${(Q@)${(z@)ZINIT[COMPINIT_OPTS]}}"
} # ]]]
# FUNCTION: zpcompdef [[[
zpcompdef() {
ZINIT_COMPDEF_REPLAY+=( "${(j: :)${(q)@}}" )
} # ]]]
#
# Source-executed code.
@ -3171,23 +3182,22 @@ functions -M -- zinit_scheduler_add 1 1 -zinit_scheduler_add_sh 2>/dev/null
zmodload zsh/zpty zsh/system 2>/dev/null
zmodload -F zsh/stat b:zstat 2>/dev/null && ZINIT[HAVE_ZSTAT]=1
# code. [[[
# code [[[
builtin alias zpl=zinit zplg=zinit zi=zinit zini=zinit
.zinit-prepare-home
# Remember source's timestamps for the automatic-reload feature.
# Remember source timestamps for the automatic-reload feature.
typeset -g ZINIT_TMP
for ZINIT_TMP ( "" -side -install -autoload ) {
.zinit-get-mtime-into "${ZINIT[BIN_DIR]}/zinit$ZINIT_TMP.zsh" "ZINIT[mtime$ZINIT_TMP]"
}
# Simulate existence of _local/zinit plugin.
# This will allow to cuninstall of its completion
# Simulate existence of _local/zinit plugin (enables cuninstall of related completions)
ZINIT_REGISTERED_PLUGINS=( _local/zinit "${(u)ZINIT_REGISTERED_PLUGINS[@]:#_local/zinit}" )
ZINIT[STATES___local/zinit]=1
# Inform Prezto that the compdef function is available.
# inform prezto that the compdef function is available.
zstyle ':prezto:module:completion' loaded 1
# Colorize completions for commands unload, report, creinstall, cuninstall.
@ -3224,9 +3234,9 @@ if [[ -e ${${ZINIT[BIN_DIR]}}/zmodules/Src/zdharma/zplugin.so ]] {
}
} # ]]]
# !atpull-pre.
# !atpull-pre
@zinit-register-hook "-r/--reset" hook:e-\!atpull-pre ∞zinit-reset-hook
# !atpull-post.
# !atpull-post
@zinit-register-hook "ICE[reset]" hook:e-\!atpull-post ∞zinit-reset-hook
@zinit-register-hook "atpull'!'" hook:e-\!atpull-post ∞zinit-atpull-e-hook
@ -3261,10 +3271,10 @@ if [[ -e ${${ZINIT[BIN_DIR]}}/zmodules/Src/zdharma/zplugin.so ]] {
# atclone-post.
@zinit-register-hook "compile-plugin" hook:atclone-post ∞zinit-compile-plugin-hook
# Create so that for sure no warncreateglobal warning is issued
# create so that for sure no warncreateglobal warning is issued
typeset -g REPLY
# A searchable menu of TAGS in current directory
# a searchable menu of tags for current directory
zinit null light-mode autoload'zi-browse-symbol' for %$ZINIT[BIN_DIR]
zle -N zi-browse-symbol
zle -N zi-browse-symbol-backwards zi-browse-symbol