From 49c0b86a6f831972972a1acc5590c2eb365dcef5 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Tue, 25 Jun 2024 18:07:26 +0200 Subject: [PATCH] ci: move to _generated.lua --- lua/lazy/build.lua | 2 +- .../community/{rocks.lua => _generated.lua} | 0 lua/lazy/community/init.lua | 25 +++++++++++++++++++ 3 files changed, 26 insertions(+), 1 deletion(-) rename lua/lazy/community/{rocks.lua => _generated.lua} (100%) create mode 100644 lua/lazy/community/init.lua 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