aboutsummaryrefslogtreecommitdiffstats
path: root/lua/mason-registry/sources/init.lua
diff options
context:
space:
mode:
authorWilliam Boman <william@redwill.se>2023-03-14 04:48:03 +0100
committerGitHub <noreply@github.com>2023-03-14 04:48:03 +0100
commitbf087883b05082a07ec2abe22e904b227b21f0d3 (patch)
tree2a024f842fb0be4ce91f325af08ecc0028299a6f /lua/mason-registry/sources/init.lua
parentfix(sources): also set .desc property when updating spec (#1095) (diff)
downloadmason-bf087883b05082a07ec2abe22e904b227b21f0d3.tar
mason-bf087883b05082a07ec2abe22e904b227b21f0d3.tar.gz
mason-bf087883b05082a07ec2abe22e904b227b21f0d3.tar.bz2
mason-bf087883b05082a07ec2abe22e904b227b21f0d3.tar.lz
mason-bf087883b05082a07ec2abe22e904b227b21f0d3.tar.xz
mason-bf087883b05082a07ec2abe22e904b227b21f0d3.tar.zst
mason-bf087883b05082a07ec2abe22e904b227b21f0d3.zip
feat: add registry.refresh() method (#1096)
Diffstat (limited to 'lua/mason-registry/sources/init.lua')
-rw-r--r--lua/mason-registry/sources/init.lua23
1 files changed, 23 insertions, 0 deletions
diff --git a/lua/mason-registry/sources/init.lua b/lua/mason-registry/sources/init.lua
index 0e5e0d29..0739f40b 100644
--- a/lua/mason-registry/sources/init.lua
+++ b/lua/mason-registry/sources/init.lua
@@ -1,3 +1,5 @@
+local _ = require "mason-core.functional"
+
local M = {}
---@param registry_id string
@@ -72,4 +74,25 @@ function M.iter(opts)
end
end
+---@return boolean #Returns true if all sources are installed.
+function M.is_installed()
+ for source in M.iter { include_uninstalled = true } do
+ if not source:is_installed() then
+ return false
+ end
+ end
+ return true
+end
+
+---@return string # The sha256 checksum of the currently registered sources.
+function M.checksum()
+ ---@type string[]
+ local registry_ids = {}
+ for source in M.iter { include_uninstalled = true } do
+ table.insert(registry_ids, source.id)
+ end
+ local checksum = _.compose(vim.fn.sha256, _.join "", _.sort_by(_.identity))
+ return checksum(registry_ids)
+end
+
return M