Skip to content

Commit 0fd98aa

Browse files
logrusxs1n7ax
andauthored
feat: adds Mason 2.0 support (#93)
* feat: Mason 2.0 migration * chore: code formatting * chore: release 2.0.0 Release-As: 2.0.0 --------- Co-authored-by: s1n7ax <[email protected]>
1 parent 401bf76 commit 0fd98aa

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

lua/java-core/ls/servers/jdtls/init.lua

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,7 @@ function M.get_config(opts)
6969
local jdk = mason_reg.get_package('openjdk-17')
7070

7171
if jdk:is_installed() then
72-
local java_home =
73-
vim.fn.glob(path.join(jdk:get_install_path(), '/jdk-17*'))
72+
local java_home = vim.fn.glob('$MASON/packages/jdk-17*')
7473
local java_bin = path.join(java_home, '/bin')
7574

7675
base_config.cmd_env = {

lua/java-core/utils/mason.lua

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,19 @@ local M = {}
66
---@param pkg_name string
77
---@return string | nil
88
function M.get_pkg_path(pkg_name)
9-
return mason_registry.get_package(pkg_name):get_install_path()
9+
local found, pkg = pcall(mason_registry.get_package, pkg_name)
10+
if not found or not pkg:is_installed() then
11+
return nil
12+
end
13+
return vim.fn.expand('$MASON/packages/' .. pkg_name)
1014
end
1115

12-
---Returns true if the package in installed in mason
16+
---Returns true if the package is installed in mason
1317
---@param pkg_name string
1418
---@return boolean
1519
function M.is_pkg_installed(pkg_name)
16-
return mason_registry.get_package(pkg_name):is_installed()
20+
local found, pkg = pcall(mason_registry.get_package, pkg_name)
21+
return found and pkg:is_installed()
1722
end
1823

1924
---Returns the shared artifact path for a given package

tests/prepare-config.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ require('lazy').setup({
2525
lazy = false,
2626
},
2727
{
28-
'williamboman/mason.nvim',
28+
'mason-org/mason.nvim',
2929
lazy = false,
3030
},
3131
}, {

0 commit comments

Comments
 (0)