Repository navigation
fix: main detection across :ZPack reload and in-session updates - #59
Merged
Merged
Conversation
resolve_main cached a miss per src until the plugin was deleted, so after an in-session update added the module, :ZPack reload still found no main. Its only caller runs once per load, so the cache saved a cached lsdir walk on a manual reload. Drop it; a found main stays cached on plugin.main.
…gument The two caching tests asserted the spec's main, which registration puts on the plugin, and changed spec.main, which resolve_main no longer reads, so neither failed when a detected main wasn't kept on plugin.main.
A detected main stayed on plugin.main for the session, so after an update renamed the plugin's module, :ZPack reload called the old module's setup from package.loaded. Reload now puts the spec's main back on the plugin after deactivate, so init, opts and config see what they see on a first load, and detection runs again.
vim.loader lists each 'runtimepath' entry's top-level modules once, so after an update added or renamed one, requiring it failed until restart (zpack enables vim.loader by default), and :ZPack reload reported "Failed to require" for the module it had just detected. The PackChanged handler now resets that plugin's entry beside zpack's own caches.
A plugin with no explicit main got its detected module on plugin.main only after its opts functions, so an opts function saw nil there while config saw the module. Detection now runs first, so both see it on every load.
The installing count told the user to run :ZPack update, which fails for a plugin that was never installed (its install prompt declined or failed). vim.pack.add installs synchronously, so nothing is still installing once setup() returns; a restart is what installs it.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-ups to #55, #57 and #58 from an audit of what they changed.
Fixes
:ZPack reload, as in lazy.nvim. After an update renamed the plugin's module, reload ran the old module'ssetup()frompackage.loaded.PackChangedhandler resetsvim.loader's index for the updated plugin. zpack enablesvim.loaderby default, and it lists each plugin's top-level modules once, so a module an update added or renamed couldn't be required until restart.optsfunctions run, sooptsfunctions see it asconfigdoes.:ZPack updatecan't install a plugin that was never installed.Docs
:ZPack! loadand its completion skip plugins whosecondis false (README, vimdoc).plugin.mainis detected beforeoptsfunctions andconfigon each load,:ZPack reloadincluded (vimdoc, docs/spec.md, types.lua).keymap.mapargcomment said!is read as normal mode; it is read as:map's modes.Testing
resolve_maincaching tests, which stopped testing anything when fix: main detection beside a compiled module, and the spec's main on the plugin in every hook #57 dropped thespecargument, now pin the cache.zb checkagainst the base: no lazy flips, structural or opts differences.zb perf --rows matrix(36 rows, both nvims) against the base: no row slower with a CI excluding 0. The rows flagged as not faster than lazy.nvim (trig150, ftd150 and fton150 on 0.12) are flagged at the base too.vim.pack, a git plugin whose update renames its module then gets the new module'ssetup()on:ZPack reload, on nightly and v0.12.0.