diff options
| author | William Boman <william@redwill.se> | 2023-04-22 19:20:52 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-04-22 19:20:52 +0200 |
| commit | 579d4bd178f4aae76a4f4dc2ea34bf5e8fa6231b (patch) | |
| tree | ec3b23ec8a00ba1922bda6c7cf80a0c9242e1978 /lua/mason-registry/sources/lua.lua | |
| parent | chore: remove generate scripts and artifacts (#1246) (diff) | |
| download | mason-579d4bd178f4aae76a4f4dc2ea34bf5e8fa6231b.tar mason-579d4bd178f4aae76a4f4dc2ea34bf5e8fa6231b.tar.gz mason-579d4bd178f4aae76a4f4dc2ea34bf5e8fa6231b.tar.bz2 mason-579d4bd178f4aae76a4f4dc2ea34bf5e8fa6231b.tar.lz mason-579d4bd178f4aae76a4f4dc2ea34bf5e8fa6231b.tar.xz mason-579d4bd178f4aae76a4f4dc2ea34bf5e8fa6231b.tar.zst mason-579d4bd178f4aae76a4f4dc2ea34bf5e8fa6231b.zip | |
feat(registry): add .get_all_package_specs() (#1247)
This is a faster method than .get_all_packages() due to the fact that it only loads package specifications without
instantiating mason-core.package instances. Useful for situations where one only needs to read spec data.
Diffstat (limited to 'lua/mason-registry/sources/lua.lua')
| -rw-r--r-- | lua/mason-registry/sources/lua.lua | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/lua/mason-registry/sources/lua.lua b/lua/mason-registry/sources/lua.lua index c3e96075..1675f232 100644 --- a/lua/mason-registry/sources/lua.lua +++ b/lua/mason-registry/sources/lua.lua @@ -1,3 +1,5 @@ +local Optional = require "mason-core.optional" +local _ = require "mason-core.functional" local log = require "mason-core.log" ---@class LuaRegistrySourceSpec @@ -37,6 +39,13 @@ function LuaRegistrySource:get_all_package_names() return vim.tbl_keys(index) end +---@return PackageSpec[] +function LuaRegistrySource:get_all_package_specs() + return _.filter_map(function(name) + return Optional.of_nilable(self:get_package(name)):map(_.prop "spec") + end, self:get_all_package_names()) +end + function LuaRegistrySource:is_installed() local ok = pcall(require, self.spec.mod) return ok |
