Skip to content

Commit 3c86e23

Browse files
committed
ci: fixed luarocks manifest loading. It's now bigger than 65k entries and luajit doesn't want to load it anymore
1 parent db06788 commit 3c86e23

1 file changed

Lines changed: 39 additions & 2 deletions

File tree

lua/lazy/build.lua

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ local Util = require("lazy.util")
66
local M = {}
77

88
M.patterns = { "nvim", "treesitter", "tree-sitter", "cmp", "neo" }
9+
local manifest_file = "build/manifest.lua"
910

1011
function M.fetch(url, file, prefix)
1112
if not vim.uv.fs_stat(file) then
@@ -19,11 +20,46 @@ function M.fetch(url, file, prefix)
1920
end
2021
end
2122

23+
function M.split()
24+
local lines = vim.fn.readfile(manifest_file)
25+
local id = 0
26+
local files = {} ---@type string[]
27+
while #lines > 0 do
28+
id = id + 1
29+
local part_file = "build/manifest-part-" .. id .. ".lua"
30+
local idx = math.min(#lines, 30000)
31+
while idx < #lines and not lines[idx]:match("^ },$") do
32+
idx = idx + 1
33+
end
34+
local part_lines = vim.list_slice(lines, 1, idx)
35+
if idx ~= #lines then
36+
part_lines[#part_lines] = " }}"
37+
end
38+
vim.fn.writefile(part_lines, part_file)
39+
files[#files + 1] = part_file
40+
print("Wrote " .. part_file .. "\n")
41+
42+
lines = vim.list_slice(lines, idx + 1)
43+
if #lines == 0 then
44+
break
45+
end
46+
lines[1] = "repository = { " .. lines[1]
47+
end
48+
return files
49+
end
50+
2251
---@return RockManifest?
2352
function M.fetch_manifest()
24-
local manifest_file = "build/manifest.lua"
2553
M.fetch("https://luarocks.org/manifest-5.1", manifest_file)
26-
return Rocks.parse(manifest_file)
54+
local ret = { repository = {} }
55+
for _, file in ipairs(M.split()) do
56+
local part = Rocks.parse(file)
57+
print(vim.tbl_count(part.repository or {}) .. " rocks in " .. file .. "\n")
58+
for k, v in pairs(part.repository or {}) do
59+
ret.repository[k] = v
60+
end
61+
end
62+
return ret
2763
end
2864

2965
function M.fetch_rockspec(name, version, prefix)
@@ -37,6 +73,7 @@ function M.build()
3773
local manifest = M.fetch_manifest() or {}
3874
---@type {name:string, version:string, url:string}[]
3975
local nvim_rocks = {}
76+
print(vim.tbl_count(manifest.repository or {}) .. " rocks in manifest\n")
4077
for rock, vv in pairs(manifest.repository or {}) do
4178
local matches = false
4279
for _, pattern in ipairs(M.patterns) do

0 commit comments

Comments
 (0)