From ae208dc380808ff1aef39929a0e897e881571d43 Mon Sep 17 00:00:00 2001 From: William Boman Date: Fri, 13 Oct 2023 21:14:29 +0200 Subject: refactor: standardize constructors and improve inheritance construction --- lua/mason-registry/sources/github.lua | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'lua/mason-registry/sources/github.lua') diff --git a/lua/mason-registry/sources/github.lua b/lua/mason-registry/sources/github.lua index 81ccaf56..d0a782fb 100644 --- a/lua/mason-registry/sources/github.lua +++ b/lua/mason-registry/sources/github.lua @@ -31,15 +31,17 @@ local GitHubRegistrySource = {} GitHubRegistrySource.__index = GitHubRegistrySource ---@param spec GitHubRegistrySourceSpec -function GitHubRegistrySource.new(spec) +function GitHubRegistrySource:new(spec) + ---@type GitHubRegistrySource + local instance = {} + setmetatable(instance, GitHubRegistrySource) local root_dir = InstallLocation.global():registry(path.concat { "github", spec.namespace, spec.name }) - return setmetatable({ - id = spec.id, - spec = spec, - root_dir = root_dir, - data_file = path.concat { root_dir, "registry.json" }, - info_file = path.concat { root_dir, "info.json" }, - }, GitHubRegistrySource) + instance.id = spec.id + instance.spec = spec + instance.root_dir = root_dir + instance.data_file = path.concat { root_dir, "registry.json" } + instance.info_file = path.concat { root_dir, "info.json" } + return instance end function GitHubRegistrySource:is_installed() -- cgit v1.2.3-70-g09d2