mirror of https://github.com/folke/lazy.nvim.git
fix(spec): `Plugin.opts` is now always a table. Fixes #351
This commit is contained in:
parent
ef87c24e8e
commit
e77be3cf3b
|
@ -234,6 +234,7 @@ end
|
||||||
-- Merges super opts or runs the opts function to override opts or return new ones
|
-- Merges super opts or runs the opts function to override opts or return new ones
|
||||||
---@param plugin LazyPlugin
|
---@param plugin LazyPlugin
|
||||||
function M.opts(plugin)
|
function M.opts(plugin)
|
||||||
|
---@type table
|
||||||
local opts = plugin._.super and M.opts(plugin._.super) or {}
|
local opts = plugin._.super and M.opts(plugin._.super) or {}
|
||||||
---@type PluginOpts?
|
---@type PluginOpts?
|
||||||
local plugin_opts = rawget(plugin, "opts")
|
local plugin_opts = rawget(plugin, "opts")
|
||||||
|
@ -273,11 +274,7 @@ function M.config(plugin)
|
||||||
end
|
end
|
||||||
if #mods == 1 then
|
if #mods == 1 then
|
||||||
fn = function()
|
fn = function()
|
||||||
local opts = M.opts(plugin)
|
require(mods[1]).setup(M.opts(plugin))
|
||||||
if next(opts) == nil then
|
|
||||||
opts = nil
|
|
||||||
end
|
|
||||||
require(mods[1]).setup(opts)
|
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
return Util.error(
|
return Util.error(
|
||||||
|
|
|
@ -295,6 +295,9 @@ end
|
||||||
--- Values will me merged in-place in the first left-most table. If you want the result to be in
|
--- Values will me merged in-place in the first left-most table. If you want the result to be in
|
||||||
--- a new table, then simply pass an empty table as the first argument `vim.merge({}, ...)`
|
--- a new table, then simply pass an empty table as the first argument `vim.merge({}, ...)`
|
||||||
--- Supports clearing values by setting a key to `vim.NIL`
|
--- Supports clearing values by setting a key to `vim.NIL`
|
||||||
|
---@generic T
|
||||||
|
---@param ... T
|
||||||
|
---@return T
|
||||||
function M.merge(...)
|
function M.merge(...)
|
||||||
local values = { ... }
|
local values = { ... }
|
||||||
local ret = values[1]
|
local ret = values[1]
|
||||||
|
|
|
@ -298,6 +298,14 @@ describe("plugin opts", function()
|
||||||
spec = { { "foo/foo", config = { a = 1, b = 1 } }, { "foo/foo", config = { a = vim.NIL } } },
|
spec = { { "foo/foo", config = { a = 1, b = 1 } }, { "foo/foo", config = { a = vim.NIL } } },
|
||||||
opts = { b = 1 },
|
opts = { b = 1 },
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
spec = { { "foo/foo", config = { a = 1, b = 1 } }, { "foo/foo" } },
|
||||||
|
opts = { a = 1, b = 1 },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
spec = { { "foo/foo" }, { "foo/foo" } },
|
||||||
|
opts = {},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, test in ipairs(tests) do
|
for _, test in ipairs(tests) do
|
||||||
|
|
Loading…
Reference in New Issue