diff --git a/src/main/java/co/huggingface/llmintellij/lsp/LLMOsProcessHandler.java b/src/main/java/co/huggingface/llmintellij/lsp/LLMOsProcessHandler.java new file mode 100644 index 0000000..d073da6 --- /dev/null +++ b/src/main/java/co/huggingface/llmintellij/lsp/LLMOsProcessHandler.java @@ -0,0 +1,19 @@ +package co.huggingface.llmintellij.lsp; + +import com.intellij.execution.ExecutionException; +import com.intellij.execution.configurations.GeneralCommandLine; +import com.intellij.execution.process.OSProcessHandler; +import com.intellij.util.io.BaseOutputReader; +import com.intellij.util.io.BaseOutputReader.Options; +import org.jetbrains.annotations.NotNull; + + +class LLMOsProcessHandler extends OSProcessHandler { + public LLMOsProcessHandler(@NotNull GeneralCommandLine commandLine) throws ExecutionException { + super(commandLine); + } + + protected @NotNull Options readerOptions() { + return BaseOutputReader.Options.forMostlySilentProcess(); + } +} diff --git a/src/main/kotlin/co/huggingface/llmintellij/lsp/LlmLsLspServerDescriptor.kt b/src/main/kotlin/co/huggingface/llmintellij/lsp/LlmLsLspServerDescriptor.kt index 3d5ea0b..bb3b1ba 100644 --- a/src/main/kotlin/co/huggingface/llmintellij/lsp/LlmLsLspServerDescriptor.kt +++ b/src/main/kotlin/co/huggingface/llmintellij/lsp/LlmLsLspServerDescriptor.kt @@ -1,11 +1,14 @@ package co.huggingface.llmintellij.lsp import co.huggingface.llmintellij.LlmSettingsState +import com.intellij.execution.ExecutionException import com.intellij.execution.configurations.GeneralCommandLine +import com.intellij.execution.process.OSProcessHandler import com.intellij.openapi.diagnostic.Logger import com.intellij.openapi.project.Project import com.intellij.openapi.vfs.VirtualFile import com.intellij.platform.lsp.api.ProjectWideLspServerDescriptor +import com.intellij.util.concurrency.annotations.RequiresBackgroundThread import io.ktor.util.* import org.eclipse.lsp4j.services.LanguageServer import java.io.File @@ -13,6 +16,14 @@ import java.io.File class LlmLsLspServerDescriptor(project: Project) : ProjectWideLspServerDescriptor(project, "LlmLs") { private val logger = Logger.getInstance("llmLsLspServerDescriptor") + @RequiresBackgroundThread + @Throws(ExecutionException::class) + override fun startServerProcess(): OSProcessHandler { + val startingCommandLine = createCommandLine() + LOG.info("$this: starting LSP server: $startingCommandLine") + return LLMOsProcessHandler(startingCommandLine) + } + override fun isSupportedFile(file: VirtualFile) = true override fun createCommandLine(): GeneralCommandLine {