Skip to content
This repository was archived by the owner on Nov 30, 2025. It is now read-only.

Commit 33115d9

Browse files
authored
refactor: use custom cmd instead of using jdtls python wrapper (#39)
* this removes the python dependency to use this plugin
1 parent ccac829 commit 33115d9

File tree

1 file changed

+31
-4
lines changed

1 file changed

+31
-4
lines changed

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

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,19 +22,46 @@ local M = {}
2222
function M.get_config(opts)
2323
log.debug('generating jdtls config')
2424

25-
local jdtls_path = mason.get_pkg_path('jdtls')
26-
local lombok_path = path.join(jdtls_path, 'lombok.jar')
27-
local jdtls_cache_path = path.join(vim.fn.stdpath('cache'), 'jdtls')
25+
-- this is the configuration found in the jdtls package. Here, I don't have to
26+
-- pick the OS at runtime because mason.nvim does that for me at the
27+
-- installation
28+
local jdtls_root = mason.get_shared_path('jdtls')
29+
local jdtls_config = path.join(jdtls_root, 'config')
30+
local lombok_path = path.join(jdtls_root, 'lombok.jar')
31+
local equinox_launcher =
32+
path.join(jdtls_root, 'plugins', 'org.eclipse.equinox.launcher.jar')
2833
local plugin_paths = plugins.get_plugin_paths(opts.jdtls_plugins)
34+
local jdtls_cache_path = path.join(vim.fn.stdpath('cache'), 'jdtls')
2935

3036
local base_config = config.get_config()
3137

3238
base_config.cmd = {
33-
'jdtls',
39+
'java',
40+
'-Declipse.application=org.eclipse.jdt.ls.core.id1',
41+
'-Dosgi.bundles.defaultStartLevel=4',
42+
'-Declipse.product=org.eclipse.jdt.ls.core.product',
43+
'-Dosgi.checkConfiguration=true',
44+
'-Dosgi.sharedConfiguration.area=' .. jdtls_config,
45+
'-Dosgi.sharedConfiguration.area.readOnly=true',
46+
'-Dosgi.configuration.cascaded=true',
47+
'-Xms1G',
48+
'--add-modules=ALL-SYSTEM',
49+
50+
'--add-opens',
51+
'java.base/java.util=ALL-UNNAMED',
52+
53+
'--add-opens',
54+
'java.base/java.lang=ALL-UNNAMED',
55+
56+
'-jar',
57+
equinox_launcher,
58+
3459
'-configuration',
3560
jdtls_cache_path,
61+
3662
'-data',
3763
workspace.get_default_workspace(),
64+
3865
'-javaagent:' .. lombok_path,
3966
}
4067

0 commit comments

Comments
 (0)