mirror of https://github.com/folke/lazy.nvim.git
feat(pkg): utils to get rock to url mappings
This commit is contained in:
parent
25981e1f39
commit
be74a8a535
|
@ -3,23 +3,22 @@ local M = {}
|
|||
---@type table<string, string>
|
||||
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
|
||||
local function load()
|
||||
if not mapping then
|
||||
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
|
||||
return mapping
|
||||
end
|
||||
|
||||
---@param rock string
|
||||
---@return string?
|
||||
function M.get_url(rock)
|
||||
_load()
|
||||
return mapping[rock]
|
||||
return load()[rock]
|
||||
end
|
||||
|
||||
return M
|
||||
|
|
Loading…
Reference in New Issue