Skip to content

Commit b6ebed5

Browse files
committed
fix(plugin): pass plugin as arg to config/init/build
1 parent de38374 commit b6ebed5

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

lua/lazy/core/loader.lua

+6-2
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,9 @@ function M.startup()
6363
for _, plugin in pairs(Config.plugins) do
6464
if plugin.init then
6565
Util.track({ plugin = plugin.name, init = "init" })
66-
Util.try(plugin.init, "Failed to run `init` for **" .. plugin.name .. "**")
66+
Util.try(function()
67+
plugin.init(plugin)
68+
end, "Failed to run `init` for **" .. plugin.name .. "**")
6769
Util.track()
6870
end
6971
end
@@ -176,7 +178,9 @@ end
176178
function M.config(plugin)
177179
local fn
178180
if type(plugin.config) == "function" then
179-
fn = plugin.config
181+
fn = function()
182+
plugin.config(plugin)
183+
end
180184
else
181185
local normname = Util.normname(plugin.name)
182186
---@type table<string, string>

lua/lazy/manage/task/plugin.lua

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ M.build = {
2020
local cmd = vim.api.nvim_parse_cmd(build:sub(2), {})
2121
self.output = vim.api.nvim_cmd(cmd, { output = true })
2222
elseif type(build) == "function" then
23-
build()
23+
build(self.plugin)
2424
else
2525
local shell = vim.env.SHELL or vim.o.shell
2626
local shell_args = shell:find("cmd.exe", 1, true) and "/c" or "-c"

0 commit comments

Comments
 (0)