aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWilliam Boman <william@redwill.se>2023-08-27 17:55:27 +0200
committerGitHub <noreply@github.com>2023-08-27 17:55:27 +0200
commit3569827f7b4651561eaafc60a3f3bc1bf382cebb (patch)
treea891f191ee3b50a44b743cd28a12ded5c76f4201
parentfix(registry): schedule vim.fn calls in FileRegistrySource (#1471) (diff)
downloadmason-3569827f7b4651561eaafc60a3f3bc1bf382cebb.tar
mason-3569827f7b4651561eaafc60a3f3bc1bf382cebb.tar.gz
mason-3569827f7b4651561eaafc60a3f3bc1bf382cebb.tar.bz2
mason-3569827f7b4651561eaafc60a3f3bc1bf382cebb.tar.lz
mason-3569827f7b4651561eaafc60a3f3bc1bf382cebb.tar.xz
mason-3569827f7b4651561eaafc60a3f3bc1bf382cebb.tar.zst
mason-3569827f7b4651561eaafc60a3f3bc1bf382cebb.zip
refactor(registry): colocate FileRegistrySource buffer management (#1473)
-rw-r--r--lua/mason-registry/sources/file.lua10
1 files changed, 4 insertions, 6 deletions
diff --git a/lua/mason-registry/sources/file.lua b/lua/mason-registry/sources/file.lua
index 1d97bbe7..84a3d6e1 100644
--- a/lua/mason-registry/sources/file.lua
+++ b/lua/mason-registry/sources/file.lua
@@ -38,10 +38,9 @@ function FileRegistrySource:get_all_package_specs()
return _.filter_map(util.map_registry_spec, self:get_buffer().specs)
end
-function FileRegistrySource:reload()
- if not self:is_installed() then
- return
- end
+---@param specs RegistryPackageSpec[]
+function FileRegistrySource:reload(specs)
+ self.buffer = _.assoc("specs", specs, self.buffer or {})
self.buffer.instances = _.compose(
_.index_by(_.prop "name"),
_.map(util.hydrate_package(self.buffer.instances or {}))
@@ -130,8 +129,7 @@ function FileRegistrySource:install()
return specs
end)
:on_success(function(specs)
- self.buffer = _.assoc("specs", specs, self.buffer or {})
- self:reload()
+ self:reload(specs)
end)
:on_failure(function(err)
log.fmt_error("Failed to install registry %s. %s", self, err)