Repository navigation
fix(main): take a compiled module named like the plugin, as lazy.nvim does - #58
Merged
Merged
Conversation
… does foo.nvim with lua/foo.so beside another module got no main and a warning; lazy.nvim's get_main takes foo. A Lua module of the same name still wins, so the PR #52 case (zeebar/init.lua beside zee_bar.so) keeps zeebar.
claims_topmod and resolve_main each matched .so/.dll themselves; top_module now returns the module name and whether it is compiled.
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 #57.
Fix
.so/.dll) named like the plugin is now itsmain, as in lazy.nvim. foo.nvim withlua/foo.sobeside another module got nomainand the "setmainexplicitly" warning; it now getsfoo. A matching Lua module still wins over the compiled one, sozeebar/init.luabesidezee_bar.sokeepszeebar(the perf: stop tracing zpack's startup code #52 case). lazy.nvim's choice there depends onpairsorder.This removes the "Known difference from lazy.nvim" that #57 documented.
Refactor
utils.top_modulenow reads.so/.dllitself and returns the module name and whether it is compiled.resolve_mainandmodule_loader'sclaims_topmodeach matched the suffixes on their own before. It checks suffixes withstring.subrather than patterns. With patterns, the move madeclaims_topmod2.5× slower, and that showed inzb(inits150 +2.2 ms). Withstring.subit is about 5× faster than before.claims_topmodanswers the same for every top-level namerequirecan produce, except the empty one fromrequire('')or a name of only dots (the loader strips leading dots, sorequire('.x')asks forx): it no longer claims a junk file named literally.soor.dll.Tests
resolve_main: the fix: main detection beside a compiled module, and the spec's main on the plugin in every hook #57 test that pinned the difference now expectsfoo. It fails onmain.resolve_main: the perf: stop tracing zpack's startup code #52 test also runs withzee_bar.dllin place ofzee_bar.so, so a.dllread as a Lua module fails it. Before, no test told the two apart.decoy, withmain = 'chosen'andopts = {}, calls onlychosen.setup. Nothing pinned this before. The test fails with a mutant that runs detection ahead of the spec'smain.Docs
:h zpack-Spec.mainsays a compiled module counts in the name match and the only-module rule, that a matching Lua module wins, and how a module name matches the plugin's.:h zpack.Plugin.mainentry in the Plugin reference, including when a detected module is set.Testing
zb checkagainst the base: no lazy flips, structural or opts differences. Every perf row is within 1 ms of the base, and inits150 is about 0.7 ms faster on both nightly and 0.12. One row, file150 on 0.12, was flagged only for machine load in two runs; there it is −0.29 ms against the base, with a CI spanning 0.lsmod+get_main, run against 22lua/layouts: zpack now matches it on all but a file literally named.so. Onmainit also differed on bothfoo.solayouts.zb checkisok, with no rows flagged and every row within ±0.6 ms of the base. In a real Neovim with a builtlua/foo.sobesidelua/bar.lua,mainwarns "Could not determine main module", and this branch callsfoo.setupwith the spec's opts, on install and on the next start.