Skip to content

fix: lazy keys in mode "!", reload, named update of a cond = false plugin, and main detection - #55

Open
zuqini wants to merge 16 commits into
mainfrom
zpack.nvim-audit
Open

zuqini wants to merge 16 commits into
mainfrom
zpack.nvim-audit

Conversation

@zuqini

@zuqini zuqini commented Nov 12, 2026

Copy link
Copy Markdown
Owner

Fixes from an audit of the whole plugin, plus dead-code removal and a docs pass.

Fixes

  • keys: a lazy key in mode ! or !a now runs its rhs on the first press, and its proxy is released when the plugin loads another way.
  • hooks: :ZPack! build no longer runs a build for a plugin whose install was declined.
  • commands: :ZPack update <name> and :ZPack restore <name> accept a cond = false plugin, as the bulk forms already did.
  • reload: :ZPack reload drops every loaded module under the plugin's lua/, not only those in its main namespace, and no longer runs deactivate for a plugin that never loaded.
  • opts: a plugin whose lua/ holds exactly one top-level module uses it as main, as in lazy.nvim (none-ls.nvim, alpha-nvim).

Refactors

No behaviour change: two clears of always-empty augroups, a second sort of the startup packs, a branch that assigned nil into a fresh table, and a duplicated PluginInfo construction are removed.

Docs

  • Corrections: KeySpec [2] is optional and can be a string; build takes a list or false; a dev = true checkout is cloned, not used in place; plugin.main is set before config.
  • The long reference entries in doc/zpack.txt and the migration notes are split into short descriptions and lists.

Testing

  • Each fix has a test that fails on its parent commit. No existing test was changed.
  • luacheck and LuaLS are clean. The suite passes on nightly (1479) and v0.12.0 (1478).
  • zb check against the base: no lazy flips, structural or opts differences; one perf row (trig150 on 0.12) is flagged identically on main.

maparg() reads the mode `!` as normal mode, so the proxy of a key in mode
`!` or `!a` looked unmapped: the first press was swallowed, and the proxy
stayed when the plugin loaded another way. Both lookups now go through one
helper that asks for insert mode.
After a declined install `:ZPack! build` reported the plugin as not
registered, then ran its build with a nil plugin and counted it.
`:ZPack update <name>` and `:ZPack restore <name>` checked the name against
the tab-completion list, which leaves out plugins `cond` keeps unloaded, and
answered "not found in spec" for one the bulk update covers. They now ask the
registry.
`:ZPack reload` only looked at `package.loaded` keys under the plugin's
`main`, so `telescope._extensions.x` and other second namespaces stayed
stale. As in lazy.nvim, every module with a file under the plugin's `lua/`
is dropped.
`:ZPack reload` of a pending lazy plugin ran its teardown hook, which could
pull the plugin in through a `require` and configure it twice. As in
lazy.nvim, the hook runs only for a loaded plugin.
A plugin whose `lua/` holds one top-level module not named like it, as
none-ls.nvim's `null-ls`, got a "Could not determine main module" warning
and no `setup()`. lazy.nvim's get_main falls back to that module, so
LazyVim's none-ls extra relies on it.
setup() runs once, and state.lua creates LazyBuildPack and DeletePack
cleared; their only writers run after these lines.
register_all hands them over sorted with the same comparator, a total
order, and nothing in between changes a priority or an import order.
entry_to_info spelled the mid-install shape itself, which left
derive_status's own "installing" branch unreachable.
The KeySpec reference said `(function, required)`, against the type, the
code and `:h zpack-Spec.keys`.
It listed a `rev` field the API doesn't return, and lacked the
"installing" status and its nil `path`.
The vimdoc's Spec.build gave only string and function, and spec.md said
shell builds run via $SHELL, which hooks.lua avoids on purpose.
The reload and dev passages presented `dev = true` plus `:ZPack reload` as
the loop for iterating on a local checkout. `vim.pack` clones the checkout
into its data dir, so an edit reaches Neovim only after a commit and
`:ZPack update <name>`.
…efore `config`

`:ZPack update` and `:ZPack delete` complete the registered names, as the
restore entry already says, not every installed plugin. `plugin.main` is
resolved before `config` is called and is nil inside `opts` functions.
Several entries in the help file and the migration notes had grown into
single paragraphs listing every edge case. Split them into a short
description followed by lists, lead each command and field with what it
does, and say "as in lazy.nvim" in a sentence where a bare tag stood.
No behaviour is described differently.
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 this pull request may close these issues.

1 participant