fix(rocks): only build rockspec when it has deps or an advanced build step

This commit is contained in:
Folke Lemaitre 2024-06-24 17:07:25 +02:00
parent dbffad6f44
commit 9a6c219826
2 changed files with 30 additions and 15 deletions

View File

@ -2,7 +2,7 @@ local Config = require("lazy.core.config")
local Util = require("lazy.util") local Util = require("lazy.util")
local M = {} local M = {}
M.VERSION = 8 M.VERSION = 10
M.dirty = false M.dirty = false
---@class LazyPkg ---@class LazyPkg

View File

@ -12,6 +12,7 @@ M.skip = { "lua" }
---@field package string ---@field package string
---@field version string ---@field version string
---@field dependencies string[] ---@field dependencies string[]
---@field build? {build_type?: string, modules?: any[]}
---@param plugin LazyPlugin ---@param plugin LazyPlugin
---@return LazyPkgSpec? ---@return LazyPkgSpec?
@ -37,30 +38,44 @@ function M.get(plugin)
end end
load() load()
if not rockspec then
return
end
local has_lua = not not vim.uv.fs_stat(plugin.dir .. "/lua")
---@param dep string ---@param dep string
local rocks = vim.tbl_filter(function(dep) local rocks = vim.tbl_filter(function(dep)
local name = dep:gsub("%s.*", "") local name = dep:gsub("%s.*", "")
return not vim.tbl_contains(M.skip, name) return not vim.tbl_contains(M.skip, name)
end, rockspec and rockspec.dependencies or {}) end, rockspec.dependencies or {})
local use = #rocks > 0 local use = not has_lua
use = true or #rocks > 0
or (
rockspec.build
and rockspec.build.build_type
and rockspec.build.build_type ~= "none"
and not (rockspec.build.build_type == "builtin" and not rockspec.build.modules)
)
if not use then
return
end
local lazy = nil local lazy = nil
if not vim.uv.fs_stat(plugin.dir .. "/lua") then if not has_lua then
lazy = false lazy = false
end end
return use return {
and {
file = vim.fn.fnamemodify(rockspec_file, ":t"), file = vim.fn.fnamemodify(rockspec_file, ":t"),
spec = { spec = {
plugin.name, plugin.name,
build = "rockspec", build = "rockspec",
lazy = lazy, lazy = lazy,
}, },
} } or nil
or nil
end end
return M return M