diff --git a/extensions/intellij/build.gradle.kts b/extensions/intellij/build.gradle.kts index e290aa5777..88b2bf362a 100644 --- a/extensions/intellij/build.gradle.kts +++ b/extensions/intellij/build.gradle.kts @@ -32,7 +32,7 @@ tasks { patchPluginXml { sinceBuild.set("241") - untilBuild.set("241.*") + untilBuild.set("242.*") } signPlugin { diff --git a/extensions/intellij/src/main/kotlin/xyz/block/ftl/intellij/FTLLspServerDescriptor.kt b/extensions/intellij/src/main/kotlin/xyz/block/ftl/intellij/FTLLspServerDescriptor.kt index 3d31f8951a..4193ed4000 100644 --- a/extensions/intellij/src/main/kotlin/xyz/block/ftl/intellij/FTLLspServerDescriptor.kt +++ b/extensions/intellij/src/main/kotlin/xyz/block/ftl/intellij/FTLLspServerDescriptor.kt @@ -4,12 +4,16 @@ import com.intellij.execution.configurations.GeneralCommandLine import com.intellij.execution.process.OSProcessHandler import com.intellij.execution.process.ProcessAdapter import com.intellij.execution.process.ProcessEvent +import com.intellij.ide.DataManager import com.intellij.openapi.project.Project import com.intellij.openapi.util.Key import com.intellij.openapi.vfs.VirtualFile +import com.intellij.openapi.wm.ToolWindowManager import com.intellij.platform.lsp.api.LspServerNotificationsHandler import com.intellij.platform.lsp.api.ProjectWideLspServerDescriptor +import com.intellij.tools.ToolsCustomizer import xyz.block.ftl.intellij.toolWindow.FTLMessagesToolWindowFactory +import java.util.concurrent.CompletableFuture import java.util.regex.Pattern class FTLLspServerDescriptor(project: Project) : ProjectWideLspServerDescriptor(project, "FTL") { @@ -26,6 +30,23 @@ class FTLLspServerDescriptor(project: Project) : ProjectWideLspServerDescriptor( generalCommandLine.setWorkDirectory(project.basePath) displayMessageInToolWindow("LSP Server Command: " + generalCommandLine.commandLineString) displayMessageInToolWindow("Working Directory: " + generalCommandLine.workDirectory) + try { + // Hermit support, we need to get the environment variables so we use the correct FTL + val result = CompletableFuture() + runOnEDT { + val toolWindow = ToolWindowManager.getInstance(project).getToolWindow("FTL") + if (toolWindow != null) { + val dataContext = DataManager.getInstance().getDataContext(toolWindow.component) + val customizeCommandLine = + ToolsCustomizer.customizeCommandLine(generalCommandLine, dataContext) + result.complete(customizeCommandLine) + } + } + val res = result.get() + return if (res != null) res else generalCommandLine + } catch (e: Exception) { + displayMessageInToolWindow("Failed to customize LSP Server Command: " + e.message) + } return generalCommandLine } @@ -33,6 +54,22 @@ class FTLLspServerDescriptor(project: Project) : ProjectWideLspServerDescriptor( displayMessageInToolWindow("Starting FTL LSP Server") val processHandler = super.startServerProcess() processHandler.addProcessListener(object : ProcessAdapter() { + + override fun startNotified(event: ProcessEvent) { + super.startNotified(event) + displayMessageInToolWindow("LSP Started") + } + + override fun processTerminated(event: ProcessEvent) { + super.processTerminated(event) + displayMessageInToolWindow("LSP Terminated") + } + + override fun processWillTerminate(event: ProcessEvent, willBeDestroyed: Boolean) { + super.processWillTerminate(event, willBeDestroyed) + displayMessageInToolWindow("LSP Will Terminate") + } + override fun onTextAvailable(event: ProcessEvent, outputType: Key<*>) { val message = event.text.trim() if (message.isNotBlank()) { diff --git a/extensions/intellij/src/main/kotlin/xyz/block/ftl/intellij/FTLSettingsConfigurable.kt b/extensions/intellij/src/main/kotlin/xyz/block/ftl/intellij/FTLSettingsConfigurable.kt index 689c367ee6..1e2c844810 100644 --- a/extensions/intellij/src/main/kotlin/xyz/block/ftl/intellij/FTLSettingsConfigurable.kt +++ b/extensions/intellij/src/main/kotlin/xyz/block/ftl/intellij/FTLSettingsConfigurable.kt @@ -32,7 +32,7 @@ class FTLSettingsConfigurable : Configurable { override fun apply() { val state = AppSettings.getInstance().state state.lspServerPath = mySettingsComponent?.getLspServerPath() ?: "ftl" - state.lspServerArguments = mySettingsComponent?.getLspServerArguments() ?: "--recreate --lsp" + state.lspServerArguments = mySettingsComponent?.getLspServerArguments() ?: " dev --recreate --lsp" state.lspServerStopArguments = mySettingsComponent?.getLspServerStopArguments() ?: "serve --stop" }