diff --git a/lua/lazy/build.lua b/lua/lazy/build.lua index c30c809..f61589e 100644 --- a/lua/lazy/build.lua +++ b/lua/lazy/build.lua @@ -83,7 +83,7 @@ function M.build() end end end - Util.write_file("lua/lazy/community/rocks.lua", "return \n" .. vim.inspect(nvim_rocks)) + Util.write_file("lua/lazy/community/_generated.lua", "return \n" .. vim.inspect(nvim_rocks)) end M.build() diff --git a/lua/lazy/community/rocks.lua b/lua/lazy/community/_generated.lua similarity index 100% rename from lua/lazy/community/rocks.lua rename to lua/lazy/community/_generated.lua diff --git a/lua/lazy/community/init.lua b/lua/lazy/community/init.lua new file mode 100644 index 0000000..4e762ec --- /dev/null +++ b/lua/lazy/community/init.lua @@ -0,0 +1,25 @@ +local M = {} + +---@type table +local mapping = nil + +local function _load() + if mapping then + return + end + mapping = {} + ---@type {name:string, url:string, version:string}[] + local gen = require("lazy.community._generated") + for _, rock in ipairs(gen) do + mapping[rock.name] = rock.url + end +end + +---@param rock string +---@return string? +function M.get_url(rock) + _load() + return mapping[rock] +end + +return M