]> git.lizzy.rs Git - rust.git/commitdiff
Adds config option for cargo-watch `--ignore` flag
authorRoberto Vidal <vidal.roberto.j@gmail.com>
Thu, 17 Oct 2019 13:22:39 +0000 (15:22 +0200)
committerRoberto Vidal <vidal.roberto.j@gmail.com>
Thu, 17 Oct 2019 18:21:07 +0000 (20:21 +0200)
docs/user/README.md
editors/code/package.json
editors/code/src/commands/cargo_watch.ts
editors/code/src/config.ts

index 036b51d5869d68b35b3090e273ad48fed2d6704a..5b7502132f865c16ba1d9557dd9d6b13981403cc 100644 (file)
@@ -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
index 6649f5b7316eb7ed41aab24d89371f6c5b92db2a..5ae0501108b0aa2ba5f5e20acc63532a57b61677 100644 (file)
                     "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.",
index 00b24dbced4a68fae5c63c6ea0d839a68c7afdac..59d4ba97a2390f9cd98b8e7f0708f87774c56024 100644 (file)
@@ -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,
index a4581485cccb83b764d0c7bd1f22e017acb575f6..49bdf7d729db5a80e676ca1f5bc6d272cb6b352a 100644 (file)
@@ -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<string[]>(
+                'cargo-watch.ignore',
+                []
+            );
+        }
+
         if (config.has('lruCapacity')) {
             this.lruCapacity = config.get('lruCapacity') as number;
         }