fix(plugin): pass plugin as arg to config/init/build

This commit is contained in:
Folke Lemaitre 2022-12-26 22:59:02 +01:00
parent de383740a2
commit b6ebed5888
No known key found for this signature in database
GPG Key ID: 41F8B1FBACAE2040
2 changed files with 7 additions and 3 deletions

View File

@ -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
@ -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>

View File

@ -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"