diff options
| author | William Boman <william@redwill.se> | 2023-03-12 08:21:15 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-03-12 08:21:15 +0100 |
| commit | a01d02ad7f680aec98a1e2ec35b04cedd307cfa8 (patch) | |
| tree | 1a09e274a1f2a4da85b911abcbb182a211035501 /lua/mason-registry/sources/init.lua | |
| parent | feat(golangci-lint): support linux_arm64 (#1089) (diff) | |
| download | mason-a01d02ad7f680aec98a1e2ec35b04cedd307cfa8.tar mason-a01d02ad7f680aec98a1e2ec35b04cedd307cfa8.tar.gz mason-a01d02ad7f680aec98a1e2ec35b04cedd307cfa8.tar.bz2 mason-a01d02ad7f680aec98a1e2ec35b04cedd307cfa8.tar.lz mason-a01d02ad7f680aec98a1e2ec35b04cedd307cfa8.tar.xz mason-a01d02ad7f680aec98a1e2ec35b04cedd307cfa8.tar.zst mason-a01d02ad7f680aec98a1e2ec35b04cedd307cfa8.zip | |
feat: add github registry source capabilities (#1091)
Diffstat (limited to 'lua/mason-registry/sources/init.lua')
| -rw-r--r-- | lua/mason-registry/sources/init.lua | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/lua/mason-registry/sources/init.lua b/lua/mason-registry/sources/init.lua index e4abe062..5a332326 100644 --- a/lua/mason-registry/sources/init.lua +++ b/lua/mason-registry/sources/init.lua @@ -4,7 +4,23 @@ local M = {} ---@return fun(): RegistrySource # Thunk to instantiate provider. local function parse(registry_id) local type, id = registry_id:match "^(.+):(.+)$" - if type == "lua" then + if type == "github" then + local namespace, name = id:match "^(.+)/(.+)$" + if not namespace or not name then + error(("Failed to parse repository from GitHub registry: %q."):format(registry_id), 0) + end + local name, version = unpack(vim.split(name, "@")) + return function() + local GitHubRegistrySource = require "mason-registry.sources.github" + return GitHubRegistrySource.new { + id = registry_id, + repo = ("%s/%s"):format(namespace, name), + namespace = namespace, + name = name, + version = version or "latest", + } + end + elseif type == "lua" then return function() local LuaRegistrySource = require "mason-registry.sources.lua" return LuaRegistrySource.new { |
