mirror of
https://github.com/folke/lazy.nvim.git
synced 2025-04-19 21:06:46 +00:00
test: fixed tests
This commit is contained in:
parent
47dafaed64
commit
c6831d2126
4 changed files with 37 additions and 24 deletions
|
@ -48,12 +48,7 @@ end
|
|||
function M.enable(plugin)
|
||||
if not plugin._.loaded then
|
||||
if not plugin._.handlers then
|
||||
plugin._.handlers = {}
|
||||
for type, handler in pairs(M.handlers) do
|
||||
if plugin[type] then
|
||||
handler:load(plugin)
|
||||
end
|
||||
end
|
||||
M.load(plugin)
|
||||
end
|
||||
for type in pairs(plugin._.handlers or {}) do
|
||||
M.handlers[type]:add(plugin)
|
||||
|
@ -103,9 +98,14 @@ function M:_values(values, plugin)
|
|||
end
|
||||
|
||||
---@param plugin LazyPlugin
|
||||
function M:load(plugin)
|
||||
function M.load(plugin)
|
||||
local Plugin = require("lazy.core.plugin")
|
||||
plugin._.handlers[self.type] = self:_values(Plugin.values(plugin, self.type, true), plugin)
|
||||
plugin._.handlers = {}
|
||||
for type, handler in pairs(M.handlers) do
|
||||
if plugin[type] then
|
||||
plugin._.handlers[type] = handler:_values(Plugin.values(plugin, type, true), plugin)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
---@param plugin LazyPlugin
|
||||
|
|
|
@ -24,7 +24,7 @@ local Util = require("lazy.core.util")
|
|||
---@class LazyKeysHandler:LazyHandler
|
||||
local M = {}
|
||||
|
||||
local skip = { mode = true, id = true, ft = true, rhs = true, lhs = true, name = true }
|
||||
local skip = { mode = true, id = true, ft = true, rhs = true, lhs = true }
|
||||
|
||||
---@param value string|LazyKeysSpec
|
||||
---@param mode? string
|
||||
|
@ -40,15 +40,18 @@ function M.parse(value, mode)
|
|||
ret[2] = nil
|
||||
ret.mode = mode or "n"
|
||||
ret.id = vim.api.nvim_replace_termcodes(ret.lhs, true, true, true)
|
||||
ret.name = ret.lhs
|
||||
|
||||
if ret.mode ~= "n" then
|
||||
ret.id = ret.id .. " (" .. ret.mode .. ")"
|
||||
ret.name = ret.name .. " (" .. ret.mode .. ")"
|
||||
end
|
||||
return ret
|
||||
end
|
||||
|
||||
---@param keys LazyKeys
|
||||
function M.to_string(keys)
|
||||
return keys.lhs .. (keys.mode == "n" and "" or " (" .. keys.mode .. ")")
|
||||
end
|
||||
|
||||
---@param lhs string
|
||||
---@param mode? string
|
||||
function M:have(lhs, mode)
|
||||
|
@ -109,8 +112,9 @@ function M:_add(keys)
|
|||
self.active[keys.id] = nil
|
||||
|
||||
if plugins then
|
||||
Util.track({ keys = keys.name })
|
||||
Loader.load(plugins, { keys = keys.name })
|
||||
local name = M.to_string(keys)
|
||||
Util.track({ keys = name })
|
||||
Loader.load(plugins, { keys = name })
|
||||
Util.track()
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue