mirror of
https://github.com/zoriya/lz.n.git
synced 2026-06-08 12:52:18 +00:00
fix: setting lazy = false marks plugin as eager (#108)
This commit is contained in:
@@ -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`.
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user