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 --- docs/user/README.md | 1 + editors/code/package.json | 5 +++++ editors/code/src/commands/cargo_watch.ts | 7 ++++++- editors/code/src/config.ts | 11 ++++++++++- 4 files changed, 22 insertions(+), 2 deletions(-) diff --git a/docs/user/README.md b/docs/user/README.md index 036b51d58..5b7502132 100644 --- a/docs/user/README.md +++ b/docs/user/README.md @@ -79,6 +79,7 @@ See [microsoft/vscode#72308](https://github.com/microsoft/vscode/issues/72308) f * `rust-analyzer.cargo-watch.command`: `cargo-watch` command. (e.g: `clippy` will run as `cargo watch -x clippy` ) * `rust-analyzer.cargo-watch.arguments`: cargo-watch check arguments. (e.g: `--features="shumway,pdf"` will run as `cargo watch -x "check --features="shumway,pdf""` ) +* `rust-analyzer.cargo-watch.ignore`: list of patterns for cargo-watch to ignore (will be passed as `--ignore`) * `rust-analyzer.trace.server`: enables internal logging * `rust-analyzer.trace.cargo-watch`: enables cargo-watch logging * `RUST_SRC_PATH`: environment variable that overwrites the sysroot 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