Skip to content

Commit

Permalink
Support zstyle to customize zsh-defer repo
Browse files Browse the repository at this point in the history
  • Loading branch information
mattmc3 committed Jul 17, 2024
1 parent 620ded1 commit fd90f64
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
9 changes: 7 additions & 2 deletions functions/__antidote_bulk_clone
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,13 @@
#function __antidote_bulk_clone {
emulate -L zsh; setopt local_options $_adote_funcopts

# Allow the user to define zsh-defer repo in case they want to fork it.
local zsh_defer_bundle
zstyle -s ':antidote:defer' bundle 'zsh_defer_bundle' \
|| zsh_defer_bundle='romkatv/zsh-defer'

# get a list of clonable repos from a bundle file
$__adote_awkcmd '
$__adote_awkcmd -v ZSH_DEFER_BUNDLE=$zsh_defer_bundle '
BEGIN { RS="[\r\n]" }
# initialize vars
Expand All @@ -15,7 +20,7 @@
/^ *(#.+)?$/ { next }
# clone zsh-defer
/kind:defer/ { print "antidote-script --kind clone romkatv/zsh-defer &" }
/kind:defer/ { print "antidote-script --kind clone " ZSH_DEFER_BUNDLE " &" }
# handle user/repo and URL forms
$1~/^[^\/]+\/[^\/]+$/ { bundle=$1 }
Expand Down
7 changes: 5 additions & 2 deletions functions/antidote-script
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,14 @@

# handle defers
local source_cmd="source"
local zsh_defer_bundle
zstyle -s ':antidote:defer' bundle 'zsh_defer_bundle' \
|| zsh_defer_bundle='romkatv/zsh-defer'
if [[ "$o_kind[-1]" == "defer" ]]; then
source_cmd="${zsh_defer} source"
script+=(
'if ! (( $+functions[zsh-defer] )); then'
"$(antidote-script 'romkatv/zsh-defer' | __antidote_indent)"
"$(antidote-script $zsh_defer_bundle | __antidote_indent)"
'fi'
)
fi
Expand All @@ -123,7 +126,7 @@
else
script+=("fpath+=( ${bundle_path}/${o_autoload[-1]} )")
fi
script+=( "builtin autoload -Uz \$fpath[-1]/*(N.:t)" )
script+=("builtin autoload -Uz \$fpath[-1]/*(N.:t)")
fi

# generate load script
Expand Down

0 comments on commit fd90f64

Please sign in to comment.