Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lua/java-core/ls/servers/jdtls/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ function M.get_config(opts)

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

base_config.cmd_env = {
Expand Down
11 changes: 8 additions & 3 deletions lua/java-core/utils/mason.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,19 @@ local M = {}
---@param pkg_name string
---@return string | nil
function M.get_pkg_path(pkg_name)
return mason_registry.get_package(pkg_name):get_install_path()
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 in installed in mason
---Returns true if the package is installed in mason
---@param pkg_name string
---@return boolean
function M.is_pkg_installed(pkg_name)
return mason_registry.get_package(pkg_name):is_installed()
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
Expand Down
2 changes: 1 addition & 1 deletion tests/prepare-config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ require('lazy').setup({
lazy = false,
},
{
'williamboman/mason.nvim',
'mason-org/mason.nvim',
lazy = false,
},
}, {
Expand Down