Skip to content

Commit 7cb45eb

Browse files
darthorimarintellij-monorepo-bot
authored andcommitted
[lsp] add setting for custom jvm options when running lsp server from vscode plugin
#38 GitOrigin-RevId: f455d792a97b9ed2fc52bce99603c190e96e3d93
1 parent 5566e5d commit 7cb45eb

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

kotlin-vscode/client/src/lspClient.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,8 @@ async function getRunningJavaServerLspOptions(): Promise<ServerOptions | null> {
178178
const extractPath = getContext().asAbsolutePath(path.join('server', 'extracted', 'lib'));
179179

180180
const args: string[] = []
181-
args.push(...jvmOptions)
181+
args.push(...defaultJvmOptions)
182+
args.push(...getUserJvmOptions())
182183
args.push(
183184
'-classpath', extractPath + path.sep + '*',
184185
'com.jetbrains.ls.kotlinLsp.KotlinLspServerKt', '--client',
@@ -196,7 +197,14 @@ async function getRunningJavaServerLspOptions(): Promise<ServerOptions | null> {
196197
};
197198
}
198199

199-
const jvmOptions = [
200+
const jvmOptionsSettingName = 'kotlinLSP.additionalJvmArgs';
201+
202+
function getUserJvmOptions() : string[] {
203+
const settings = vscode.workspace.getConfiguration().get<string[]>(jvmOptionsSettingName)
204+
return settings ?? []
205+
}
206+
207+
const defaultJvmOptions = [
200208
"--add-opens", "java.base/java.io=ALL-UNNAMED",
201209
"--add-opens", "java.base/java.lang=ALL-UNNAMED",
202210
"--add-opens", "java.base/java.lang.ref=ALL-UNNAMED",

kotlin-vscode/package.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,11 @@
5656
"type": "string",
5757
"default": null,
5858
"description": "A path to the JRE that will be used to run the LSP. It should be at least version 17. If not specified, default java version will be used"
59+
},
60+
"kotlinLSP.additionalJvmArgs": {
61+
"type": "array",
62+
"default": [],
63+
"description": "Additional JVM arguments to pass to the LSP server"
5964
}
6065
}
6166
},

0 commit comments

Comments
 (0)