Skip to content

Commit

Permalink
feat: path/plugin access shorthands regenerate automatically, when ne…
Browse files Browse the repository at this point in the history
…eded
  • Loading branch information
psprint committed Sep 21, 2023
1 parent 2453050 commit 280d26a
Show file tree
Hide file tree
Showing 7 changed files with 187 additions and 184 deletions.
4 changes: 4 additions & 0 deletions _zinit
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ __zinit_commands(){
'update:Upgrade outdated plugins and snippets using the same options they were originally installed with'
'version:Print the version numbers of Zinit to standard output'
'zstatus:Overall Zinit status'
'xhop:Deploy a code snippet that jumps back'
'xclone:Git clone with animated progress bar'
'xgh-clone:GitHub clone with fancy progress, only user/repo required'
'xcon:A build console with support for opening files on errors'
)
_describe -t commands 'zinit commands' commands
} # ]]]
Expand Down
58 changes: 58 additions & 0 deletions functions/z4÷def-action-func
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#!/usr/bin/env zsh
z4÷def-action-func(){
builtin emulate -L zsh -o extendedglob \
-o warncreateglobal -o typesetsilent \
-o nopromptsubst

local TMP_PATH
foreach TMP_PATH ($ZINIT[PLUGINS_DIR]/*[[:alnum:]](N.,/,@)
$ZINIT[SNIPPETS_DIR]/*[[:alnum:]_÷-]~*/(http(|s)|ftp(s|)|scp|file)--*(N.,/,@)
$ZINIT[SNIPPETS_DIR]/(http(|s)|ftp(|s)|scp|file)--*/*[[:alnum:]_÷-](N.,/,@))
if [[ $TMP_PATH == $ZINIT[SNIPPETS_DIR](/*)# ]];then
local PID=${${TMP_PATH##$ZINIT[SNIPPETS_DIR]\/}//(#b)(http(s|)|ftp(|s)|file|scp)--/$match[1]://}
PID=${${PID//--//}:t}
else
local PID=${${TMP_PATH:t}//---//}
fi
local IDAS=${${TMP_PATH:t}//---//}
functions[@$PID]="
local OP=\$1 pos=(\"\$@[2,-1]\") ICE ICEV icest=()
if [[ -f ${(qqq)TMP_PATH%/}/._zinit/id-as ]];then
local IDAS=\$(<${(qqq)TMP_PATH%/}/._zinit/id-as)
[[ -z \$IDAS || \$IDAS == auto ]]&&IDAS=$PID
else
local IDAS=${(qqq)IDAS}
fi
case \$OP in
(cd|)
\${OP:-cd} -- ${(qqq)TMP_PATH}
;;
(load)
local -A ICE
.zinit-load-ices \$IDAS
foreach ICE ICEV (\"\${(@kv)ICE}\")
icest+=(\$ICE\$ICEV)
end
#print -- zinit \"\$icest[@]\" for @\$IDAS
zinit \"\$icest[@]\" for @\$IDAS
;;
(unload)
zinit unload \$IDAS \"\$pos[@]\"
;;
(update|status)
zinit \$OP \$IDAS \"\$pos[@]\"
;;
(dispose)
zinit delete -y \$IDAS
;;
(run|*)
[[ \$OP == run ]]&&OP=
(
builtin cd -q -- ${(qqq)TMP_PATH}
builtin eval \$OP \"\$pos[@]\"
)
;;
esac
"
end
}
13 changes: 13 additions & 0 deletions functions/z4÷def-gl-alias
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/usr/bin/env zsh
z4÷def-gl-alias(){

alias -g '[[:WRONGSTR:]]'='([[:cntrl:][:space:][:INCOMPLETE:][:INVALID:]]#|*[[:INCOMPLETE:][:INVALID:]]*|[[:cntrl:]]#|[^[:print:][:alnum:]]#)'

alias -g '[[:iNVALIDST:]]'='*[[:INCOMPLETE:][:INVALID:]]*'
alias -g '[[:IDSTR:]]'='(<->|[A-Za-z_][A-Za-z_0-9]#)'
alias -g '[[:PRINTSTR:]]'='([[:print:][:alnum:]]#)'
alias -g '[[:EMPTYSTR:]]'="[[:space:][:INCOMPLETE:][:INVALID:]$'\e\1'-$'\036']#"
alias -g '[[:EMINVSTR:]]'="([[:space:][:INCOMPLETE:][:INVALID:]$'\e\1'-$'\036'-g:(<->|[A-Za-z_][A-Za-z_0-9]#)]#|*[[:INCOMPLETE:][:INVALID:]]*)"
alias -g '[[:FUNCSTR:]]'="[[:space:]]#(function[[:space:]]##|)(#b)((#B)*)(#B)[[:space:]]#\([[:space:]]#\)([[:space:]]#\{|)*"

}
102 changes: 102 additions & 0 deletions functions/z4÷populate-dynamic-dir
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
#!/usr/bin/env zsh
z4÷populate-dynamic-dir(){
builtin emulate -L zsh -o extendedglob \
-o warncreateglobal -o typesetsilent \
-o nopromptsubst

z4_zdn_widget(){z4_directory_name_generic "$@";}
add-zsh-hook -U zsh_directory_name z4_zdn_widget
z4_dir_suffix() {
[[ $1 = 1 ]] || return

if [[ $LBUFFER[-1] != ']' ]]; then
if [[ $KEYS = [$'] \t\n/']## ]]; then
if [[ $LBUFFER[-1] == ':' ]];then
LBUFFER="$LBUFFER[1,-2]"
fi
LBUFFER+=${${${KEYS:#*\]*}:+\]}:-${kEYS//\]/}}
elif [[ $KEYS = (*[^[:print:]]*|[[:blank:]\;\&\|@]) ]]; then
LBUFFER="$LBUFFER[1,-2]"\]
fi
fi
}

typeset -Ag z4_zdn_top=() z4_zdn_level1=() z4_gitdir_zdn_level1=() \
z4_zdn_zplug_level1=(:default: z4_zdn_level1) \
z4_zdn_zsnip_level1=(:default: z4_zdn_level1)
zstyle ":zdn:z4_zdn_widget:" mapping z4_zdn_top
z4_zdn_top+=(
# Zinit4's system diectories
z $ZINIT[BIN_DIR]/:z4_gitdir_zdn_level1
z4 $ZINIT[BIN_DIR]/:z4_gitdir_zdn_level1
zbin $ZINIT[BIN_DIR]/:z4_gitdir_zdn_level1
z4bin $ZINIT[BIN_DIR]/:z4_gitdir_zdn_level1
zcompl $ZINIT[COMPLETIONS_DIR]
z4compl $ZINIT[COMPLETIONS_DIR]
zsnip $ZINIT[SNIPPETS_DIR]/:z4_zdn_zsnip_level1
z4snip $ZINIT[SNIPPETS_DIR]/:z4_zdn_zsnip_level1
zplug $ZINIT[PLUGINS_DIR]/:z4_zdn_zplug_level1
z4plug $ZINIT[PLUGINS_DIR]/:z4_zdn_zplug_level1
ztheme $ZINIT[THEME_DIR]
z4theme $ZINIT[THEME_DIR]
zcache $ZSH_CACHE_DIR
z4cache $ZSH_CACHE_DIR

bin $HOME/.local/bin
cfg ${XDG_CONFIG_HOME:-$HOME/.config}
cache ${XDG_CACHE_HOME:-$HOME/.cache}
data ${XDG_DATA_HOME:-$HOME/.local/share}

# Z-Prefix's words
zp $ZPFX
ZP $ZPFX
zpfx $ZPFX
ZPFX $ZPFX

# Default
#:default: /:z4_zdn_level1
)

z4_zdn_top+=(
zfun /(usr|)${ZINIT[BINPATH]%%[^\/]#\/[^\/]#}share/zsh/$ZSH_VERSION/functions(NY1)
zlib /(usr|)${ZINIT[BINPATH]%%[^\/]#\/[^\/]#}lib(|64)/zsh/$ZSH_VERSION(NY1)
)

z4_zdn_top[zfun]+="/:zsh_dir_level"

typeset -A -g zsh_dir_level1=(
cal Calendar ex Example ftpe MIME pro Prompts vcs VCS_Info
chpwd Chpwd exc Exceptions vari Misc zftp Zftp
cpctl Compctl math Math user Newuser tcp TCP zle Zle
)

local -a tmp
tmp=($ZINIT[SNIPPETS_DIR]/*[[:alnum:]_÷-]~*/(http(|s)|ftp(s|)|scp|file)--*(N.,/,@) $ZINIT[SNIPPETS_DIR]/(http(|s)|ftp(|s)|scp|file)--*/*[[:alnum:]_÷-](N.,/,@))
: ${tmp[@]//(#b)(*)/${z4_zdn_top[${${${match[1]//(http(s|)|ftp(|s)|file|scp)--/proto://}//--//}:t}]::=$match[1]}}
: ${tmp[@]//(#b)(*)/${z4_zdn_zsnip_level1[${${${match[1]//(http(s|)|ftp(|s)|file|scp)--/proto://}//--//}:t}]::=$match[1]}}

tmp=($ZINIT[PLUGINS_DIR]/*[[:alnum:]](N.,/,@))
: ${tmp[@]//(#b)(*)/${z4_zdn_top[${${match[1]:t}//---//}]::=$match[1]}}
: ${tmp[@]//(#b)(*)/${z4_zdn_zplug_level1[${${match[1]:t}//---//}]::=${match[1]:t}}}

z4_zdn_level1+=(
share share
lib lib
libexec libexec
bin bin
func functions
# scripts scripts
docs docs
src src
contrib contrib
)

z4_gitdir_zdn_level1+=(
share share
lib lib
libexec libexec
func functions
scripts scripts
doc doc
)
}
20 changes: 0 additions & 20 deletions libexec/fetch

This file was deleted.

5 changes: 5 additions & 0 deletions zinit-install.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -2517,6 +2517,11 @@ for its found {file}meson.build{pre} input file}:-because {flag}m{pre} \
}
}
} # ]]]
# FUNCTION: ∞zinit-func-dyn-dir-hook [[[
∞zinit-func-dyn-dir-hook() {
z4÷populate-dynamic-dir
z4÷def-action-func
} # ]]]
# FUNCTION: ∞zinit-atpull-e-hook [[[
∞zinit-atpull-e-hook() {
(( ${+ICE[atpull]} )) || return 0
Expand Down
Loading

0 comments on commit 280d26a

Please sign in to comment.