Skip to content

Commit

Permalink
fix(plugin): pass plugin as arg to config/init/build
Browse files Browse the repository at this point in the history
  • Loading branch information
folke committed Dec 26, 2022
1 parent de38374 commit b6ebed5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
8 changes: 6 additions & 2 deletions lua/lazy/core/loader.lua
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,9 @@ function M.startup()
for _, plugin in pairs(Config.plugins) do
if plugin.init then
Util.track({ plugin = plugin.name, init = "init" })
Util.try(plugin.init, "Failed to run `init` for **" .. plugin.name .. "**")
Util.try(function()
plugin.init(plugin)
end, "Failed to run `init` for **" .. plugin.name .. "**")
Util.track()
end
end
Expand Down Expand Up @@ -176,7 +178,9 @@ end
function M.config(plugin)
local fn
if type(plugin.config) == "function" then
fn = plugin.config
fn = function()
plugin.config(plugin)
end
else
local normname = Util.normname(plugin.name)
---@type table<string, string>
Expand Down
2 changes: 1 addition & 1 deletion lua/lazy/manage/task/plugin.lua
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ M.build = {
local cmd = vim.api.nvim_parse_cmd(build:sub(2), {})
self.output = vim.api.nvim_cmd(cmd, { output = true })
elseif type(build) == "function" then
build()
build(self.plugin)
else
local shell = vim.env.SHELL or vim.o.shell
local shell_args = shell:find("cmd.exe", 1, true) and "/c" or "-c"
Expand Down

0 comments on commit b6ebed5

Please sign in to comment.