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
31 lines (26 loc) · 923 Bytes
/
mason.lua
File metadata and controls
31 lines (26 loc) · 923 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
30
31
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 found, pkg = pcall(mason_registry.get_package, pkg_name)
if not found or not pkg:is_installed() then
return nil
end
return vim.fn.expand('$MASON/packages/' .. pkg_name)
end
---Returns true if the package is installed in mason
---@param pkg_name string
---@return boolean
function M.is_pkg_installed(pkg_name)
local found, pkg = pcall(mason_registry.get_package, pkg_name)
return found and pkg:is_installed()
end
---Returns the shared artifact path for a given package
---@param pkg_name string name of the package to get the path of
---@return string # path to the shared artifact directory of the package
function M.get_shared_path(pkg_name)
return vim.fn.glob('$MASON/share/' .. pkg_name)
end
return M