aboutsummaryrefslogtreecommitdiff
path: root/editors
diff options
context:
space:
mode:
authorEmil Lauridsen <[email protected]>2019-12-25 15:50:38 +0000
committerEmil Lauridsen <[email protected]>2019-12-25 16:37:40 +0000
commit6af4bf7a8d27e653d2e6316172fe140871054d27 (patch)
treeb1a3eed872b7659eb5400e5f2e117a0d008052f9 /editors
parent41a1ec723ce2ea3fa78ae468830f0a77e5658307 (diff)
Configuration plumbing for cargo watcher
Diffstat (limited to 'editors')
-rw-r--r--editors/code/package.json40
-rw-r--r--editors/code/src/config.ts59
-rw-r--r--editors/code/src/server.ts3
3 files changed, 28 insertions, 74 deletions
diff --git a/editors/code/package.json b/editors/code/package.json
index 6cb24a3ce..5f4123397 100644
--- a/editors/code/package.json
+++ b/editors/code/package.json
@@ -188,20 +188,10 @@
188 "default": "ra_lsp_server", 188 "default": "ra_lsp_server",
189 "description": "Path to ra_lsp_server executable" 189 "description": "Path to ra_lsp_server executable"
190 }, 190 },
191 "rust-analyzer.enableCargoWatchOnStartup": { 191 "rust-analyzer.enableCargoCheck": {
192 "type": "string", 192 "type": "boolean",
193 "default": "ask", 193 "default": true,
194 "enum": [ 194 "description": "Run `cargo check` for diagnostics on save"
195 "ask",
196 "enabled",
197 "disabled"
198 ],
199 "enumDescriptions": [
200 "Asks each time whether to run `cargo watch`",
201 "`cargo watch` is always started",
202 "Don't start `cargo watch`"
203 ],
204 "description": "Whether to run `cargo watch` on startup"
205 }, 195 },
206 "rust-analyzer.excludeGlobs": { 196 "rust-analyzer.excludeGlobs": {
207 "type": "array", 197 "type": "array",
@@ -213,25 +203,15 @@
213 "default": true, 203 "default": true,
214 "description": "client provided file watching instead of notify watching." 204 "description": "client provided file watching instead of notify watching."
215 }, 205 },
216 "rust-analyzer.cargo-watch.arguments": { 206 "rust-analyzer.cargo-check.arguments": {
217 "type": "string",
218 "description": "`cargo-watch` arguments. (e.g: `--features=\"shumway,pdf\"` will run as `cargo watch -x \"check --features=\"shumway,pdf\"\"` )",
219 "default": ""
220 },
221 "rust-analyzer.cargo-watch.command": {
222 "type": "string",
223 "description": "`cargo-watch` command. (e.g: `clippy` will run as `cargo watch -x clippy` )",
224 "default": "check"
225 },
226 "rust-analyzer.cargo-watch.ignore": {
227 "type": "array", 207 "type": "array",
228 "description": "A list of patterns for cargo-watch to ignore (will be passed as `--ignore`)", 208 "description": "`cargo-check` arguments. (e.g: `--features=\"shumway,pdf\"` will run as `cargo check --features=\"shumway,pdf\"` )",
229 "default": [] 209 "default": []
230 }, 210 },
231 "rust-analyzer.cargo-watch.allTargets": { 211 "rust-analyzer.cargo-check.command": {
232 "type": "boolean", 212 "type": "string",
233 "description": "Check all targets and tests (will be passed as `--all-targets`)", 213 "description": "`cargo-check` command. (e.g: `clippy` will run as `cargo clippy` )",
234 "default": true 214 "default": "check"
235 }, 215 },
236 "rust-analyzer.trace.server": { 216 "rust-analyzer.trace.server": {
237 "type": "string", 217 "type": "string",
diff --git a/editors/code/src/config.ts b/editors/code/src/config.ts
index e131f09df..96532e2c9 100644
--- a/editors/code/src/config.ts
+++ b/editors/code/src/config.ts
@@ -4,16 +4,10 @@ import { Server } from './server';
4 4
5const RA_LSP_DEBUG = process.env.__RA_LSP_SERVER_DEBUG; 5const RA_LSP_DEBUG = process.env.__RA_LSP_SERVER_DEBUG;
6 6
7export type CargoWatchStartupOptions = 'ask' | 'enabled' | 'disabled'; 7export interface CargoCheckOptions {
8export type CargoWatchTraceOptions = 'off' | 'error' | 'verbose'; 8 enabled: boolean;
9 9 arguments: string[];
10export interface CargoWatchOptions { 10 command: null | string;
11 enableOnStartup: CargoWatchStartupOptions;
12 arguments: string;
13 command: string;
14 trace: CargoWatchTraceOptions;
15 ignore: string[];
16 allTargets: boolean;
17} 11}
18 12
19export interface CargoFeatures { 13export interface CargoFeatures {
@@ -35,13 +29,10 @@ export class Config {
35 public featureFlags = {}; 29 public featureFlags = {};
36 // for internal use 30 // for internal use
37 public withSysroot: null | boolean = null; 31 public withSysroot: null | boolean = null;
38 public cargoWatchOptions: CargoWatchOptions = { 32 public cargoCheckOptions: CargoCheckOptions = {
39 enableOnStartup: 'ask', 33 enabled: true,
40 trace: 'off', 34 arguments: [],
41 arguments: '', 35 command: null,
42 command: '',
43 ignore: [],
44 allTargets: true,
45 }; 36 };
46 public cargoFeatures: CargoFeatures = { 37 public cargoFeatures: CargoFeatures = {
47 noDefaultFeatures: false, 38 noDefaultFeatures: false,
@@ -100,47 +91,27 @@ export class Config {
100 RA_LSP_DEBUG || (config.get('raLspServerPath') as string); 91 RA_LSP_DEBUG || (config.get('raLspServerPath') as string);
101 } 92 }
102 93
103 if (config.has('enableCargoWatchOnStartup')) { 94 if (config.has('enableCargoCheck')) {
104 this.cargoWatchOptions.enableOnStartup = config.get< 95 this.cargoCheckOptions.enabled = config.get<boolean>(
105 CargoWatchStartupOptions 96 'enableCargoCheck',
106 >('enableCargoWatchOnStartup', 'ask'); 97 true,
107 }
108
109 if (config.has('trace.cargo-watch')) {
110 this.cargoWatchOptions.trace = config.get<CargoWatchTraceOptions>(
111 'trace.cargo-watch',
112 'off',
113 ); 98 );
114 } 99 }
115 100
116 if (config.has('cargo-watch.arguments')) { 101 if (config.has('cargo-watch.arguments')) {
117 this.cargoWatchOptions.arguments = config.get<string>( 102 this.cargoCheckOptions.arguments = config.get<string[]>(
118 'cargo-watch.arguments', 103 'cargo-watch.arguments',
119 '', 104 [],
120 ); 105 );
121 } 106 }
122 107
123 if (config.has('cargo-watch.command')) { 108 if (config.has('cargo-watch.command')) {
124 this.cargoWatchOptions.command = config.get<string>( 109 this.cargoCheckOptions.command = config.get<string>(
125 'cargo-watch.command', 110 'cargo-watch.command',
126 '', 111 '',
127 ); 112 );
128 } 113 }
129 114
130 if (config.has('cargo-watch.ignore')) {
131 this.cargoWatchOptions.ignore = config.get<string[]>(
132 'cargo-watch.ignore',
133 [],
134 );
135 }
136
137 if (config.has('cargo-watch.allTargets')) {
138 this.cargoWatchOptions.allTargets = config.get<boolean>(
139 'cargo-watch.allTargets',
140 true,
141 );
142 }
143
144 if (config.has('lruCapacity')) { 115 if (config.has('lruCapacity')) {
145 this.lruCapacity = config.get('lruCapacity') as number; 116 this.lruCapacity = config.get('lruCapacity') as number;
146 } 117 }
diff --git a/editors/code/src/server.ts b/editors/code/src/server.ts
index 5ace1d0fa..409d3b4b7 100644
--- a/editors/code/src/server.ts
+++ b/editors/code/src/server.ts
@@ -55,6 +55,9 @@ export class Server {
55 publishDecorations: true, 55 publishDecorations: true,
56 lruCapacity: Server.config.lruCapacity, 56 lruCapacity: Server.config.lruCapacity,
57 maxInlayHintLength: Server.config.maxInlayHintLength, 57 maxInlayHintLength: Server.config.maxInlayHintLength,
58 cargoCheckEnable: Server.config.cargoCheckOptions.enabled,
59 cargoCheckCommand: Server.config.cargoCheckOptions.command,
60 cargoCheckArgs: Server.config.cargoCheckOptions.arguments,
58 excludeGlobs: Server.config.excludeGlobs, 61 excludeGlobs: Server.config.excludeGlobs,
59 useClientWatching: Server.config.useClientWatching, 62 useClientWatching: Server.config.useClientWatching,
60 featureFlags: Server.config.featureFlags, 63 featureFlags: Server.config.featureFlags,