Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Speed up plugin source file detection #127

Merged
merged 2 commits into from
Apr 17, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 5 additions & 8 deletions zap.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,11 @@ fpath+="$ZAP_DIR/completion"
function plug() {

function _try_source() {
typeset -a extensions=(".plugin.zsh" ".zsh-theme" ".zsh")
for ext in "${extensions[@]}"; do
[[ -e "$plugin_dir/$plugin_name$ext" ]] && source "$plugin_dir/$plugin_name$ext" && return 0
[[ -e "$plugin_dir/${plugin_name#zsh-}$ext" ]] && source "$plugin_dir/${plugin_name#zsh-}$ext" && return 0
# If the plugin file has a different name than $plugin_name
plugin_filename=$(command ls $plugin_dir | grep $ext)
[[ -n $plugin_filename ]] && [[ $(echo $plugin_filename | wc -l) -eq 1 ]] && source "$plugin_dir/$plugin_filename" && return 0
done
local -a initfiles=(
$plugin_dir/${plugin_name}.{plugin.,}{z,}sh{-theme,}(N)
$plugin_dir/*.{plugin.,}{z,}sh{-theme,}(N)
)
(( $#initfiles )) && source $initfiles[1]
}

# If the absolute is a directory then source as a local plugin
Expand Down