From 0cdbd0814958e174c5481d6bf16bd2a7e53ec981 Mon Sep 17 00:00:00 2001 From: Emil Lauridsen Date: Wed, 25 Dec 2019 20:23:44 +0100 Subject: Keep VSCode config mostly backwards compatible --- editors/code/package.json | 34 ++++++++++++++-------------------- editors/code/src/config.ts | 31 ++++++++++++++++++++----------- editors/code/src/extension.ts | 2 +- editors/code/src/server.ts | 8 +++++--- 4 files changed, 40 insertions(+), 35 deletions(-) (limited to 'editors') diff --git a/editors/code/package.json b/editors/code/package.json index 5f4123397..69298e917 100644 --- a/editors/code/package.json +++ b/editors/code/package.json @@ -188,11 +188,6 @@ "default": "ra_lsp_server", "description": "Path to ra_lsp_server executable" }, - "rust-analyzer.enableCargoCheck": { - "type": "boolean", - "default": true, - "description": "Run `cargo check` for diagnostics on save" - }, "rust-analyzer.excludeGlobs": { "type": "array", "default": [], @@ -203,16 +198,26 @@ "default": true, "description": "client provided file watching instead of notify watching." }, - "rust-analyzer.cargo-check.arguments": { + "rust-analyzer.cargo-watch.enable": { + "type": "boolean", + "default": true, + "description": "Run `cargo check` for diagnostics on save" + }, + "rust-analyzer.cargo-watch.arguments": { "type": "array", - "description": "`cargo-check` arguments. (e.g: `--features=\"shumway,pdf\"` will run as `cargo 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-check.command": { + "rust-analyzer.cargo-watch.command": { "type": "string", - "description": "`cargo-check` command. (e.g: `clippy` will run as `cargo clippy` )", + "description": "`cargo-watch` command. (e.g: `clippy` will run as `cargo watch -x clippy` )", "default": "check" }, + "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": { "type": "string", "scope": "window", @@ -229,17 +234,6 @@ "default": "off", "description": "Trace requests to the ra_lsp_server" }, - "rust-analyzer.trace.cargo-watch": { - "type": "string", - "scope": "window", - "enum": [ - "off", - "error", - "verbose" - ], - "default": "off", - "description": "Trace output of cargo-watch" - }, "rust-analyzer.lruCapacity": { "type": "number", "default": null, diff --git a/editors/code/src/config.ts b/editors/code/src/config.ts index 96532e2c9..4b388b80c 100644 --- a/editors/code/src/config.ts +++ b/editors/code/src/config.ts @@ -4,10 +4,11 @@ import { Server } from './server'; const RA_LSP_DEBUG = process.env.__RA_LSP_SERVER_DEBUG; -export interface CargoCheckOptions { - enabled: boolean; +export interface CargoWatchOptions { + enable: boolean; arguments: string[]; - command: null | string; + command: string; + allTargets: boolean; } export interface CargoFeatures { @@ -29,10 +30,11 @@ export class Config { public featureFlags = {}; // for internal use public withSysroot: null | boolean = null; - public cargoCheckOptions: CargoCheckOptions = { - enabled: true, + public cargoWatchOptions: CargoWatchOptions = { + enable: true, arguments: [], - command: null, + command: '', + allTargets: true, }; public cargoFeatures: CargoFeatures = { noDefaultFeatures: false, @@ -91,27 +93,34 @@ export class Config { RA_LSP_DEBUG || (config.get('raLspServerPath') as string); } - if (config.has('enableCargoCheck')) { - this.cargoCheckOptions.enabled = config.get( - 'enableCargoCheck', + if (config.has('cargo-watch.enable')) { + this.cargoWatchOptions.enable = config.get( + 'cargo-watch.enable', true, ); } if (config.has('cargo-watch.arguments')) { - this.cargoCheckOptions.arguments = config.get( + this.cargoWatchOptions.arguments = config.get( 'cargo-watch.arguments', [], ); } if (config.has('cargo-watch.command')) { - this.cargoCheckOptions.command = config.get( + this.cargoWatchOptions.command = config.get( 'cargo-watch.command', '', ); } + if (config.has('cargo-watch.allTargets')) { + this.cargoWatchOptions.allTargets = config.get( + 'cargo-watch.allTargets', + true, + ); + } + if (config.has('lruCapacity')) { this.lruCapacity = config.get('lruCapacity') as number; } diff --git a/editors/code/src/extension.ts b/editors/code/src/extension.ts index 36163b6bb..1da10ebd0 100644 --- a/editors/code/src/extension.ts +++ b/editors/code/src/extension.ts @@ -85,7 +85,7 @@ export async function activate(context: vscode.ExtensionContext) { } const watchStatus = new StatusDisplay( - Server.config.cargoCheckOptions.command || 'check', + Server.config.cargoWatchOptions.command, ); disposeOnDeactivation(watchStatus); diff --git a/editors/code/src/server.ts b/editors/code/src/server.ts index 409d3b4b7..ae81af848 100644 --- a/editors/code/src/server.ts +++ b/editors/code/src/server.ts @@ -55,9 +55,11 @@ export class Server { publishDecorations: true, lruCapacity: Server.config.lruCapacity, maxInlayHintLength: Server.config.maxInlayHintLength, - cargoCheckEnable: Server.config.cargoCheckOptions.enabled, - cargoCheckCommand: Server.config.cargoCheckOptions.command, - cargoCheckArgs: Server.config.cargoCheckOptions.arguments, + cargoWatchEnable: Server.config.cargoWatchOptions.enable, + cargoWatchArgumets: Server.config.cargoWatchOptions.arguments, + cargoWatchCommand: Server.config.cargoWatchOptions.command, + cargoWatchAllTargets: + Server.config.cargoWatchOptions.allTargets, excludeGlobs: Server.config.excludeGlobs, useClientWatching: Server.config.useClientWatching, featureFlags: Server.config.featureFlags, -- cgit v1.2.3