From a17180d7a9da267569878f6c12da1998af37a649 Mon Sep 17 00:00:00 2001 From: infastin Date: Tue, 14 Jan 2025 23:11:08 +0500 Subject: [PATCH 1/4] 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", From 7190e015cb2aa41660a7399e4e9c007165db3b73 Mon Sep 17 00:00:00 2001 From: infastin Date: Tue, 14 Jan 2025 23:18:46 +0500 Subject: [PATCH 2/4] chore: only check files inside rockspecs directory --- lua/lazy/pkg/rockspec.lua | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lua/lazy/pkg/rockspec.lua b/lua/lazy/pkg/rockspec.lua index 4a43c6a..1616071 100644 --- a/lua/lazy/pkg/rockspec.lua +++ b/lua/lazy/pkg/rockspec.lua @@ -260,9 +260,11 @@ function M.find_rockspec(plugin) Util.ls(plugin.dir, function(path, name, t) 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 + if t == "file" then + rockspec_file = check_file(path, name) + if rockspec_file ~= nil then + return false + end end end) if rockspec_file ~= nil then From aea6fdb84b413474e992c9d50e46432ba3c29b1f Mon Sep 17 00:00:00 2001 From: infastin Date: Tue, 14 Jan 2025 23:29:43 +0500 Subject: [PATCH 3/4] feat: also allow rockspec directory --- lua/lazy/pkg/rockspec.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/lazy/pkg/rockspec.lua b/lua/lazy/pkg/rockspec.lua index 1616071..f6accd9 100644 --- a/lua/lazy/pkg/rockspec.lua +++ b/lua/lazy/pkg/rockspec.lua @@ -258,7 +258,7 @@ function M.find_rockspec(plugin) end Util.ls(plugin.dir, function(path, name, t) - if t == "directory" and name == "rockspecs" then + if t == "directory" and (name == "rockspec" or name == "rockspecs") then Util.ls(path, function(path, name, t) if t == "file" then rockspec_file = check_file(path, name) From 7e18ced2e64a500f8ebab2e6d4d35d0832da59fe Mon Sep 17 00:00:00 2001 From: infastin Date: Tue, 14 Jan 2025 23:46:35 +0500 Subject: [PATCH 4/4] feat: match any revision --- lua/lazy/pkg/rockspec.lua | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lua/lazy/pkg/rockspec.lua b/lua/lazy/pkg/rockspec.lua index f6accd9..ee951ff 100644 --- a/lua/lazy/pkg/rockspec.lua +++ b/lua/lazy/pkg/rockspec.lua @@ -249,9 +249,10 @@ function M.find_rockspec(plugin) local rockspec_file ---@type string? local check_file = function(path, name) + -- match package-(scm|git|dev)-[REV].rockspec for _, suffix in ipairs({ "scm", "git", "dev" }) do - suffix = suffix .. "-1.rockspec" - if name:sub(-#suffix) == suffix then + pattern = suffix .. "%-%d+%.rockspec$" + if name:find(pattern) then return path end end