From 90f7909d532c75781ebc3b2bd62e07d992264678 Mon Sep 17 00:00:00 2001 From: Valentine Briese Date: Wed, 4 Dec 2024 10:27:41 -0800 Subject: [PATCH] Launch JDTLS with `$JAVA_HOME` set to `java.home` initialization option if set --- src/lib.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index 1e1fede..02073e3 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -218,12 +218,27 @@ impl zed::Extension for Java { .map(|classpath_str| classpath_str.to_string()) }) }); + let java_home = LspSettings::for_worktree(language_server_id.as_ref(), worktree)? + .initialization_options + .and_then(|initialization_options| { + initialization_options + .pointer("/settings/java/home") + .and_then(|java_home_value| { + java_home_value + .as_str() + .map(|java_home_str| java_home_str.to_string()) + }) + }); let mut env = Vec::new(); if let Some(classpath) = classpath { env.push(("CLASSPATH".to_string(), classpath)); } + if let Some(java_home) = java_home { + env.push(("JAVA_HOME".to_string(), java_home)); + } + let mut args = Vec::new(); // Add lombok as javaagent if initialization_options.settings.java.jdt.ls.lombokSupport.enabled is true