fix(hooks): regression preventing beforeAll from being run (#101)

This commit is contained in:
Marc Jakobi
2024-10-15 16:30:12 +02:00
committed by GitHub
parent de27f80d43
commit 8259302208
2 changed files with 44 additions and 1 deletions

View File

@@ -23,7 +23,7 @@ end
---@param plugins table<string, lz.n.Plugin>
local function run_before_all(plugins)
---@param plugin lz.n.Plugin
vim.iter(plugins):each(function(plugin)
vim.iter(plugins):each(function(_, plugin)
if plugin.beforeAll then
xpcall(
plugin.beforeAll,

43
spec/hooks_spec.lua Normal file
View File

@@ -0,0 +1,43 @@
local lz = require("lz.n")
vim.g.lz_n = {
load = function() end,
}
describe("hooks", function()
it("beforeAll", function()
local beforeAllRun = false
lz.load({
{
"neorg",
beforeAll = function()
beforeAllRun = true
end,
},
})
assert.True(beforeAllRun)
end)
it("before", function()
local beforeRun = false
lz.load({
{
"neorg",
before = function()
beforeRun = true
end,
},
})
assert.True(beforeRun)
end)
it("after", function()
local afterRun = false
lz.load({
{
"neorg",
beforeAll = function()
afterRun = true
end,
},
})
assert.True(afterRun)
end)
end)