Skip to content

Commit 293ee31

Browse files
committed
fix: nvim-java does not work on mac with the embeded jdk
1 parent 32c0b75 commit 293ee31

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

lua/java-core/constants/java_version.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
return {
2-
['1.43.0'] = { from = 17, to = 21 },
2+
['1.43.0'] = { from = 17, to = 17 },
33
['1.44.0'] = { from = 17, to = 21 },
44
['1.45.0'] = { from = 21, to = 21 },
55
['1.46.0'] = { from = 21, to = 21 },

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

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
local path = require('java-core.utils.path')
22
local Manager = require('pkgm.manager')
33
local log = require('java-core.utils.log2')
4+
local system = require('java-core.utils.system')
45

56
--- @TODO: importing stuff from java main package feels wrong.
67
--- We should fix this in the future
@@ -16,7 +17,15 @@ function M.get_env(opts)
1617
end
1718

1819
local jdk_root = Manager:get_install_dir('openjdk', config.jdk.version)
19-
local java_home = vim.fn.glob(path.join(jdk_root, 'jdk-*'))
20+
21+
local java_home
22+
23+
if system.get_os() == 'mac' then
24+
java_home = vim.fn.glob(path.join(jdk_root, 'jdk-*', 'Contents', 'Home'))
25+
else
26+
java_home = vim.fn.glob(path.join(jdk_root, 'jdk-*'))
27+
end
28+
2029
local java_bin = path.join(java_home, 'bin')
2130

2231
local env = {

0 commit comments

Comments
 (0)