zgen icon indicating copy to clipboard operation
zgen copied to clipboard

Why is $fpath extended after sourcing plugins?

Open psprint opened this issue 6 years ago • 2 comments

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.

psprint avatar Jun 01 '18 07:06 psprint

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 avatar Dec 12 '19 10:12 tekumara

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"

tekumara avatar Dec 21 '19 09:12 tekumara