mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-27 05:23:24 +00:00
Introduce cargo-watch.check-command
This commit is contained in:
parent
7d79be3280
commit
4722e6d491
4 changed files with 27 additions and 7 deletions
|
@ -203,9 +203,14 @@
|
||||||
},
|
},
|
||||||
"rust-analyzer.cargo-watch.check-arguments": {
|
"rust-analyzer.cargo-watch.check-arguments": {
|
||||||
"type": "string",
|
"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": ""
|
"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": {
|
"rust-analyzer.trace.server": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"scope": "window",
|
"scope": "window",
|
||||||
|
|
|
@ -43,7 +43,7 @@ export class CargoWatchProvider implements vscode.Disposable {
|
||||||
this.diagnosticCollection = vscode.languages.createDiagnosticCollection(
|
this.diagnosticCollection = vscode.languages.createDiagnosticCollection(
|
||||||
'rustc'
|
'rustc'
|
||||||
);
|
);
|
||||||
this.statusDisplay = new StatusDisplay();
|
this.statusDisplay = new StatusDisplay(Server.config.cargoWatchOptions.checkCommand);
|
||||||
this.outputChannel = vscode.window.createOutputChannel(
|
this.outputChannel = vscode.window.createOutputChannel(
|
||||||
'Cargo Watch Trace'
|
'Cargo Watch Trace'
|
||||||
);
|
);
|
||||||
|
@ -57,7 +57,9 @@ export class CargoWatchProvider implements vscode.Disposable {
|
||||||
return;
|
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) {
|
if (Server.config.cargoWatchOptions.checkArguments.length > 0) {
|
||||||
// Excape the double quote string:
|
// Excape the double quote string:
|
||||||
args += ' ' + Server.config.cargoWatchOptions.checkArguments;
|
args += ' ' + Server.config.cargoWatchOptions.checkArguments;
|
||||||
|
|
|
@ -7,13 +7,15 @@ export class StatusDisplay implements vscode.Disposable {
|
||||||
|
|
||||||
private i = 0;
|
private i = 0;
|
||||||
private statusBarItem: vscode.StatusBarItem;
|
private statusBarItem: vscode.StatusBarItem;
|
||||||
|
private command: string;
|
||||||
private timer?: NodeJS.Timeout;
|
private timer?: NodeJS.Timeout;
|
||||||
|
|
||||||
constructor() {
|
constructor(command: string) {
|
||||||
this.statusBarItem = vscode.window.createStatusBarItem(
|
this.statusBarItem = vscode.window.createStatusBarItem(
|
||||||
vscode.StatusBarAlignment.Left,
|
vscode.StatusBarAlignment.Left,
|
||||||
10
|
10
|
||||||
);
|
);
|
||||||
|
this.command = command;
|
||||||
this.statusBarItem.hide();
|
this.statusBarItem.hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,11 +26,11 @@ export class StatusDisplay implements vscode.Disposable {
|
||||||
this.timer ||
|
this.timer ||
|
||||||
setInterval(() => {
|
setInterval(() => {
|
||||||
if (this.packageName) {
|
if (this.packageName) {
|
||||||
this.statusBarItem!.text = `cargo check [${
|
this.statusBarItem!.text = `cargo ${this.command} [${
|
||||||
this.packageName
|
this.packageName
|
||||||
}] ${this.frame()}`;
|
}] ${this.frame()}`;
|
||||||
} else {
|
} else {
|
||||||
this.statusBarItem!.text = `cargo check ${this.frame()}`;
|
this.statusBarItem!.text = `cargo ${this.command} ${this.frame()}`;
|
||||||
}
|
}
|
||||||
}, 300);
|
}, 300);
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import * as vscode from 'vscode';
|
import * as vscode from 'vscode';
|
||||||
|
|
||||||
import { Server } from './server';
|
import { Server } from './server';
|
||||||
|
import { strict } from 'assert';
|
||||||
|
|
||||||
const RA_LSP_DEBUG = process.env.__RA_LSP_SERVER_DEBUG;
|
const RA_LSP_DEBUG = process.env.__RA_LSP_SERVER_DEBUG;
|
||||||
|
|
||||||
|
@ -10,6 +11,7 @@ export type CargoWatchTraceOptions = 'off' | 'error' | 'verbose';
|
||||||
export interface CargoWatchOptions {
|
export interface CargoWatchOptions {
|
||||||
enableOnStartup: CargoWatchStartupOptions;
|
enableOnStartup: CargoWatchStartupOptions;
|
||||||
checkArguments: string;
|
checkArguments: string;
|
||||||
|
checkCommand: string;
|
||||||
trace: CargoWatchTraceOptions;
|
trace: CargoWatchTraceOptions;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,7 +25,8 @@ export class Config {
|
||||||
public cargoWatchOptions: CargoWatchOptions = {
|
public cargoWatchOptions: CargoWatchOptions = {
|
||||||
enableOnStartup: 'ask',
|
enableOnStartup: 'ask',
|
||||||
trace: 'off',
|
trace: 'off',
|
||||||
checkArguments: ''
|
checkArguments: '',
|
||||||
|
checkCommand: ''
|
||||||
};
|
};
|
||||||
|
|
||||||
private prevEnhancedTyping: null | boolean = null;
|
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')) {
|
if (config.has('lruCapacity')) {
|
||||||
this.lruCapacity = config.get('lruCapacity') as number;
|
this.lruCapacity = config.get('lruCapacity') as number;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue