forked from nvim-java/nvim-java-core
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmason.lua
More file actions
30 lines (24 loc) · 811 Bytes
/
mason.lua
File metadata and controls
30 lines (24 loc) · 811 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
local mason_registry = require('mason-registry')
local M = {}
---Returns the path to the package in mason packages
---@param pkg_name string
---@return string | nil
function M.get_pkg_path(pkg_name)
local mason_data_path = vim.fn.stdpath("data") .. "/mason/packages/" .. pkg_name
return mason_data_path
end
---Returns true if the package is installed in mason
---@param pkg_name string
---@return boolean
function M.is_pkg_installed(pkg_name)
local ok, pkg = pcall(mason_registry.get_package, pkg_name)
return ok and pkg:is_installed()
end
---Returns the shared artifact path for a given package
---@param pkg_name string
---@return string
function M.get_shared_path(pkg_name)
local mason_share_path = vim.fn.stdpath("data") .. "/mason/share/" .. pkg_name
return mason_share_path
end
return M