From 7c2595c26820917fa9ad1b1c36f01fc6ac979287 Mon Sep 17 00:00:00 2001 From: Igor Matuszewski Date: Mon, 18 Mar 2019 22:35:47 +0100 Subject: [PATCH] Guard auto cargo watch behind a config option --- editors/code/package.json | 5 +++++ editors/code/src/commands/runnables.ts | 4 ++++ editors/code/src/config.ts | 8 ++++++++ 3 files changed, 17 insertions(+) diff --git a/editors/code/package.json b/editors/code/package.json index 3834f28473..3e8cde3880 100644 --- a/editors/code/package.json +++ b/editors/code/package.json @@ -168,6 +168,11 @@ "default": "ra_lsp_server", "description": "Path to ra_lsp_server executable" }, + "rust-analyzer.enableCargoWatchOnStartup": { + "type": "boolean", + "default": "true", + "description": "When enabled, ask the user whether to run `cargo watch` on startup" + }, "rust-analyzer.trace.server": { "type": "string", "scope": "window", diff --git a/editors/code/src/commands/runnables.ts b/editors/code/src/commands/runnables.ts index 285afaaf67..74407dc3e5 100644 --- a/editors/code/src/commands/runnables.ts +++ b/editors/code/src/commands/runnables.ts @@ -153,6 +153,10 @@ export const autoCargoWatchTask: vscode.Task = { * that, when accepted, allow us to `cargo install cargo-watch` and then run it. */ export async function interactivelyStartCargoWatch() { + if (!Server.config.enableCargoWatchOnStartup) { + return; + } + const execAsync = util.promisify(exec); const watch = await vscode.window.showInformationMessage( diff --git a/editors/code/src/config.ts b/editors/code/src/config.ts index afc5cc6aff..d8795f3b0f 100644 --- a/editors/code/src/config.ts +++ b/editors/code/src/config.ts @@ -9,6 +9,7 @@ export class Config { public enableEnhancedTyping = true; public raLspServerPath = RA_LSP_DEBUG || 'ra_lsp_server'; public showWorkspaceLoadedNotification = true; + public enableCargoWatchOnStartup = true; private prevEnhancedTyping: null | boolean = null; @@ -68,5 +69,12 @@ export class Config { this.raLspServerPath = RA_LSP_DEBUG || (config.get('raLspServerPath') as string); } + + if (config.has('enableCargoWatchOnStartup')) { + this.enableCargoWatchOnStartup = config.get( + 'enableCargoWatchOnStartup', + true + ); + } } }