aboutsummaryrefslogtreecommitdiff
path: root/editors/code
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2020-04-02 13:05:46 +0100
committerGitHub <[email protected]>2020-04-02 13:05:46 +0100
commit3c9e9d3f3ebbc7a22d932dd2a3fd63f1e44c4568 (patch)
tree0dbb6b8c37601a7d0c617a1d88a342b8f4c97a32 /editors/code
parent9ee96dcf4a2b47a6df0e3ea379d36aec2e6e1784 (diff)
parent7a4ebd2c8dfee8ca15dab7ba053a6521840aa5e3 (diff)
Merge #3824
3824: New config names r=matklad a=matklad bors r+ ЁЯдЦ Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'editors/code')
-rw-r--r--editors/code/package.json239
-rw-r--r--editors/code/src/client.ts26
-rw-r--r--editors/code/src/commands/runnables.ts4
-rw-r--r--editors/code/src/config.ts30
-rw-r--r--editors/code/src/ctx.ts3
-rw-r--r--editors/code/src/status_display.ts2
6 files changed, 131 insertions, 173 deletions
diff --git a/editors/code/package.json b/editors/code/package.json
index 946145df8..1f95cd130 100644
--- a/editors/code/package.json
+++ b/editors/code/package.json
@@ -177,81 +177,70 @@
177 "type": "object", 177 "type": "object",
178 "title": "Rust Analyzer", 178 "title": "Rust Analyzer",
179 "properties": { 179 "properties": {
180 "rust-analyzer.highlighting.semanticTokens": { 180 "rust-analyzer.diagnostics.enable": {
181 "type": "boolean", 181 "type": "boolean",
182 "default": false, 182 "default": true,
183 "description": "Use proposed semantic tokens API for syntax highlighting" 183 "markdownDescription": "Whether to show native rust-analyzer diagnostics."
184 }, 184 },
185 "rust-analyzer.featureFlags": { 185 "rust-analyzer.lruCapacity": {
186 "type": "object", 186 "type": [
187 "default": {}, 187 "null",
188 "description": "Fine grained feature flags to disable annoying features", 188 "integer"
189 "properties": { 189 ],
190 "lsp.diagnostics": { 190 "default": null,
191 "type": "boolean", 191 "minimum": 0,
192 "markdownDescription": "Whether to show diagnostics from `cargo check`" 192 "exclusiveMinimum": true,
193 }, 193 "description": "Number of syntax trees rust-analyzer keeps in memory."
194 "completion.insertion.add-call-parenthesis": {
195 "type": "boolean",
196 "description": "Whether to add parenthesis when completing functions"
197 },
198 "completion.insertion.add-argument-snippets": {
199 "type": "boolean",
200 "description": "Whether to add argument snippets when completing functions"
201 },
202 "completion.enable-postfix": {
203 "type": "boolean",
204 "markdownDescription": "Whether to show postfix snippets like `dbg`, `if`, `not`, etc."
205 },
206 "call-info.full": {
207 "type": "boolean",
208 "description": "Show function name and docs in parameter hints"
209 },
210 "notifications.workspace-loaded": {
211 "type": "boolean",
212 "markdownDescription": "Whether to show `workspace loaded` message"
213 },
214 "notifications.cargo-toml-not-found": {
215 "type": "boolean",
216 "markdownDescription": "Whether to show `can't find Cargo.toml` error message"
217 }
218 }
219 }, 194 },
220 "rust-analyzer.updates.channel": { 195 "rust-analyzer.files.watcher": {
221 "type": "string", 196 "type": "string",
222 "enum": [ 197 "enum": [
223 "stable", 198 "client",
224 "nightly" 199 "notify"
225 ],
226 "default": "stable",
227 "markdownEnumDescriptions": [
228 "`\"stable\"` updates are shipped weekly, they don't contain cutting-edge features from VSCode proposed APIs but have less bugs in general",
229 "`\"nightly\"` updates are shipped daily (extension updates automatically by downloading artifacts directly from GitHub), they contain cutting-edge features and latest bug fixes. These releases help us get your feedback very quickly and speed up rust-analyzer development **drastically**"
230 ], 200 ],
231 "markdownDescription": "Choose `\"nightly\"` updates to get the latest features and bug fixes every day. While `\"stable\"` releases occur weekly and don't contain cutting-edge features from VSCode proposed APIs" 201 "default": "client",
202 "description": "Controls file watching implementation."
232 }, 203 },
233 "rust-analyzer.updates.askBeforeDownload": { 204 "rust-analyzer.files.exclude": {
205 "type": "array",
206 "items": {
207 "type": "string"
208 },
209 "default": [],
210 "description": "Paths to exclude from analysis."
211 },
212 "rust-analyzer.notifications.workspaceLoaded": {
234 "type": "boolean", 213 "type": "boolean",
235 "default": true, 214 "markdownDescription": "Whether to show `workspace loaded` message."
236 "description": "Whether to ask for permission before downloading any files from the Internet"
237 }, 215 },
238 "rust-analyzer.serverPath": { 216 "rust-analyzer.notifications.cargoTomlNotFound": {
239 "type": [ 217 "type": "boolean",
240 "null", 218 "markdownDescription": "Whether to show `can't find Cargo.toml` error message"
241 "string" 219 },
242 ], 220 "rust-analyzer.cargo.noDefaultFeatures": {
243 "default": null, 221 "type": "boolean",
244 "description": "Path to rust-analyzer executable (points to bundled binary by default). If this is set, then \"rust-analyzer.updates.channel\" setting is not used" 222 "default": false,
223 "markdownDescription": "Do not activate the `default` feature"
224 },
225 "rust-analyzer.cargo.allFeatures": {
226 "type": "boolean",
227 "default": true,
228 "description": "Activate all available features"
245 }, 229 },
246 "rust-analyzer.excludeGlobs": { 230 "rust-analyzer.cargo.features": {
247 "type": "array", 231 "type": "array",
248 "items": { 232 "items": {
249 "type": "string" 233 "type": "string"
250 }, 234 },
251 "default": [], 235 "default": [],
252 "description": "Paths to exclude from analysis" 236 "description": "List of features to activate"
237 },
238 "rust-analyzer.cargo.loadOutDirsFromCheck": {
239 "type": "boolean",
240 "default": false,
241 "markdownDescription": "Run `cargo check` on startup to get the correct value for package OUT_DIRs"
253 }, 242 },
254 "rust-analyzer.rustfmtArgs": { 243 "rust-analyzer.rustfmt.extraArgs": {
255 "type": "array", 244 "type": "array",
256 "items": { 245 "items": {
257 "type": "string" 246 "type": "string"
@@ -259,64 +248,28 @@
259 "default": [], 248 "default": [],
260 "description": "Additional arguments to rustfmt" 249 "description": "Additional arguments to rustfmt"
261 }, 250 },
262 "rust-analyzer.useClientWatching": { 251 "rust-analyzer.checkOnSave.enable": {
263 "type": "boolean", 252 "type": "boolean",
264 "default": true, 253 "default": true,
265 "description": "client provided file watching instead of notify watching." 254 "markdownDescription": "Run specified `cargo check` command for diagnostics on save"
266 }, 255 },
267 "rust-analyzer.cargo-watch.enable": { 256 "rust-analyzer.checkOnSave.extraArgs": {
268 "type": "boolean",
269 "default": true,
270 "markdownDescription": "Run specified `cargo-watch` command for diagnostics on save"
271 },
272 "rust-analyzer.cargo-watch.arguments": {
273 "type": "array", 257 "type": "array",
274 "items": { 258 "items": {
275 "type": "string" 259 "type": "string"
276 }, 260 },
277 "markdownDescription": "`cargo-watch` arguments. (e.g: `--features=\"shumway,pdf\"` will run as `cargo watch -x \"check --features=\"shumway,pdf\"\"` )", 261 "markdownDescription": "Extra arguments for `cargo check`",
278 "default": [] 262 "default": []
279 }, 263 },
280 "rust-analyzer.cargo-watch.command": { 264 "rust-analyzer.checkOnSave.command": {
281 "type": "string",
282 "markdownDescription": "`cargo-watch` command. (e.g: `clippy` will run as `cargo watch -x clippy` )",
283 "default": "check"
284 },
285 "rust-analyzer.cargo-watch.allTargets": {
286 "type": "boolean",
287 "markdownDescription": "Check all targets and tests (will be passed as `--all-targets`)",
288 "default": true
289 },
290 "rust-analyzer.trace.server": {
291 "type": "string", 265 "type": "string",
292 "scope": "window", 266 "default": "check",
293 "enum": [ 267 "markdownDescription": "Cargo command to use for `cargo check`"
294 "off",
295 "messages",
296 "verbose"
297 ],
298 "enumDescriptions": [
299 "No traces",
300 "Error only",
301 "Full log"
302 ],
303 "default": "off",
304 "description": "Trace requests to the rust-analyzer"
305 }, 268 },
306 "rust-analyzer.trace.extension": { 269 "rust-analyzer.checkOnSave.allTargets": {
307 "description": "Enable logging of VS Code extensions itself",
308 "type": "boolean", 270 "type": "boolean",
309 "default": false 271 "default": true,
310 }, 272 "markdownDescription": "Check all targets and tests (will be passed as `--all-targets`)"
311 "rust-analyzer.lruCapacity": {
312 "type": [
313 "null",
314 "integer"
315 ],
316 "default": null,
317 "minimum": 0,
318 "exclusiveMinimum": true,
319 "description": "Number of syntax trees rust-analyzer keeps in memory"
320 }, 273 },
321 "rust-analyzer.inlayHints.typeHints": { 274 "rust-analyzer.inlayHints.typeHints": {
322 "type": "boolean", 275 "type": "boolean",
@@ -343,28 +296,76 @@
343 "exclusiveMinimum": true, 296 "exclusiveMinimum": true,
344 "description": "Maximum length for inlay hints" 297 "description": "Maximum length for inlay hints"
345 }, 298 },
346 "rust-analyzer.cargoFeatures.noDefaultFeatures": { 299 "rust-analyzer.completion.addCallParenthesis": {
347 "type": "boolean", 300 "type": "boolean",
348 "default": false, 301 "default": true,
349 "markdownDescription": "Do not activate the `default` feature" 302 "description": "Whether to add parenthesis when completing functions"
350 }, 303 },
351 "rust-analyzer.cargoFeatures.allFeatures": { 304 "rust-analyzer.completion.addCallArgumentSnippets": {
352 "type": "boolean", 305 "type": "boolean",
353 "default": true, 306 "default": true,
354 "description": "Activate all available features" 307 "description": "Whether to add argument snippets when completing functions"
355 }, 308 },
356 "rust-analyzer.cargoFeatures.features": { 309 "rust-analyzer.completion.postfix.enable": {
357 "type": "array", 310 "type": "boolean",
358 "items": { 311 "default": true,
359 "type": "string" 312 "markdownDescription": "Whether to show postfix snippets like `dbg`, `if`, `not`, etc."
360 }, 313 },
361 "default": [], 314 "rust-analyzer.callInfo.full": {
362 "description": "List of features to activate" 315 "type": "boolean",
316 "description": "Show function name and docs in parameter hints"
363 }, 317 },
364 "rust-analyzer.cargoFeatures.loadOutDirsFromCheck": { 318 "rust-analyzer.highlighting.semanticTokens": {
365 "type": "boolean", 319 "type": "boolean",
366 "default": false, 320 "default": false,
367 "markdownDescription": "Run `cargo check` on startup to get the correct value for package OUT_DIRs" 321 "description": "Use proposed semantic tokens API for syntax highlighting"
322 },
323 "rust-analyzer.updates.channel": {
324 "type": "string",
325 "enum": [
326 "stable",
327 "nightly"
328 ],
329 "default": "stable",
330 "markdownEnumDescriptions": [
331 "`\"stable\"` updates are shipped weekly, they don't contain cutting-edge features from VSCode proposed APIs but have less bugs in general",
332 "`\"nightly\"` updates are shipped daily (extension updates automatically by downloading artifacts directly from GitHub), they contain cutting-edge features and latest bug fixes. These releases help us get your feedback very quickly and speed up rust-analyzer development **drastically**"
333 ],
334 "markdownDescription": "Choose `\"nightly\"` updates to get the latest features and bug fixes every day. While `\"stable\"` releases occur weekly and don't contain cutting-edge features from VSCode proposed APIs"
335 },
336 "rust-analyzer.updates.askBeforeDownload": {
337 "type": "boolean",
338 "default": true,
339 "description": "Whether to ask for permission before downloading any files from the Internet"
340 },
341 "rust-analyzer.serverPath": {
342 "type": [
343 "null",
344 "string"
345 ],
346 "default": null,
347 "description": "Path to rust-analyzer executable (points to bundled binary by default). If this is set, then \"rust-analyzer.updates.channel\" setting is not used"
348 },
349 "rust-analyzer.trace.server": {
350 "type": "string",
351 "scope": "window",
352 "enum": [
353 "off",
354 "messages",
355 "verbose"
356 ],
357 "enumDescriptions": [
358 "No traces",
359 "Error only",
360 "Full log"
361 ],
362 "default": "off",
363 "description": "Trace requests to the rust-analyzer"
364 },
365 "rust-analyzer.trace.extension": {
366 "description": "Enable logging of VS Code extensions itself",
367 "type": "boolean",
368 "default": false
368 } 369 }
369 } 370 }
370 }, 371 },
diff --git a/editors/code/src/client.ts b/editors/code/src/client.ts
index 8ddc1cdca..3b1d00bca 100644
--- a/editors/code/src/client.ts
+++ b/editors/code/src/client.ts
@@ -5,30 +5,6 @@ import { Config } from './config';
5import { CallHierarchyFeature } from 'vscode-languageclient/lib/callHierarchy.proposed'; 5import { CallHierarchyFeature } from 'vscode-languageclient/lib/callHierarchy.proposed';
6import { SemanticTokensFeature, DocumentSemanticsTokensSignature } from 'vscode-languageclient/lib/semanticTokens.proposed'; 6import { SemanticTokensFeature, DocumentSemanticsTokensSignature } from 'vscode-languageclient/lib/semanticTokens.proposed';
7 7
8export function configToServerOptions(config: Config) {
9 return {
10 lruCapacity: config.lruCapacity,
11
12 inlayHintsType: config.inlayHints.typeHints,
13 inlayHintsParameter: config.inlayHints.parameterHints,
14 inlayHintsChaining: config.inlayHints.chainingHints,
15 inlayHintsMaxLength: config.inlayHints.maxLength,
16
17 cargoWatchEnable: config.cargoWatchOptions.enable,
18 cargoWatchArgs: config.cargoWatchOptions.arguments,
19 cargoWatchCommand: config.cargoWatchOptions.command,
20 cargoWatchAllTargets: config.cargoWatchOptions.allTargets,
21
22 excludeGlobs: config.excludeGlobs,
23 useClientWatching: config.useClientWatching,
24 featureFlags: config.featureFlags,
25 withSysroot: config.withSysroot,
26 cargoFeatures: config.cargoFeatures,
27 rustfmtArgs: config.rustfmtArgs,
28 vscodeLldb: vscode.extensions.getExtension("vadimcn.vscode-lldb") != null,
29 };
30}
31
32export async function createClient(config: Config, serverPath: string, cwd: string): Promise<lc.LanguageClient> { 8export async function createClient(config: Config, serverPath: string, cwd: string): Promise<lc.LanguageClient> {
33 // '.' Is the fallback if no folder is open 9 // '.' Is the fallback if no folder is open
34 // TODO?: Workspace folders support Uri's (eg: file://test.txt). 10 // TODO?: Workspace folders support Uri's (eg: file://test.txt).
@@ -48,7 +24,7 @@ export async function createClient(config: Config, serverPath: string, cwd: stri
48 24
49 const clientOptions: lc.LanguageClientOptions = { 25 const clientOptions: lc.LanguageClientOptions = {
50 documentSelector: [{ scheme: 'file', language: 'rust' }], 26 documentSelector: [{ scheme: 'file', language: 'rust' }],
51 initializationOptions: configToServerOptions(config), 27 initializationOptions: vscode.workspace.getConfiguration("rust-analyzer"),
52 traceOutputChannel, 28 traceOutputChannel,
53 middleware: { 29 middleware: {
54 // Workaround for https://github.com/microsoft/vscode-languageserver-node/issues/576 30 // Workaround for https://github.com/microsoft/vscode-languageserver-node/issues/576
diff --git a/editors/code/src/commands/runnables.ts b/editors/code/src/commands/runnables.ts
index 357155163..2635a1440 100644
--- a/editors/code/src/commands/runnables.ts
+++ b/editors/code/src/commands/runnables.ts
@@ -66,6 +66,10 @@ export function debugSingle(ctx: Ctx): Cmd {
66 return async (config: ra.Runnable) => { 66 return async (config: ra.Runnable) => {
67 const editor = ctx.activeRustEditor; 67 const editor = ctx.activeRustEditor;
68 if (!editor) return; 68 if (!editor) return;
69 if (!vscode.extensions.getExtension("vadimcn.vscode-lldb")) {
70 vscode.window.showErrorMessage("Install `vadimcn.vscode-lldb` extension for debugging");
71 return;
72 }
69 73
70 const debugConfig = { 74 const debugConfig = {
71 type: "lldb", 75 type: "lldb",
diff --git a/editors/code/src/config.ts b/editors/code/src/config.ts
index c37c6276b..1f45f1de0 100644
--- a/editors/code/src/config.ts
+++ b/editors/code/src/config.ts
@@ -11,9 +11,8 @@ export class Config {
11 private readonly rootSection = "rust-analyzer"; 11 private readonly rootSection = "rust-analyzer";
12 private readonly requiresReloadOpts = [ 12 private readonly requiresReloadOpts = [
13 "serverPath", 13 "serverPath",
14 "cargoFeatures", 14 "cargo",
15 "excludeGlobs", 15 "files",
16 "useClientWatching",
17 "highlighting", 16 "highlighting",
18 "updates.channel", 17 "updates.channel",
19 ] 18 ]
@@ -71,17 +70,8 @@ export class Config {
71 get channel() { return this.cfg.get<UpdatesChannel>("updates.channel")!; } 70 get channel() { return this.cfg.get<UpdatesChannel>("updates.channel")!; }
72 get askBeforeDownload() { return this.cfg.get<boolean>("updates.askBeforeDownload")!; } 71 get askBeforeDownload() { return this.cfg.get<boolean>("updates.askBeforeDownload")!; }
73 get highlightingSemanticTokens() { return this.cfg.get<boolean>("highlighting.semanticTokens")!; } 72 get highlightingSemanticTokens() { return this.cfg.get<boolean>("highlighting.semanticTokens")!; }
74 get lruCapacity() { return this.cfg.get<null | number>("lruCapacity")!; }
75 get excludeGlobs() { return this.cfg.get<string[]>("excludeGlobs")!; }
76 get useClientWatching() { return this.cfg.get<boolean>("useClientWatching")!; }
77 get featureFlags() { return this.cfg.get<Record<string, boolean>>("featureFlags")!; }
78 get rustfmtArgs() { return this.cfg.get<string[]>("rustfmtArgs")!; }
79 get loadOutDirsFromCheck() { return this.cfg.get<boolean>("loadOutDirsFromCheck")!; }
80 get traceExtension() { return this.cfg.get<boolean>("trace.extension")!; } 73 get traceExtension() { return this.cfg.get<boolean>("trace.extension")!; }
81 74
82 // for internal use
83 get withSysroot() { return this.cfg.get<boolean>("withSysroot", true)!; }
84
85 get inlayHints() { 75 get inlayHints() {
86 return { 76 return {
87 typeHints: this.cfg.get<boolean>("inlayHints.typeHints")!, 77 typeHints: this.cfg.get<boolean>("inlayHints.typeHints")!,
@@ -91,21 +81,9 @@ export class Config {
91 }; 81 };
92 } 82 }
93 83
94 get cargoWatchOptions() { 84 get checkOnSave() {
95 return {
96 enable: this.cfg.get<boolean>("cargo-watch.enable")!,
97 arguments: this.cfg.get<string[]>("cargo-watch.arguments")!,
98 allTargets: this.cfg.get<boolean>("cargo-watch.allTargets")!,
99 command: this.cfg.get<string>("cargo-watch.command")!,
100 };
101 }
102
103 get cargoFeatures() {
104 return { 85 return {
105 noDefaultFeatures: this.cfg.get<boolean>("cargoFeatures.noDefaultFeatures")!, 86 command: this.cfg.get<string>("checkOnSave.command")!,
106 allFeatures: this.cfg.get<boolean>("cargoFeatures.allFeatures")!,
107 features: this.cfg.get<string[]>("cargoFeatures.features")!,
108 loadOutDirsFromCheck: this.cfg.get<boolean>("cargoFeatures.loadOutDirsFromCheck")!,
109 }; 87 };
110 } 88 }
111} 89}
diff --git a/editors/code/src/ctx.ts b/editors/code/src/ctx.ts
index 86b5f3629..bd1c3de07 100644
--- a/editors/code/src/ctx.ts
+++ b/editors/code/src/ctx.ts
@@ -2,7 +2,7 @@ import * as vscode from 'vscode';
2import * as lc from 'vscode-languageclient'; 2import * as lc from 'vscode-languageclient';
3 3
4import { Config } from './config'; 4import { Config } from './config';
5import { createClient, configToServerOptions } from './client'; 5import { createClient } from './client';
6import { isRustEditor, RustEditor } from './util'; 6import { isRustEditor, RustEditor } from './util';
7 7
8export class Ctx { 8export class Ctx {
@@ -25,7 +25,6 @@ export class Ctx {
25 const res = new Ctx(config, extCtx, client, serverPath); 25 const res = new Ctx(config, extCtx, client, serverPath);
26 res.pushCleanup(client.start()); 26 res.pushCleanup(client.start());
27 await client.onReady(); 27 await client.onReady();
28 client.onRequest('workspace/configuration', _ => [configToServerOptions(config)]);
29 return res; 28 return res;
30 } 29 }
31 30
diff --git a/editors/code/src/status_display.ts b/editors/code/src/status_display.ts
index 0f5f6ef99..f9cadc8a2 100644
--- a/editors/code/src/status_display.ts
+++ b/editors/code/src/status_display.ts
@@ -7,7 +7,7 @@ import { Ctx } from './ctx';
7const spinnerFrames = ['таЛ', 'таЩ', 'та╣', 'та╕', 'та╝', 'та┤', 'таж', 'таз', 'таЗ', 'таП']; 7const spinnerFrames = ['таЛ', 'таЩ', 'та╣', 'та╕', 'та╝', 'та┤', 'таж', 'таз', 'таЗ', 'таП'];
8 8
9export function activateStatusDisplay(ctx: Ctx) { 9export function activateStatusDisplay(ctx: Ctx) {
10 const statusDisplay = new StatusDisplay(ctx.config.cargoWatchOptions.command); 10 const statusDisplay = new StatusDisplay(ctx.config.checkOnSave.command);
11 ctx.pushCleanup(statusDisplay); 11 ctx.pushCleanup(statusDisplay);
12 const client = ctx.client; 12 const client = ctx.client;
13 if (client != null) { 13 if (client != null) {