From cc14adda0766246daa3c0fdd51f112d06cedf22d Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Mon, 24 Jun 2024 14:31:26 +0200 Subject: [PATCH] feat(build): set `vim.env.LAZY_BUILD_DIR` to plugin dir before building --- lua/lazy/manage/task/plugin.lua | 46 ++++++++++++++++++--------------- 1 file changed, 25 insertions(+), 21 deletions(-) diff --git a/lua/lazy/manage/task/plugin.lua b/lua/lazy/manage/task/plugin.lua index cd01a2514..cf826ee8c 100644 --- a/lua/lazy/manage/task/plugin.lua +++ b/lua/lazy/manage/task/plugin.lua @@ -79,28 +79,32 @@ M.build = { builders = builders or get_build_file(self.plugin) - if builders then - builders = type(builders) == "table" and builders or { builders } - ---@cast builders (string|fun(LazyPlugin))[] - for _, build in ipairs(builders) do - if type(build) == "function" then - self:async(function() - build(self.plugin) - end) - elseif build == "rockspec" then - B.rockspec(self) - elseif build:sub(1, 1) == ":" then - B.cmd(self, build) - elseif build:match("%.lua$") then - local file = self.plugin.dir .. "/" .. build - local chunk, err = loadfile(file) - if not chunk or err then - error(err) - end - self:async(chunk) - else - B.shell(self, build) + if not builders then + return + end + + vim.env.LAZY_BUILD_DIR = self.plugin.dir + + builders = type(builders) == "table" and builders or { builders } + ---@cast builders (string|fun(LazyPlugin))[] + for _, build in ipairs(builders) do + if type(build) == "function" then + self:async(function() + build(self.plugin) + end) + elseif build == "rockspec" then + B.rockspec(self) + elseif build:sub(1, 1) == ":" then + B.cmd(self, build) + elseif build:match("%.lua$") then + local file = self.plugin.dir .. "/" .. build + local chunk, err = loadfile(file) + if not chunk or err then + error(err) end + self:async(chunk) + else + B.shell(self, build) end end end,