Skip to content

Commit ed45a80

Browse files
committed
fix: use one and only one lsp-users-projects-root workspace
Make docker built image point to that instead of test one
1 parent ef40a10 commit ed45a80

File tree

11 files changed

+43
-41
lines changed

11 files changed

+43
-41
lines changed

completions/src/main/kotlin/completions/configuration/lsp/LspProperties.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,6 @@ data class LspProperties(
1111
val host: String,
1212
val port: Int,
1313
val reconnectionRetries: Int,
14+
val remoteWorkspaceRoot: String = "/lsp/workspaces/lsp-users-projects-root",
15+
val localWorkspaceRoot: String = "/lsp/workspaces/lsp-users-projects-root"
1416
)

completions/src/main/kotlin/completions/lsp/KotlinLspProxy.kt

Lines changed: 1 addition & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ class KotlinLspProxy(private val lspProperties: LspProperties) {
113113
* @param clientName the name of the client, defaults to "lsp-proxy"
114114
*/
115115
suspend fun initializeClient(
116-
workspacePath: String = lspRemoteWorkspaceRoot().path,
116+
workspacePath: String = Path.of(lspProperties.remoteWorkspaceRoot).toUri().path,
117117
clientName: String = "kotlin-compiler-server"
118118
) {
119119
if (!::lspClient.isInitialized) {
@@ -203,37 +203,8 @@ class KotlinLspProxy(private val lspProperties: LspProperties) {
203203
}
204204
}
205205

206-
/**
207-
* [lspRemoteWorkspaceRoot] is the workspace that the LSP will point to, while
208-
* [lspLocalWorkspaceRoot] is the local workspace that the LSP client is running on.
209-
* They are usually the same if the LSP client is running on the same machine as the server,
210-
* otherwise [lspRemoteWorkspaceRoot] will have to be set wrt to server's local workspace.
211-
*
212-
* Note that [lspRemoteWorkspaceRoot] is the most important one, since it will be used
213-
* from the LSP analyzer to resolve the project's dependencies.
214-
*/
215206
companion object {
216207
private val logger = LoggerFactory.getLogger(KotlinLspProxy::class.java)
217-
218-
fun lspRemoteWorkspaceRoot(): URI =Path.of(
219-
System.getProperty("LSP_REMOTE_WORKSPACE_ROOT")
220-
?: System.getenv("LSP_REMOTE_WORKSPACE_ROOT")
221-
?: defaultWorkspacePath()
222-
).toUri()
223-
224-
fun lspLocalWorkspaceRoot(): URI = Path.of(
225-
System.getProperty("LSP_LOCAL_WORKSPACE_ROOT")
226-
?: System.getenv("LSP_LOCAL_WORKSPACE_ROOT")
227-
?: defaultWorkspacePath()
228-
).toUri()
229-
230-
private fun defaultWorkspacePath(): String =
231-
System.getProperty("LSP_USERS_PROJECTS_ROOT")
232-
?: System.getProperty("LSP_USERS_PROJECTS_ROOT")
233-
?: run {
234-
KotlinLspProxy::class.java.getResource("/lsp-users-projects-root")?.path
235-
?: error("Could not find default workspace path")
236-
}
237208
}
238209
}
239210

completions/src/main/resources/application-local.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ lsp:
44
host: ${LSP_HOST:localhost}
55
port: ${LSP_PORT:9999}
66
reconnection-retries: 10
7+
remote-workspace-root: /workspaces/lsp-users-projects-root
78
spring:
89
docker:
910
compose:

completions/src/main/resources/application.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ lsp:
44
host: {$LSP_HOST:localhost}
55
port: ${LSP_PORT:9999}
66
reconnection-retries: 10
7+
remote-workspace-root: /workspaces/lsp-users-projects-root
8+
79
springdoc:
810
swagger-ui:
911
enabled: false

completions/src/main/resources/lsp-users-projects-root/build.gradle.kts

Lines changed: 0 additions & 7 deletions
This file was deleted.
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
FROM gradle:9-jdk-21-and-24
2+
3+
ARG ZIP_VERSION
4+
ARG ZIP_ARCH
5+
ENV ZIP_VERSION=${ZIP_VERSION}
6+
ENV ZIP_ARCH=${ZIP_ARCH}
7+
8+
RUN apt-get update && apt-get install -y curl zip unzip bash netcat-openbsd \
9+
&& rm -rf /var/lib/apt/lists/*
10+
11+
COPY workspaces /workspaces/
12+
WORKDIR /lsp
13+
14+
COPY server/intellij-lsp-${ZIP_VERSION}-linux-${ZIP_ARCH}.zip ./intellij-lsp.zip
15+
16+
RUN unzip intellij-lsp.zip \
17+
&& rm intellij-lsp.zip \
18+
&& chmod +x ./kotlin-lsp.sh
19+
20+
EXPOSE 9999
21+
22+
CMD ["./kotlin-lsp.sh", "--multi-client", "--isolated-documents", "--socket", "0.0.0.0:9999"]
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
plugins {
2+
kotlin("jvm") version "2.2.20"
3+
}
4+
5+
repositories {
6+
mavenCentral()
7+
}
8+
9+
dependencies {
10+
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.10.2")
11+
}

completions/src/test/kotlin/lsp/LspClientTest.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,8 @@ class LspClientTest : CompletionTest, LspIntegrationTest() {
7070
}
7171

7272
companion object {
73-
private val WORKSPACE_PATH = System.getProperty("LSP_REMOTE_WORKSPACE_ROOT") ?:
74-
LspClientTest::class.java.getResource("/lsp/lsp-users-projects-root-test")?.path
73+
private val WORKSPACE_PATH = System.getProperty("LSP_REMOTE_WORKSPACE_ROOT")
74+
?: LspClientTest::class.java.getResource("/lsp/workspaces/lsp-users-projects-root")?.path
7575
?: error("Could not find LSP remote workspace root")
7676
private val LSP_HOST = System.getProperty("LSP_HOST") ?: "localhost"
7777
private val LSP_PORT = System.getProperty("LSP_PORT")?.toInt() ?: 9999

0 commit comments

Comments
 (0)