]> git.lizzy.rs Git - rust.git/commitdiff
Introduce cargo-watch.check-command
authorAleksei Sidorov <aleksei.sidorov@xdev.re>
Mon, 24 Jun 2019 10:02:20 +0000 (13:02 +0300)
committerAleksei Sidorov <aleksei.sidorov@xdev.re>
Mon, 24 Jun 2019 10:02:20 +0000 (13:02 +0300)
editors/code/package.json
editors/code/src/commands/cargo_watch.ts
editors/code/src/commands/watch_status.ts
editors/code/src/config.ts

index c2ed8d1268fe45b001d6a97e053f1ba15eca5cb4..e4fc682df92faedd081d8213a9788c3ff7a04039 100644 (file)
                 },
                 "rust-analyzer.cargo-watch.check-arguments": {
                     "type": "string",
-                    "description": "`cargo-watch` check arguments. (e.g: `--features=\"shumway,pdf\"` will run as `cargo watch -x \"check --features=\"shumway,pdf\"\"` )",
+                    "description": "`cargo-watch` arguments. (e.g: `--features=\"shumway,pdf\"` will run as `cargo watch -x \"check --features=\"shumway,pdf\"\"` )",
                     "default": ""
                 },
+                "rust-analyzer.cargo-watch.check-command": {
+                    "type": "string",
+                    "description": "`cargo-watch` command. (e.g: `clippy` will run as `cargo watch -x clippy` )",
+                    "default": "check"                    
+                },
                 "rust-analyzer.trace.server": {
                     "type": "string",
                     "scope": "window",
index 6ba794bb337aad8a8249b137e2c573f1e39da232..db92e03f4cc5f2db739ffe56986e77c19a0e59ea 100644 (file)
@@ -43,7 +43,7 @@ export class CargoWatchProvider implements vscode.Disposable {
         this.diagnosticCollection = vscode.languages.createDiagnosticCollection(
             'rustc'
         );
-        this.statusDisplay = new StatusDisplay();
+        this.statusDisplay = new StatusDisplay(Server.config.cargoWatchOptions.checkCommand);
         this.outputChannel = vscode.window.createOutputChannel(
             'Cargo Watch Trace'
         );
@@ -57,7 +57,9 @@ export class CargoWatchProvider implements vscode.Disposable {
             return;
         }
 
-        let args = 'check --all-targets --message-format json';
+        let command = Server.config.cargoWatchOptions.checkCommand;
+
+        let args = command + ' --all-targets --message-format json';
         if (Server.config.cargoWatchOptions.checkArguments.length > 0) {
             // Excape the double quote string:
             args += ' ' + Server.config.cargoWatchOptions.checkArguments;
index a3b0178f20a6e4f32cf8f1a60e1367bdf1f34a6a..91bc7195b2ea76091b9eebd0a115034ea9c09951 100644 (file)
@@ -7,13 +7,15 @@ export class StatusDisplay implements vscode.Disposable {
 
     private i = 0;
     private statusBarItem: vscode.StatusBarItem;
+    private command: string;
     private timer?: NodeJS.Timeout;
 
-    constructor() {
+    constructor(command: string) {
         this.statusBarItem = vscode.window.createStatusBarItem(
             vscode.StatusBarAlignment.Left,
             10
         );
+        this.command = command;
         this.statusBarItem.hide();
     }
 
@@ -24,11 +26,11 @@ export class StatusDisplay implements vscode.Disposable {
             this.timer ||
             setInterval(() => {
                 if (this.packageName) {
-                    this.statusBarItem!.text = `cargo check [${
+                    this.statusBarItem!.text = `cargo ${this.command} [${
                         this.packageName
                     }] ${this.frame()}`;
                 } else {
-                    this.statusBarItem!.text = `cargo check ${this.frame()}`;
+                    this.statusBarItem!.text = `cargo ${this.command} ${this.frame()}`;
                 }
             }, 300);
 
index 3024546d25e0e6ba93c5f853173f3c75df968481..85366fc341e34314234629290046855b89d7e739 100644 (file)
@@ -1,6 +1,7 @@
 import * as vscode from 'vscode';
 
 import { Server } from './server';
+import { strict } from 'assert';
 
 const RA_LSP_DEBUG = process.env.__RA_LSP_SERVER_DEBUG;
 
@@ -10,6 +11,7 @@ export type CargoWatchTraceOptions = 'off' | 'error' | 'verbose';
 export interface CargoWatchOptions {
     enableOnStartup: CargoWatchStartupOptions;
     checkArguments: string;
+    checkCommand: string;
     trace: CargoWatchTraceOptions;
 }
 
@@ -23,7 +25,8 @@ export class Config {
     public cargoWatchOptions: CargoWatchOptions = {
         enableOnStartup: 'ask',
         trace: 'off',
-        checkArguments: ''
+        checkArguments: '',
+        checkCommand: ''
     };
 
     private prevEnhancedTyping: null | boolean = null;
@@ -110,6 +113,14 @@ export class Config {
                 ''
             );
         }
+
+        if (config.has('cargo-watch.check-command')) {
+            this.cargoWatchOptions.checkCommand = config.get<string>(
+                'cargo-watch.check-command', 
+                ''
+            );
+        }
+
         if (config.has('lruCapacity')) {
             this.lruCapacity = config.get('lruCapacity') as number;
         }