8000 fix: lazy keys in mode "!", reload, named update of a cond = false plugin, and main detection by zuqini · Pull Request #55 · zuqini/zpack.nvim · GitHub
[go: up one dir, main page]

Skip to content

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

Merged
zuqini merged 32 commits into
mainfrom
zpack.nvim-audit
Nov 14, 2026
Merged

zuqini merged 32 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.
  • keys: releasing a proxy in mode '', v, ! or !a checks each mode it covers, so a mapping put over one of them stays and no stale proxy is left in the others.
  • 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 or false (the type annotation now agrees); build takes a list or false; shell builds run with cmd.exe /c on Windows; a dev = true checkout is cloned, not used in place; plugin.main is set before the first config; deactivate runs only for a plugin that has loaded; :ZPack reload loads a lazy plugin that hadn't loaded, where :Lazy reload leaves it to its triggers.
  • 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 assertion was changed; the shared vim.pack.get mock in tests/helpers.lua now raises for a name it doesn't have, as vim.pack.get does, and the keymap cleanup there also clears abbreviations.
  • luacheck and LuaLS are clean. The suite passes on nightly (1506) and v0.12.0 (1505).
  • 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.
827f976 skipped the build of any plugin with no load callback, which
also dropped it for an installed plugin activated by an earlier
vim.pack.add (zpack_nvim-x2w): `:ZPack build <name>`, `:ZPack! build`
and a build after an update all ran on main. Skip only a plugin that
isn't installed, which is what a declined install leaves.
Releasing a proxy in mode `!` looked at its insert-mode half and
deleted both, so it took a cmdline mapping the user had put over the
proxy, and left the cmdline half when the insert one was replaced.
Modes `''` and `v` left the other halves the same way, and a
buffer-local proxy in any of the three took the user's mapping with it.
Each mode is now checked and deleted on its own.
02dd15d said so under `:ZPack reload` and left the hook's own entries
saying it runs on every reload.
spec.md named only `sh -c`; the vimdoc already had both.
A config that deletes its own plugin left load_and_build indexing a pack
spec the load had removed. The installed check is now vim.pack.get raising
or not, inline: the test harness's vim.pack.get raises for a name that
isn't installed, as vim.pack's does.
It doesn't clear `vim.g.loaded_*` guards, re-source the plugin's loaded
Vim scripts or call the main module's `deactivate`, which lazy.nvim does.
The entry already lists what the command does.
@zuqini
zuqini merged commit 79c8536 into main Nov 14, 2026
4 checks passed
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

0