Skip to content

Commit bfe810e

Browse files
committed
feat: support explicit lazy=false
1 parent 32be28a commit bfe810e

File tree

2 files changed

+26
-7
lines changed

2 files changed

+26
-7
lines changed

lua/lz/n/handler/init.lua

+10-7
Original file line numberDiff line numberDiff line change
@@ -93,13 +93,16 @@ end
9393
---@return boolean
9494
local function is_lazy(spec)
9595
---@diagnostic disable-next-line: undefined-field
96-
return spec.lazy
97-
or vim.iter(handlers):any(function(spec_field, _)
98-
-- PERF: This should be simpler and more performant than
99-
-- filtering out "lazy" spec fields. However, this also
100-
-- assumes that 'false' means a handler is disabled.
101-
return spec[spec_field] and spec[spec_field] ~= nil
102-
end)
96+
if spec.lazy ~= nil then
97+
---@diagnostic disable-next-line: undefined-field
98+
return spec.lazy
99+
end
100+
return vim.iter(handlers):any(function(spec_field, _)
101+
-- PERF: This should be simpler and more performant than
102+
-- filtering out "lazy" spec fields. However, this also
103+
-- assumes that 'false' means a handler is disabled.
104+
return spec[spec_field] and spec[spec_field] ~= nil
105+
end)
103106
end
104107

105108
---Mutates the `plugin`.

spec/lz_n_spec.lua

+16
Original file line numberDiff line numberDiff line change
@@ -96,5 +96,21 @@ describe("lz.n", function()
9696
cmd = { "Single" },
9797
})
9898
end)
99+
it("eagerly load if lazy=False", function()
100+
local spy_load = spy.on(loader, "_load")
101+
lz.load({
102+
{
103+
"single.nvim",
104+
cmd = "Single",
105+
lazy = false,
106+
},
107+
})
108+
assert.spy(spy_load).called(1)
109+
assert.spy(spy_load).called_with({
110+
name = "single.nvim",
111+
cmd = { "Single" },
112+
lazy = false,
113+
})
114+
end)
99115
end)
100116
end)

0 commit comments

Comments
 (0)