Skip to content

Commit 63afb16

Browse files
committed
feat: path/plugin access shorthands regenerate automatically, when needed
1 parent 2453050 commit 63afb16

File tree

7 files changed

+187
-184
lines changed

7 files changed

+187
-184
lines changed

_zinit

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,10 @@ __zinit_commands(){
5757
'update:Upgrade outdated plugins and snippets using the same options they were originally installed with'
5858
'version:Print the version numbers of Zinit to standard output'
5959
'zstatus:Overall Zinit status'
60+
'xhop:Deploy a code snippet that jumps back'
61+
'xclone:Git clone with animated progress bar'
62+
'xgh-clone:GitHub clone with fancy progress, only user/repo required'
63+
'xcon:A build console with support for opening files on errors'
6064
)
6165
_describe -t commands 'zinit commands' commands
6266
} # ]]]

functions/z4÷def-action-func

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
#!/usr/bin/env zsh
2+
z4÷def-action-func(){
3+
builtin emulate -L zsh -o extendedglob \
4+
-o warncreateglobal -o typesetsilent \
5+
-o nopromptsubst
6+
7+
local TMP_PATH
8+
foreach TMP_PATH ($ZINIT[PLUGINS_DIR]/*[[:alnum:]](N.,/,@)
9+
$ZINIT[SNIPPETS_DIR]/*[[:alnum:]_÷-]~*/(http(|s)|ftp(s|)|scp|file)--*(N.,/,@)
10+
$ZINIT[SNIPPETS_DIR]/(http(|s)|ftp(|s)|scp|file)--*/*[[:alnum:]_÷-](N.,/,@))
11+
if [[ $TMP_PATH == $ZINIT[SNIPPETS_DIR](/*)# ]];then
12+
local PID=${${TMP_PATH##$ZINIT[SNIPPETS_DIR]\/}//(#b)(http(s|)|ftp(|s)|file|scp)--/$match[1]://}
13+
PID=${${PID//--//}:t}
14+
else
15+
local PID=${${TMP_PATH:t}//---//}
16+
fi
17+
local IDAS=${${TMP_PATH:t}//---//}
18+
functions[@$PID]="
19+
local OP=\$1 pos=(\"\$@[2,-1]\") ICE ICEV icest=()
20+
if [[ -f ${(qqq)TMP_PATH%/}/._zinit/id-as ]];then
21+
local IDAS=\$(<${(qqq)TMP_PATH%/}/._zinit/id-as)
22+
[[ -z \$IDAS || \$IDAS == auto ]]&&IDAS=$PID
23+
else
24+
local IDAS=${(qqq)IDAS}
25+
fi
26+
case \$OP in
27+
(cd|)
28+
\${OP:-cd} -- ${(qqq)TMP_PATH}
29+
;;
30+
(load)
31+
local -A ICE
32+
.zinit-load-ices \$IDAS
33+
foreach ICE ICEV (\"\${(@kv)ICE}\")
34+
icest+=(\$ICE\$ICEV)
35+
end
36+
#print -- zinit \"\$icest[@]\" for @\$IDAS
37+
zinit \"\$icest[@]\" for @\$IDAS
38+
;;
39+
(unload)
40+
zinit unload \$IDAS \"\$pos[@]\"
41+
;;
42+
(update|status)
43+
zinit \$OP \$IDAS \"\$pos[@]\"
44+
;;
45+
(dispose)
46+
zinit delete -y \$IDAS
47+
;;
48+
(run|*)
49+
[[ \$OP == run ]]&&OP=
50+
(
51+
builtin cd -q -- ${(qqq)TMP_PATH}||return 1
52+
builtin eval \$OP \"\$pos[@]\"
53+
)
54+
;;
55+
esac
56+
"
57+
end
58+
}

functions/z4÷def-gl-alias

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/usr/bin/env zsh
2+
z4÷def-gl-alias(){
3+
4+
alias -g '[[:WRONGSTR:]]'='([[:cntrl:][:space:][:INCOMPLETE:][:INVALID:]]#|*[[:INCOMPLETE:][:INVALID:]]*|[[:cntrl:]]#|[^[:print:][:alnum:]]#)'
5+
6+
alias -g '[[:iNVALIDST:]]'='*[[:INCOMPLETE:][:INVALID:]]*'
7+
alias -g '[[:IDSTR:]]'='(<->|[A-Za-z_][A-Za-z_0-9]#)'
8+
alias -g '[[:PRINTSTR:]]'='([[:print:][:alnum:]]#)'
9+
alias -g '[[:EMPTYSTR:]]'="[[:space:][:INCOMPLETE:][:INVALID:]$'\e\1'-$'\036']#"
10+
alias -g '[[:EMINVSTR:]]'="([[:space:][:INCOMPLETE:][:INVALID:]$'\e\1'-$'\036'-g:(<->|[A-Za-z_][A-Za-z_0-9]#)]#|*[[:INCOMPLETE:][:INVALID:]]*)"
11+
alias -g '[[:FUNCSTR:]]'="[[:space:]]#(function[[:space:]]##|)(#b)((#B)*)(#B)[[:space:]]#\([[:space:]]#\)([[:space:]]#\{|)*"
12+
13+
}

functions/z4÷populate-dynamic-dir

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
#!/usr/bin/env zsh
2+
z4÷populate-dynamic-dir(){
3+
builtin emulate -L zsh -o extendedglob \
4+
-o warncreateglobal -o typesetsilent \
5+
-o nopromptsubst
6+
7+
z4_zdn_widget(){z4_directory_name_generic "$@";}
8+
add-zsh-hook -U zsh_directory_name z4_zdn_widget
9+
z4_dir_suffix() {
10+
[[ $1 = 1 ]] || return
11+
12+
if [[ $LBUFFER[-1] != ']' ]]; then
13+
if [[ $KEYS = [$'] \t\n/']## ]]; then
14+
if [[ $LBUFFER[-1] == ':' ]];then
15+
LBUFFER="$LBUFFER[1,-2]"
16+
fi
17+
LBUFFER+=${${${KEYS:#*\]*}:+\]}:-${kEYS//\]/}}
18+
elif [[ $KEYS = (*[^[:print:]]*|[[:blank:]\;\&\|@]) ]]; then
19+
LBUFFER="$LBUFFER[1,-2]"\]
20+
fi
21+
fi
22+
}
23+
24+
typeset -Ag z4_zdn_top=() z4_zdn_level1=() z4_gitdir_zdn_level1=() \
25+
z4_zdn_zplug_level1=(:default: z4_zdn_level1) \
26+
z4_zdn_zsnip_level1=(:default: z4_zdn_level1)
27+
zstyle ":zdn:z4_zdn_widget:" mapping z4_zdn_top
28+
z4_zdn_top+=(
29+
# Zinit4's system diectories
30+
z $ZINIT[BIN_DIR]/:z4_gitdir_zdn_level1
31+
z4 $ZINIT[BIN_DIR]/:z4_gitdir_zdn_level1
32+
zbin $ZINIT[BIN_DIR]/:z4_gitdir_zdn_level1
33+
z4bin $ZINIT[BIN_DIR]/:z4_gitdir_zdn_level1
34+
zcompl $ZINIT[COMPLETIONS_DIR]
35+
z4compl $ZINIT[COMPLETIONS_DIR]
36+
zsnip $ZINIT[SNIPPETS_DIR]/:z4_zdn_zsnip_level1
37+
z4snip $ZINIT[SNIPPETS_DIR]/:z4_zdn_zsnip_level1
38+
zplug $ZINIT[PLUGINS_DIR]/:z4_zdn_zplug_level1
39+
z4plug $ZINIT[PLUGINS_DIR]/:z4_zdn_zplug_level1
40+
ztheme $ZINIT[THEME_DIR]
41+
z4theme $ZINIT[THEME_DIR]
42+
zcache $ZSH_CACHE_DIR
43+
z4cache $ZSH_CACHE_DIR
44+
45+
bin $HOME/.local/bin
46+
cfg ${XDG_CONFIG_HOME:-$HOME/.config}
47+
cache ${XDG_CACHE_HOME:-$HOME/.cache}
48+
data ${XDG_DATA_HOME:-$HOME/.local/share}
49+
50+
# Z-Prefix's words
51+
zp $ZPFX
52+
ZP $ZPFX
53+
zpfx $ZPFX
54+
ZPFX $ZPFX
55+
56+
# Default
57+
#:default: /:z4_zdn_level1
58+
)
59+
60+
z4_zdn_top+=(
61+
zfun /(usr|)${ZINIT[BINPATH]%%[^\/]#\/[^\/]#}share/zsh/$ZSH_VERSION/functions(NY1)
62+
zlib /(usr|)${ZINIT[BINPATH]%%[^\/]#\/[^\/]#}lib(|64)/zsh/$ZSH_VERSION(NY1)
63+
)
64+
65+
z4_zdn_top[zfun]+="/:zsh_dir_level"
66+
67+
typeset -A -g zsh_dir_level1=(
68+
cal Calendar ex Example ftpe MIME pro Prompts vcs VCS_Info
69+
chpwd Chpwd exc Exceptions vari Misc zftp Zftp
70+
cpctl Compctl math Math user Newuser tcp TCP zle Zle
71+
)
72+
73+
local -a tmp
74+
tmp=($ZINIT[SNIPPETS_DIR]/*[[:alnum:]_÷-]~*/(http(|s)|ftp(s|)|scp|file)--*(N.,/,@) $ZINIT[SNIPPETS_DIR]/(http(|s)|ftp(|s)|scp|file)--*/*[[:alnum:]_÷-](N.,/,@))
75+
: ${tmp[@]//(#b)(*)/${z4_zdn_top[${${${match[1]//(http(s|)|ftp(|s)|file|scp)--/proto://}//--//}:t}]::=$match[1]}}
76+
: ${tmp[@]//(#b)(*)/${z4_zdn_zsnip_level1[${${${match[1]//(http(s|)|ftp(|s)|file|scp)--/proto://}//--//}:t}]::=$match[1]}}
77+
78+
tmp=($ZINIT[PLUGINS_DIR]/*[[:alnum:]](N.,/,@))
79+
: ${tmp[@]//(#b)(*)/${z4_zdn_top[${${match[1]:t}//---//}]::=$match[1]}}
80+
: ${tmp[@]//(#b)(*)/${z4_zdn_zplug_level1[${${match[1]:t}//---//}]::=${match[1]:t}}}
81+
82+
z4_zdn_level1+=(
83+
share share
84+
lib lib
85+
libexec libexec
86+
bin bin
87+
func functions
88+
# scripts scripts
89+
docs docs
90+
src src
91+
contrib contrib
92+
)
93+
94+
z4_gitdir_zdn_level1+=(
95+
share share
96+
lib lib
97+
libexec libexec
98+
func functions
99+
scripts scripts
100+
doc doc
101+
)
102+
}

libexec/fetch

Lines changed: 0 additions & 20 deletions
This file was deleted.

zinit-install.zsh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2517,6 +2517,11 @@ for its found {file}meson.build{pre} input file}:-because {flag}m{pre} \
25172517
}
25182518
}
25192519
} # ]]]
2520+
# FUNCTION: ∞zinit-func-dyn-dir-hook [[[
2521+
∞zinit-func-dyn-dir-hook() {
2522+
z4÷populate-dynamic-dir
2523+
z4÷def-action-func
2524+
} # ]]]
25202525
# FUNCTION: ∞zinit-atpull-e-hook [[[
25212526
∞zinit-atpull-e-hook() {
25222527
(( ${+ICE[atpull]} )) || return 0

0 commit comments

Comments
 (0)