Skip to content

nb.plugin.zsh: entry-point uses the retired shared Plugins-hash pattern #86

Description

@ss-o

Problem

`nb.plugin.zsh`'s entry-point boilerplate does:

```zsh
typeset -gA Plugins
Plugins[NB_DIR]="${0:h}"
```

This is the pattern PATTERNS.md's "Plugin entry-point skeleton" section
marks retired, and it also conflicts with the current Zsh Plugin Standard:

"Never place plugin state in a shared global `Plugins` hash."

Concretely: the assignment unconditionally overwrites `Plugins[NB_DIR]`
without snapshotting whether the key existed or its prior value, so there
is no way to restore caller state — and there is no unload function at
all, so nothing ever reverses this side effect.

Fix

Rebuild the entry point from the canonical scaffold at
`z-shell/.github:.github/skills/new-zsh-plugin/templates/plugin.plugin.zsh`,
which snapshots the pre-load `Plugins` key/value, tracks whether this load
owns the `fpath` append, and provides a real `nb_plugin_unload` that
reverses both. Needs the usual load/unload verification in an isolated
`zsh -f` shell with temp `HOME`/`ZDOTDIR` (test both an absent key and a
pre-existing value).

Related

Split out of #85 to keep that XDG-defaults change scoped and mechanical
cleanup separate from behavioral change, per z-shell/.github's AGENTS.md.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions