Add option to disable all-targets.

Can be useful in embedded.
This commit is contained in:
Vadzim Dambrouski 2019-12-15 23:02:13 +05:30
parent 4e24b25c66
commit a85cd6455a
3 changed files with 18 additions and 1 deletions

View File

@ -237,6 +237,11 @@
"description": "A list of patterns for cargo-watch to ignore (will be passed as `--ignore`)", "description": "A list of patterns for cargo-watch to ignore (will be passed as `--ignore`)",
"default": [] "default": []
}, },
"rust-analyzer.cargo-watch.allTargets": {
"type": "boolean",
"description": "Check all targets and tests (will be passed as `--all-targets`)",
"default": true
},
"rust-analyzer.trace.server": { "rust-analyzer.trace.server": {
"type": "string", "type": "string",
"scope": "window", "scope": "window",

View File

@ -83,7 +83,10 @@ export class CargoWatchProvider implements vscode.Disposable {
let args = let args =
Server.config.cargoWatchOptions.command + Server.config.cargoWatchOptions.command +
' --all-targets --message-format json'; ' --message-format json';
if (Server.config.cargoWatchOptions.allTargets) {
args += ' --all-targets';
}
if (Server.config.cargoWatchOptions.command.length > 0) { if (Server.config.cargoWatchOptions.command.length > 0) {
// Excape the double quote string: // Excape the double quote string:
args += ' ' + Server.config.cargoWatchOptions.arguments; args += ' ' + Server.config.cargoWatchOptions.arguments;

View File

@ -13,6 +13,7 @@ export interface CargoWatchOptions {
command: string; command: string;
trace: CargoWatchTraceOptions; trace: CargoWatchTraceOptions;
ignore: string[]; ignore: string[];
allTargets: boolean;
} }
export interface CargoFeatures { export interface CargoFeatures {
@ -40,6 +41,7 @@ export class Config {
arguments: '', arguments: '',
command: '', command: '',
ignore: [], ignore: [],
allTargets: true,
}; };
public cargoFeatures: CargoFeatures = { public cargoFeatures: CargoFeatures = {
noDefaultFeatures: false, noDefaultFeatures: false,
@ -132,6 +134,13 @@ export class Config {
); );
} }
if (config.has('cargo-watch.allTargets')) {
this.cargoWatchOptions.allTargets = config.get<boolean>(
'cargo-watch.allTargets',
true,
);
}
if (config.has('lruCapacity')) { if (config.has('lruCapacity')) {
this.lruCapacity = config.get('lruCapacity') as number; this.lruCapacity = config.get('lruCapacity') as number;
} }