geometry-zsh / geometry

geometry is a minimal, fully customizable and composable zsh prompt theme
ISC License
920 stars 94 forks source link

Change custom plugins examples and guidelines #197

Closed desyncr closed 6 years ago

desyncr commented 6 years ago

Current documentation suggests for plugins to self register. Back then it was a good idea as it loaded plugins configuration-free.

Current implementation (right and left prompt pluggable) enables further customization and it makes sense to be able to tell the plugins to either load at the right or left prompt:

GEOMETRY_PROMPT_PLUGINS_SECONDARY=(custom_plugin ...)
# Or
GEOMETRY_PROMPT_PLUGINS_PRIMARY=(custom_plugin ...)

This conflicts with the current plugin loading approach as by default self-registration uses the SECONDARY prompt as target.

We do support both registration methods but should update the documentation to use the configuration approach rather than self-registration.

An example configuration would be such as:

# Add the plugin to a prompt, in this example "secondary"
GEOMETRY_PROMPT_PLUGINS_SECONDARY=(custom_plugin ...)

# Source the plugin script BEFORE geometry
source custom_plugin.zsh

# Finally source geometry theme
source geometry.zsh
desyncr commented 6 years ago

Actually there's a little fix needed for custom-plugins to be able to be configured by context.

frm commented 6 years ago

@desyncr can we label this as a nice first PR for people?

jedahan commented 6 years ago

Is there any case that someone would want to source a geometry plugin and it not be present in secondary prompt?

I would rather have us auto-put in secondary prompt, UNLESS it is defined to be in primary prompt by user.

So default configureless, but if you configure it overrides.

frm commented 6 years ago

Is there a way for this to happen though? You have to explicitly set it to the secondary or primary variable, right?

jedahan commented 6 years ago

we check in register function if plugin is currently in PRIMARY. if it is, we do nothing. if its not, we register to SECONDARY

i havent looked at the code in a while though, so i might be missing something obvious