aboutsummaryrefslogtreecommitdiffstats
path: root/lua/mason-core/package/init.lua
diff options
context:
space:
mode:
authorWilliam Boman <william@redwill.se>2026-05-14 17:21:42 +0200
committerGitHub <noreply@github.com>2026-05-14 17:21:42 +0200
commit8e921c2b68571e978db5d4d3fef9c9a7f8755473 (patch)
treec16d4b5c8a6e33877c523d2e7ff714090432a8de /lua/mason-core/package/init.lua
parentfix(pypi): add python 3.13 and 3.14 to list of fallbacks (#2081) (diff)
downloadmason-8e921c2b68571e978db5d4d3fef9c9a7f8755473.tar
mason-8e921c2b68571e978db5d4d3fef9c9a7f8755473.tar.gz
mason-8e921c2b68571e978db5d4d3fef9c9a7f8755473.tar.bz2
mason-8e921c2b68571e978db5d4d3fef9c9a7f8755473.tar.lz
mason-8e921c2b68571e978db5d4d3fef9c9a7f8755473.tar.xz
mason-8e921c2b68571e978db5d4d3fef9c9a7f8755473.tar.zst
mason-8e921c2b68571e978db5d4d3fef9c9a7f8755473.zip
feat: add the infrastructure to support "system" packages (#2085)HEADmain
This enables `mason.nvim` to start managing certain packages that: 1) are not suitable for the core registry 2) should not surface in existing APIs and UIs
Diffstat (limited to 'lua/mason-core/package/init.lua')
-rw-r--r--lua/mason-core/package/init.lua13
1 files changed, 12 insertions, 1 deletions
diff --git a/lua/mason-core/package/init.lua b/lua/mason-core/package/init.lua
index cb4ef99e..07257d8d 100644
--- a/lua/mason-core/package/init.lua
+++ b/lua/mason-core/package/init.lua
@@ -76,6 +76,7 @@ Package.License = setmetatable({}, {
---@class RegistryPackageSpec
---@field schema RegistryPackageSpecSchema
---@field name string
+---@field system boolean?
---@field description string
---@field homepage string
---@field licenses string[]
@@ -147,9 +148,19 @@ function Package:uninstall(opts, callback)
end
---@param location? InstallLocation
+function Package:get_install_path(location)
+ location = location or InstallLocation.global()
+ if self.spec.system then
+ return location:system_package(self.name)
+ else
+ return location:package(self.name)
+ end
+end
+
+---@param location? InstallLocation
function Package:is_installed(location)
location = location or InstallLocation.global()
- local ok, stat = pcall(vim.loop.fs_stat, location:package(self.name))
+ local ok, stat = pcall(vim.loop.fs_stat, self:get_install_path(location))
if not ok or not stat then
return false
end