feat(rocks): use hererocks to install luarocks when luarocks is not found

This commit is contained in:
Folke Lemaitre 2024-06-25 07:55:30 +02:00
parent dea1f687fe
commit d87da76679
No known key found for this signature in database
GPG key ID: 41F8B1FBACAE2040
5 changed files with 58 additions and 2 deletions

View file

@ -18,8 +18,25 @@ local B = {}
---@param task LazyTask
function B.rockspec(task)
---@type table<string, string>
local env = {}
if Config.options.rocks.hererocks then
local hererocks = Config.options.rocks.root .. "/hererocks"
local sep = jit.os:find("Windows") and ";" or ":"
local path = vim.split(vim.env.PATH, sep)
table.insert(path, 1, hererocks .. "/bin")
env = {
PATH = table.concat(path, sep),
}
local plugin = Config.plugins.hererocks
-- hererocks is still building, so skip for now
if plugin and plugin._.build then
return
end
end
local root = Config.options.rocks.root .. "/" .. task.plugin.name
vim.fn.mkdir(root, "p")
task:spawn("luarocks", {
args = {
"--tree",
@ -33,6 +50,7 @@ function B.rockspec(task)
"--force-fast",
},
cwd = task.plugin.dir,
env = env,
})
end