diff --git a/lua/lazy/core/plugin.lua b/lua/lazy/core/plugin.lua index ea9a04e..8ce23b4 100644 --- a/lua/lazy/core/plugin.lua +++ b/lua/lazy/core/plugin.lua @@ -240,7 +240,7 @@ function Spec:fix_disabled() end end - -- fix deps of plugins that are all optional + -- fix deps of plugins that are completely optional self:fix_dependencies(all_optional_deps, dep_of, function(dep_name) self.plugins[dep_name] = nil end) diff --git a/tests/core/plugin_spec.lua b/tests/core/plugin_spec.lua index 3c37e91..f64cb4c 100644 --- a/tests/core/plugin_spec.lua +++ b/tests/core/plugin_spec.lua @@ -273,6 +273,25 @@ describe("plugin spec opt", function() end end end) + + it("handles the optional keyword", function() + local tests = { + [{ { "foo/bax" }, { "foo/bar", optional = true, dependencies = "foo/dep1" } }] = false, + [{ { "foo/bax", dependencies = "foo/dep1" }, { "foo/bar", optional = true, dependencies = "foo/dep1" } }] = true, + } + for test, ret in pairs(tests) do + local spec = Plugin.Spec.new(test) + assert(#spec.notifs == 0) + assert(spec.plugins.bax) + assert(not spec.plugins.bar) + assert(#spec.disabled == 0) + if ret then + assert(spec.plugins.dep1) + else + assert(not spec.plugins.opt1) + end + end + end) end) describe("plugin opts", function()