chore: simplify LzPluginHandler type

This commit is contained in:
Marc Jakobi
2024-06-05 17:34:03 +02:00
parent 1e36358596
commit 9b54ecb500
3 changed files with 18 additions and 6 deletions
+2 -1
View File
@@ -151,8 +151,9 @@ end
---@param plugin LzPlugin
function M.add(plugin)
-- TODO add plugin to M.pending
for _, event in pairs(plugin.event or {}) do
M.pending[event.id] = M.pending[event.id] or {}
M.pending[event.id][plugin.name] = plugin.name
add_event(event)
end
end
+5 -5
View File
@@ -31,11 +31,11 @@ error("Cannot import a meta module")
---@field after? fun(self:LzPlugin, opts:table)|true Will be executed when loading the plugin
---@field opts? PluginOpts
---@class LzPluginHandlers -- keys = plugin names
---@field event? table<string,LzEvent>
---@field ft? table<string,LzEvent>
---@field keys? table<string,LzKeys>
---@field cmd? table<string,string>
---@class LzPluginHandlers
---@field event? LzEvent[]
---@field ft? LzEvent[]
---@field keys? LzKeys[]
---@field cmd? string[]
---@class LzPluginSpecHandlers
---@field event? string|LzEventSpec[]
+11
View File
@@ -1,4 +1,5 @@
local event = require("lz.n.handler.event")
-- local loader = require("lz.n.loader")
describe("event", function()
it("can parse from string", function()
@@ -38,4 +39,14 @@ describe("event", function()
})
)
end)
it("integration", function()
---@type LzPlugin
local plugin = {
name = "foo",
event = { { id = "BufEnter", event = "BufEnter" } },
pattern = ".lua",
}
event.add(plugin)
-- TODO
end)
end)