From 4dd2af5113c975f865da460f166ea0809cf51c3b Mon Sep 17 00:00:00 2001 From: Daan Sieben Date: Mon, 21 Oct 2024 10:58:54 +0200 Subject: [PATCH] feat: support initializeStopped setting --- src/tools/rust-analyzer/editors/code/package.json | 5 +++++ src/tools/rust-analyzer/editors/code/src/config.ts | 4 ++++ src/tools/rust-analyzer/editors/code/src/main.ts | 9 ++++++++- 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/tools/rust-analyzer/editors/code/package.json b/src/tools/rust-analyzer/editors/code/package.json index 6c7f402dc5f93..8005527d2fa12 100644 --- a/src/tools/rust-analyzer/editors/code/package.json +++ b/src/tools/rust-analyzer/editors/code/package.json @@ -349,6 +349,11 @@ "markdownDescription": "Whether to show the test explorer.", "default": false, "type": "boolean" + }, + "rust-analyzer.initializeStopped": { + "markdownDescription": "Do not start rust-analyzer server when the extension is activated.", + "default": false, + "type": "boolean" } } }, diff --git a/src/tools/rust-analyzer/editors/code/src/config.ts b/src/tools/rust-analyzer/editors/code/src/config.ts index abb4099f9f5eb..67bc72f1e1268 100644 --- a/src/tools/rust-analyzer/editors/code/src/config.ts +++ b/src/tools/rust-analyzer/editors/code/src/config.ts @@ -330,6 +330,10 @@ export class Config { get statusBarClickAction() { return this.get("statusBar.clickAction"); } + + get initializeStopped() { + return this.get("initializeStopped"); + } } export function prepareVSCodeConfig(resp: T): T { diff --git a/src/tools/rust-analyzer/editors/code/src/main.ts b/src/tools/rust-analyzer/editors/code/src/main.ts index 0ddc5619e9942..fdf43f66f9499 100644 --- a/src/tools/rust-analyzer/editors/code/src/main.ts +++ b/src/tools/rust-analyzer/editors/code/src/main.ts @@ -107,7 +107,14 @@ async function activateServer(ctx: Ctx): Promise { initializeDebugSessionTrackingAndRebuild(ctx); } - await ctx.start(); + if (ctx.config.initializeStopped) { + ctx.setServerStatus({ + health: "stopped", + }); + } else { + await ctx.start(); + } + return ctx; }