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

Support Zsh plugin standard? #104

Open
psprint opened this issue May 6, 2018 · 2 comments · Fixed by jandamm/zgenom#35
Open

Support Zsh plugin standard? #104

psprint opened this issue May 6, 2018 · 2 comments · Fixed by jandamm/zgenom#35

Comments

@psprint
Copy link

psprint commented May 6, 2018

Hello!
There's attempt of mine to write down and clarify Zsh plugin standard. It follows Oh-My-Zsh unwritten standard, but solves a few issues like:

  1. Incompatibility with *_argzero options like no_function_argzero.
  2. Lack of indicator that plugin is loaded by a plugin manager.
  3. No help from plugin manager in handling of dependencies.
  4. No support for plugin unloading.
  5. etc.

For a plugin manager, a short list of needed changes is:

  1. Set ZERO parameter at plugin load time, equal to path to sourced script ($0 from within the script).
  2. Set LOADED_PLUGINS array to hold strings "user/plugin" of loaded plugins and the plugin being currently loaded.
  3. Set ZPFX to a prefix-like directory (/usr, /usr/local, /opt are examples of such directories). Zplug and Zplugin can do build-hooks and run Makefiles, providing ZPFX allows consistent and short hook-code.
  4. Call *_unload function if it's provided, if user requests plugin unload.

Zgen architecture is about generating script with sequence of source commands. With above commands, the script could look like:

typeset -ga LOADED_PLUGINS  # typeset, in case user turns on `warn_create_global`
typeset -g ZERO ZPFX="$HOME/.zgen/polaris"

LOADED_PLUGINS+=( "geometry-zsh/geometry" )
ZERO="$HOME/.zgen/.../geometry.plugin.zsh"
fpath+=( "$HOME/.zgen/.../geometry-zsh" )
source $HOME/.zgen/.../geometry.plugin.zsh

LOADED_PLUGINS+=( "zsh-users/zsh-autosuggestions" )
ZERO="$HOME/.zgen/.../zsh-autosuggestions.plugin.zsh"
fpath+=( "$HOME/.zgen/.../zsh-autosuggestions" )
source $HOME/.zgen/.../zsh-autosuggestions.plugin.zsh

...

I've sent a patch to Zsh and it was accepted, it uses realloc() for array appends and is faster than previous code anywhere in 10 to 1000 times, so I think there's no pain of lowering zgen's excellent performance. ZERO will release programmers' will to do tricks. So for example zgen could issue:

...
LOADED_PLUGINS+=( "geometry-zsh/geometry" )
ZERO="$HOME/.zgen/.../geometry.plugin.zsh"
fpath+=( "$HOME/.zgen/.../geometry-zsh" )
eval "$(<$HOME/.zgen/.../geometry.plugin.zsh)"
...

$ZPFX hints that despite performance-centered architecture of Zgen, it can still do build-time (installation, update) hooks and make use of $ZPFX (to run e.g. make PREFIX=$ZPFX install).

Does this make sense to you? Maybe you have ideas for extensions or modifications for the standard? It is located here:

http://zdharma.org/Zsh-100-Commits-Club/Zsh-Plugin-Standard.html

PRs can be submitted here.

@psprint
Copy link
Author

psprint commented Oct 25, 2019

I've created a PR with partial implementation (the most important parts) of the standard: #124.

@jandamm
Copy link

jandamm commented Nov 24, 2020

Hi @psprint,

I've forked zgen (see zgenom).

I'd like to support the zsh plugin standard but I'm not really sure of the benefit of most "rules".

  • $ZERO why not just use $0?
  • $LOADED_PLUGINS 👍
  • $ZPFX zgenom doesn't support hooks, what is the benefit of setting ZPFX when the hooks aren't used anyways?
  • *_unload zgenom doesn't allow to unload plugins.

See jandamm/zgenom#27

jandamm added a commit to jandamm/zgenom that referenced this issue Dec 11, 2020
1. Standardized $0 Handling              - Yes
2. Functions Directory                   - Yes
3. Binaries Directory                    - Sort of*
4. Unload Function                       - Doesn't apply
5. @zsh-plugin-run-on-unload Call        - Doesn't apply
6. @zsh-plugin-run-on-update Call        - No
7. Plugin Manager Activity Indicator     - Yes
8. Global Parameter ZPFX                 - Yes
9. Global Parameter holding capabilities - Yes

\* I don't think it is a good idea to automatically add every `bin`
folder to the PATH. If the user wants this `zgenom bin <repo>` does so.

Closes #27
Closes tarjoilija/zgen#104
Closes tarjoilija/zgen#124
jandamm added a commit to jandamm/zgenom that referenced this issue Dec 16, 2020
1. Standardized $0 Handling              - Yes
2. Functions Directory                   - Yes
3. Binaries Directory                    - Sort of*
4. Unload Function                       - Doesn't apply
5. @zsh-plugin-run-on-unload Call        - Doesn't apply
6. @zsh-plugin-run-on-update Call        - No
7. Plugin Manager Activity Indicator     - Yes
8. Global Parameter ZPFX                 - Yes
9. Global Parameter holding capabilities - Yes

\* I don't think it is a good idea to automatically add every `bin`
folder to the PATH. If the user wants this `zgenom bin <repo>` does so.

Closes #27
Closes tarjoilija/zgen#104
Closes tarjoilija/zgen#124
forivall pushed a commit to forivall/zgen that referenced this issue Aug 8, 2023
This solves the issue that some plugins use `compdef` but zgenom does
`compinit` after loading all plugins.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants