tarjoilija / zgen

A lightweight and simple plugin manager for ZSH
BSD 2-Clause "Simplified" License
1.5k stars 99 forks source link

Why is $fpath extended after sourcing plugins? #105

Open psprint opened 6 years ago

psprint commented 6 years ago

Hello, I saw one zgen-generated init.zsh and it contained fpath+=( ... code after the series of sources of plugins. I think this is problematic because plugins cannot use autoload functionality to use external-file functions. This is a very important feature of Zsh and plugins do use it, at least mine. Could fpath+=( ... be moved above sources of plugins? It would then be conforming to Oh-My-Zsh. It also extends fpath before sourcing plugins, and also runs compinit in that place, allowing plugins to use compdef call.

tekumara commented 4 years ago

I'm also running into this problem. I'm using zgen load scmbreeze/scm_breeze to load the scm_breeze plugin but it tries to call compdef and errors:

/Users/tekumara/.scm_breeze/lib/git/aliases.sh:192: command not found: compdef

This is happening because the plugin is sourced before compinit is run.

tekumara commented 4 years ago

For now, I am working around this by running compinit before zgen. Zgen detects this and doesn't run compinit itself.

autoload -Uz compinit && \
   compinit -C 

# load zgen
source "${HOME}/.zgen/zgen.zsh"