mirror of
https://github.com/zoriya/lz.n.git
synced 2026-06-01 18:35:18 +00:00
fix: spec list with a single plugin spec ignored (#34)
This commit is contained in:
+9
-1
@@ -151,10 +151,18 @@ local function parse(spec)
|
||||
return result
|
||||
end
|
||||
|
||||
---XXX: This is unsafe because we assume a prior `vim.islist` check
|
||||
---
|
||||
---@param spec lz.n.Spec
|
||||
---@return boolean
|
||||
local function is_list_with_single_spec_unsafe(spec)
|
||||
return #spec == 1 and type(spec[1]) == "table"
|
||||
end
|
||||
|
||||
---@param spec lz.n.Spec
|
||||
---@return boolean
|
||||
function M.is_spec_list(spec)
|
||||
return #spec > 1 or vim.islist(spec) and #spec > 1
|
||||
return #spec > 1 or vim.islist(spec) and #spec > 1 or is_list_with_single_spec_unsafe(spec)
|
||||
end
|
||||
|
||||
---@param spec lz.n.Spec
|
||||
|
||||
@@ -81,5 +81,22 @@ describe("lz.n", function()
|
||||
vim.api.nvim_feedkeys(feed, "ix", false)
|
||||
assert.True(loaded)
|
||||
end)
|
||||
it("list with a single plugin spec", function()
|
||||
local spy_load = spy.on(loader, "_load")
|
||||
lz.load({
|
||||
{
|
||||
"single.nvim",
|
||||
cmd = "Single",
|
||||
},
|
||||
})
|
||||
assert.spy(spy_load).called(0)
|
||||
pcall(vim.cmd.Single)
|
||||
assert.spy(spy_load).called(1)
|
||||
assert.spy(spy_load).called_with({
|
||||
name = "single.nvim",
|
||||
lazy = true,
|
||||
cmd = { "Single" },
|
||||
})
|
||||
end)
|
||||
end)
|
||||
end)
|
||||
|
||||
Reference in New Issue
Block a user