From f4d50de2758b38208745d9594ccbcf0227d49d5b Mon Sep 17 00:00:00 2001 From: Roberto Vidal Date: Thu, 17 Oct 2019 15:22:39 +0200 Subject: Adds config option for cargo-watch `--ignore` flag --- editors/code/package.json | 5 +++++ editors/code/src/commands/cargo_watch.ts | 7 ++++++- editors/code/src/config.ts | 11 ++++++++++- 3 files changed, 21 insertions(+), 2 deletions(-) (limited to 'editors') diff --git a/editors/code/package.json b/editors/code/package.json index 6649f5b73..5ae050110 100644 --- a/editors/code/package.json +++ b/editors/code/package.json @@ -224,6 +224,11 @@ "description": "`cargo-watch` command. (e.g: `clippy` will run as `cargo watch -x clippy` )", "default": "check" }, + "rust-analyzer.cargo-watch.ignore": { + "type": "array", + "description": "A list of patterns for cargo-watch to ignore (will be passed as `--ignore`)", + "default": [] + }, "rust-analyzer.showWorkspaceLoadedNotification": { "type": "boolean", "description": "Controls whether rust-analyzer displays a notification when a project is loaded.", diff --git a/editors/code/src/commands/cargo_watch.ts b/editors/code/src/commands/cargo_watch.ts index 00b24dbce..59d4ba97a 100644 --- a/editors/code/src/commands/cargo_watch.ts +++ b/editors/code/src/commands/cargo_watch.ts @@ -93,10 +93,15 @@ export class CargoWatchProvider implements vscode.Disposable { args = '"' + args + '"'; } + const ignoreFlags = Server.config.cargoWatchOptions.ignore.reduce( + (flags, pattern) => [...flags, '--ignore', pattern], + [] as string[] + ); + // Start the cargo watch with json message this.cargoProcess = child_process.spawn( 'cargo', - ['watch', '-x', args], + ['watch', '-x', args, ...ignoreFlags], { stdio: ['ignore', 'pipe', 'pipe'], cwd: vscode.workspace.rootPath, diff --git a/editors/code/src/config.ts b/editors/code/src/config.ts index a4581485c..49bdf7d72 100644 --- a/editors/code/src/config.ts +++ b/editors/code/src/config.ts @@ -12,6 +12,7 @@ export interface CargoWatchOptions { arguments: string; command: string; trace: CargoWatchTraceOptions; + ignore: string[]; } export class Config { @@ -29,7 +30,8 @@ export class Config { enableOnStartup: 'ask', trace: 'off', arguments: '', - command: '' + command: '', + ignore: [] }; private prevEnhancedTyping: null | boolean = null; @@ -124,6 +126,13 @@ export class Config { ); } + if (config.has('cargo-watch.ignore')) { + this.cargoWatchOptions.ignore = config.get( + 'cargo-watch.ignore', + [] + ); + } + if (config.has('lruCapacity')) { this.lruCapacity = config.get('lruCapacity') as number; } -- cgit v1.2.3