Skip to content

Commit

Permalink
fix: propagate intellij environment to language server
Browse files Browse the repository at this point in the history
  • Loading branch information
bastiandoetsch committed Sep 12, 2024
1 parent 8139591 commit f25499d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 3 additions & 0 deletions src/main/kotlin/snyk/common/EnvironmentHelper.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package snyk.common

import com.intellij.util.EnvironmentUtil
import com.intellij.util.net.HttpConfigurable
import io.snyk.plugin.pluginSettings
import snyk.pluginInfo
Expand All @@ -11,6 +12,8 @@ object EnvironmentHelper {
environment: MutableMap<String, String>,
apiToken: String,
) {
// first of all, use IntelliJ environment tool, to spice up env
environment.putAll(EnvironmentUtil.getEnvironmentMap())
val endpoint = getEndpointUrl()

val oauthEnabledEnvVar = "INTERNAL_SNYK_OAUTH_ENABLED"
Expand Down
3 changes: 1 addition & 2 deletions src/main/kotlin/snyk/common/lsp/LanguageServerWrapper.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import io.snyk.plugin.isSnykIaCLSEnabled
import io.snyk.plugin.isSnykOSSLSEnabled
import io.snyk.plugin.pluginSettings
import io.snyk.plugin.toLanguageServerURL
import io.snyk.plugin.toVirtualFile
import io.snyk.plugin.ui.toolwindow.SnykPluginDisposable
import kotlinx.coroutines.DelicateCoroutinesApi
import kotlinx.coroutines.GlobalScope
Expand Down Expand Up @@ -132,7 +131,7 @@ class LanguageServerWrapper(
val cmd = listOf(lsPath, "language-server", "-l", logLevel)

val processBuilder = ProcessBuilder(cmd)
pluginSettings().token?.let { EnvironmentHelper.updateEnvironment(processBuilder.environment(), it) }
EnvironmentHelper.updateEnvironment(processBuilder.environment(), pluginSettings().token ?: "")

process = processBuilder.start()
launcher = LSPLauncher.createClientLauncher(languageClient, process.inputStream, process.outputStream)
Expand Down

0 comments on commit f25499d

Please sign in to comment.