fix: setting lazy = false marks plugin as eager (#108)

This commit is contained in:
Marc Jakobi
2024-10-24 20:22:37 +02:00
committed by GitHub
parent 409fe8585f
commit 6325a21905
2 changed files with 32 additions and 3 deletions
+7 -3
View File
@@ -93,9 +93,13 @@ end
---@return boolean
local function is_lazy(spec)
---@diagnostic disable-next-line: undefined-field
return spec.lazy or vim.iter(handlers):any(function(spec_field, _)
return spec[spec_field] ~= nil
end)
return spec.lazy
or vim.iter(handlers):any(function(spec_field, _)
-- PERF: This should be simpler and more performant than
-- filtering out "lazy" spec fields. However, this also
-- assumes that 'false' means a handler is disabled.
return spec[spec_field] and spec[spec_field] ~= nil
end)
end
---Mutates the `plugin`.
+25
View File
@@ -40,4 +40,29 @@ describe("hooks", function()
})
assert.True(afterRun)
end)
describe("regression-#187", function()
it("hook run when `lazy = false`", function()
local beforeAllRun = false
local beforeRun = false
local afterRun = false
lz.load({
{
"neorg",
lazy = false,
beforeAll = function()
beforeAllRun = true
end,
before = function()
beforeRun = true
end,
after = function()
afterRun = true
end,
},
})
assert.True(beforeAllRun)
assert.True(beforeRun)
assert.True(afterRun)
end)
end)
end)