refactor: Handler.load => Handler.resolve

This commit is contained in:
Folke Lemaitre 2023-10-17 17:43:37 +02:00
parent 03419f3e5f
commit c059eece0c
No known key found for this signature in database
GPG Key ID: 41F8B1FBACAE2040
2 changed files with 4 additions and 4 deletions

View File

@ -48,7 +48,7 @@ end
function M.enable(plugin)
if not plugin._.loaded then
if not plugin._.handlers then
M.load(plugin)
M.resolve(plugin)
end
for type in pairs(plugin._.handlers or {}) do
M.handlers[type]:add(plugin)
@ -98,7 +98,7 @@ function M:_values(values, plugin)
end
---@param plugin LazyPlugin
function M.load(plugin)
function M.resolve(plugin)
local Plugin = require("lazy.core.plugin")
plugin._.handlers = {}
for type, handler in pairs(M.handlers) do

View File

@ -241,7 +241,7 @@ describe("plugin spec opt", function()
local spec = Plugin.Spec.new(test)
assert(#spec.notifs == 0)
assert(vim.tbl_count(spec.plugins) == 1)
Handler.load(spec.plugins.bar)
Handler.resolve(spec.plugins.bar)
vim.print(spec.plugins.bar._.handlers)
local events = vim.tbl_keys(spec.plugins.bar._.handlers.event or {})
assert(type(events) == "table")
@ -307,7 +307,7 @@ describe("plugin spec opt", function()
local spec = Plugin.Spec.new(test)
assert(#spec.notifs == 0)
assert(vim.tbl_count(spec.plugins) == 1)
Handler.load(spec.plugins.bar)
Handler.resolve(spec.plugins.bar)
local events = spec.plugins.bar._.handlers.event
assert(type(events) == "table")
assert(vim.tbl_count(events) == 2)