aboutsummaryrefslogtreecommitdiff
path: root/editors
diff options
context:
space:
mode:
Diffstat (limited to 'editors')
-rw-r--r--editors/code/package.json15
-rw-r--r--editors/code/src/config.ts77
-rw-r--r--editors/code/src/server.ts1
3 files changed, 80 insertions, 13 deletions
diff --git a/editors/code/package.json b/editors/code/package.json
index 68b3b6e05..43db61a8b 100644
--- a/editors/code/package.json
+++ b/editors/code/package.json
@@ -278,6 +278,21 @@
278 "type": "number", 278 "type": "number",
279 "default": 20, 279 "default": 20,
280 "description": "Maximum length for inlay hints" 280 "description": "Maximum length for inlay hints"
281 },
282 "rust-analyzer.cargoFeatures.noDefaultFeatures": {
283 "type": "boolean",
284 "default": false,
285 "description": "Do not activate the `default` feature"
286 },
287 "rust-analyzer.cargoFeatures.allFeatures": {
288 "type": "boolean",
289 "default": true,
290 "description": "Activate all available features"
291 },
292 "rust-analyzer.cargoFeatures.features": {
293 "type": "array",
294 "default": [],
295 "description": "List of features to activate"
281 } 296 }
282 } 297 }
283 }, 298 },
diff --git a/editors/code/src/config.ts b/editors/code/src/config.ts
index 2d3b6a54e..defdfeb9c 100644
--- a/editors/code/src/config.ts
+++ b/editors/code/src/config.ts
@@ -15,6 +15,12 @@ export interface CargoWatchOptions {
15 ignore: string[]; 15 ignore: string[];
16} 16}
17 17
18export interface CargoFeatures {
19 noDefaultFeatures: boolean;
20 allFeatures: boolean;
21 features: string[];
22}
23
18export class Config { 24export class Config {
19 public highlightingOn = true; 25 public highlightingOn = true;
20 public rainbowHighlightingOn = false; 26 public rainbowHighlightingOn = false;
@@ -35,8 +41,14 @@ export class Config {
35 command: '', 41 command: '',
36 ignore: [], 42 ignore: [],
37 }; 43 };
44 public cargoFeatures: CargoFeatures = {
45 noDefaultFeatures: false,
46 allFeatures: true,
47 features: [],
48 };
38 49
39 private prevEnhancedTyping: null | boolean = null; 50 private prevEnhancedTyping: null | boolean = null;
51 private prevCargoFeatures: null | CargoFeatures = null;
40 52
41 constructor() { 53 constructor() {
42 vscode.workspace.onDidChangeConfiguration(_ => 54 vscode.workspace.onDidChangeConfiguration(_ =>
@@ -47,6 +59,8 @@ export class Config {
47 59
48 public userConfigChanged() { 60 public userConfigChanged() {
49 const config = vscode.workspace.getConfiguration('rust-analyzer'); 61 const config = vscode.workspace.getConfiguration('rust-analyzer');
62 let requireReloadMessage = null;
63
50 if (config.has('highlightingOn')) { 64 if (config.has('highlightingOn')) {
51 this.highlightingOn = config.get('highlightingOn') as boolean; 65 this.highlightingOn = config.get('highlightingOn') as boolean;
52 } 66 }
@@ -74,19 +88,8 @@ export class Config {
74 } 88 }
75 89
76 if (this.prevEnhancedTyping !== this.enableEnhancedTyping) { 90 if (this.prevEnhancedTyping !== this.enableEnhancedTyping) {
77 const reloadAction = 'Reload now'; 91 requireReloadMessage =
78 vscode.window 92 'Changing enhanced typing setting requires a reload';
79 .showInformationMessage(
80 'Changing enhanced typing setting requires a reload',
81 reloadAction,
82 )
83 .then(selectedAction => {
84 if (selectedAction === reloadAction) {
85 vscode.commands.executeCommand(
86 'workbench.action.reloadWindow',
87 );
88 }
89 });
90 this.prevEnhancedTyping = this.enableEnhancedTyping; 93 this.prevEnhancedTyping = this.enableEnhancedTyping;
91 } 94 }
92 95
@@ -153,5 +156,53 @@ export class Config {
153 if (config.has('withSysroot')) { 156 if (config.has('withSysroot')) {
154 this.withSysroot = config.get('withSysroot') || false; 157 this.withSysroot = config.get('withSysroot') || false;
155 } 158 }
159
160 if (config.has('cargoFeatures.noDefaultFeatures')) {
161 this.cargoFeatures.noDefaultFeatures = config.get(
162 'cargoFeatures.noDefaultFeatures',
163 false,
164 );
165 }
166 if (config.has('cargoFeatures.allFeatures')) {
167 this.cargoFeatures.allFeatures = config.get(
168 'cargoFeatures.allFeatures',
169 true,
170 );
171 }
172 if (config.has('cargoFeatures.features')) {
173 this.cargoFeatures.features = config.get(
174 'cargoFeatures.features',
175 [],
176 );
177 }
178
179 if (
180 this.prevCargoFeatures !== null &&
181 (this.cargoFeatures.allFeatures !==
182 this.prevCargoFeatures.allFeatures ||
183 this.cargoFeatures.noDefaultFeatures !==
184 this.prevCargoFeatures.noDefaultFeatures ||
185 this.cargoFeatures.features.length !==
186 this.prevCargoFeatures.features.length ||
187 this.cargoFeatures.features.some(
188 (v, i) => v !== this.prevCargoFeatures!.features[i],
189 ))
190 ) {
191 requireReloadMessage = 'Changing cargo features requires a reload';
192 }
193 this.prevCargoFeatures = { ...this.cargoFeatures };
194
195 if (requireReloadMessage !== null) {
196 const reloadAction = 'Reload now';
197 vscode.window
198 .showInformationMessage(requireReloadMessage, reloadAction)
199 .then(selectedAction => {
200 if (selectedAction === reloadAction) {
201 vscode.commands.executeCommand(
202 'workbench.action.reloadWindow',
203 );
204 }
205 });
206 }
156 } 207 }
157} 208}
diff --git a/editors/code/src/server.ts b/editors/code/src/server.ts
index 2fe45f1ed..5ace1d0fa 100644
--- a/editors/code/src/server.ts
+++ b/editors/code/src/server.ts
@@ -59,6 +59,7 @@ export class Server {
59 useClientWatching: Server.config.useClientWatching, 59 useClientWatching: Server.config.useClientWatching,
60 featureFlags: Server.config.featureFlags, 60 featureFlags: Server.config.featureFlags,
61 withSysroot: Server.config.withSysroot, 61 withSysroot: Server.config.withSysroot,
62 cargoFeatures: Server.config.cargoFeatures,
62 }, 63 },
63 traceOutputChannel, 64 traceOutputChannel,
64 }; 65 };