From a17180d7a9da267569878f6c12da1998af37a649 Mon Sep 17 00:00:00 2001 From: infastin Date: Tue, 14 Jan 2025 23:11:08 +0500 Subject: [PATCH] feat(rockspec): scan rockspecs directory for .rockspec files --- lua/lazy/pkg/rockspec.lua | 35 ++++++++++++++++++++++++++++------- 1 file changed, 28 insertions(+), 7 deletions(-) diff --git a/lua/lazy/pkg/rockspec.lua b/lua/lazy/pkg/rockspec.lua index e8ece1b..4a43c6a 100644 --- a/lua/lazy/pkg/rockspec.lua +++ b/lua/lazy/pkg/rockspec.lua @@ -247,17 +247,36 @@ end ---@param plugin LazyPlugin function M.find_rockspec(plugin) local rockspec_file ---@type string? + + local check_file = function(path, name) + for _, suffix in ipairs({ "scm", "git", "dev" }) do + suffix = suffix .. "-1.rockspec" + if name:sub(-#suffix) == suffix then + return path + end + end + end + Util.ls(plugin.dir, function(path, name, t) - if t == "file" then - for _, suffix in ipairs({ "scm", "git", "dev" }) do - suffix = suffix .. "-1.rockspec" - if name:sub(-#suffix) == suffix then - rockspec_file = path + if t == "directory" and name == "rockspecs" then + Util.ls(path, function(path, name, t) + rockspec_file = check_file(path, name) + if rockspec_file ~= nil then return false end + end) + if rockspec_file ~= nil then + return false + end + end + if t == "file" then + rockspec_file = check_file(path, name) + if rockspec_file ~= nil then + return false end end end) + return rockspec_file end @@ -311,11 +330,13 @@ function M.get(plugin) -- has a complex build process or not M.is_simple_build(rockspec) + rockspec_file = rockspec_file:sub(#plugin.dir+2) + if not use then -- community specs only return #specs > 0 and { - file = vim.fn.fnamemodify(rockspec_file, ":t"), + file = rockspec_file, spec = { plugin.name, specs = specs, @@ -331,7 +352,7 @@ function M.get(plugin) end return { - file = vim.fn.fnamemodify(rockspec_file, ":t"), + file = rockspec_file, spec = { plugin.name, build = "rockspec",