Skip to content
This repository has been archived by the owner on Dec 22, 2024. It is now read-only.

Commit

Permalink
Pass the interpreter path to Pyright on initialization (#13)
Browse files Browse the repository at this point in the history
  • Loading branch information
InSyncWithFoo committed Apr 8, 2024
1 parent 559da5d commit ba0947b
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/main/kotlin/com/insyncwithfoo/pyrightls/server/Listener.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.insyncwithfoo.pyrightls.server

import com.insyncwithfoo.pyrightls.sdkPath
import com.intellij.openapi.project.Project
import com.intellij.platform.lsp.api.LspServerListener
import com.intellij.platform.lsp.api.LspServerManager
Expand All @@ -15,10 +16,13 @@ internal class Listener(val project: Project) : LspServerListener {
// codeAction requests, but it never actually finishes initialising the workspace folders
// sent with the initialize request unless kickstarted with an (empty) didChangeConfiguration notification
// see: https://github.com/microsoft/pyright/issues/6874

val lspServerManager = LspServerManager.getInstance(project)
lspServerManager.getServersForProvider(PyrightLSSupportProvider::class.java).forEach {
it.sendNotification { lsp4jServer ->
lsp4jServer.workspaceService.didChangeConfiguration(DidChangeConfigurationParams())
val settings = project.sdkPath?.let { mapOf("python" to mapOf("pythonPath" to it.toString())) } ?: return

lspServerManager.getServersForProvider(PyrightLSSupportProvider::class.java).forEach { lspServer ->
lspServer.sendNotification {
it.workspaceService.didChangeConfiguration(DidChangeConfigurationParams(settings))
}
}
}
Expand Down

0 comments on commit ba0947b

Please sign in to comment.