feat: LazyKeysBase Support opts and rhs_maker

opts, a table of key options for vim.keymap.set.
rhs_maker, a function that returns a rhs. run after plugin loads, it could produce rhs dynamically.
This commit is contained in:
HC 2023-11-04 06:10:38 +08:00
commit b1213d426f
2 changed files with 24 additions and 3 deletions

View file

@ -167,7 +167,8 @@ end
---@param plugins string|LazyPlugin|string[]|LazyPlugin[]
---@param reason {[string]:string}
---@param opts? {force:boolean} when force is true, we skip the cond check
function M.load(plugins, reason, opts)
---@param afterload? function a function that runs after load
function M.load(plugins, reason, opts, afterload)
---@diagnostic disable-next-line: cast-local-type
plugins = (type(plugins) == "string" or plugins.name) and { plugins } or plugins
---@cast plugins (string|LazyPlugin)[]
@ -185,6 +186,9 @@ function M.load(plugins, reason, opts)
end
if plugin and not plugin._.loaded then
M._load(plugin, reason, opts)
if afterload then
afterload()
end
end
end
end