mirror of
https://github.com/zoriya/lz.n.git
synced 2025-12-06 06:36:11 +00:00
feat: support explicit lazy=false
This commit is contained in:
@@ -93,13 +93,16 @@ 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, _)
|
||||
-- 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)
|
||||
if spec.lazy ~= nil then
|
||||
---@diagnostic disable-next-line: undefined-field
|
||||
return spec.lazy
|
||||
end
|
||||
return 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`.
|
||||
|
||||
@@ -96,5 +96,21 @@ describe("lz.n", function()
|
||||
cmd = { "Single" },
|
||||
})
|
||||
end)
|
||||
it("eagerly load if lazy=False", function()
|
||||
local spy_load = spy.on(loader, "_load")
|
||||
lz.load({
|
||||
{
|
||||
"single.nvim",
|
||||
cmd = "Single",
|
||||
lazy = false,
|
||||
},
|
||||
})
|
||||
assert.spy(spy_load).called(1)
|
||||
assert.spy(spy_load).called_with({
|
||||
name = "single.nvim",
|
||||
cmd = { "Single" },
|
||||
lazy = false,
|
||||
})
|
||||
end)
|
||||
end)
|
||||
end)
|
||||
|
||||
Reference in New Issue
Block a user