diff options
Diffstat (limited to 'editors')
-rw-r--r-- | editors/code/package.json | 6 | ||||
-rw-r--r-- | editors/code/src/client.ts | 26 | ||||
-rw-r--r-- | editors/code/src/config.ts | 30 | ||||
-rw-r--r-- | editors/code/src/ctx.ts | 3 | ||||
-rw-r--r-- | editors/code/src/status_display.ts | 2 |
5 files changed, 8 insertions, 59 deletions
diff --git a/editors/code/package.json b/editors/code/package.json index df8adfe0e..1f95cd130 100644 --- a/editors/code/package.json +++ b/editors/code/package.json | |||
@@ -217,7 +217,6 @@ | |||
217 | "type": "boolean", | 217 | "type": "boolean", |
218 | "markdownDescription": "Whether to show `can't find Cargo.toml` error message" | 218 | "markdownDescription": "Whether to show `can't find Cargo.toml` error message" |
219 | }, | 219 | }, |
220 | |||
221 | "rust-analyzer.cargo.noDefaultFeatures": { | 220 | "rust-analyzer.cargo.noDefaultFeatures": { |
222 | "type": "boolean", | 221 | "type": "boolean", |
223 | "default": false, | 222 | "default": false, |
@@ -272,7 +271,6 @@ | |||
272 | "default": true, | 271 | "default": true, |
273 | "markdownDescription": "Check all targets and tests (will be passed as `--all-targets`)" | 272 | "markdownDescription": "Check all targets and tests (will be passed as `--all-targets`)" |
274 | }, | 273 | }, |
275 | |||
276 | "rust-analyzer.inlayHints.typeHints": { | 274 | "rust-analyzer.inlayHints.typeHints": { |
277 | "type": "boolean", | 275 | "type": "boolean", |
278 | "default": true, | 276 | "default": true, |
@@ -298,7 +296,6 @@ | |||
298 | "exclusiveMinimum": true, | 296 | "exclusiveMinimum": true, |
299 | "description": "Maximum length for inlay hints" | 297 | "description": "Maximum length for inlay hints" |
300 | }, | 298 | }, |
301 | |||
302 | "rust-analyzer.completion.addCallParenthesis": { | 299 | "rust-analyzer.completion.addCallParenthesis": { |
303 | "type": "boolean", | 300 | "type": "boolean", |
304 | "default": true, | 301 | "default": true, |
@@ -318,7 +315,6 @@ | |||
318 | "type": "boolean", | 315 | "type": "boolean", |
319 | "description": "Show function name and docs in parameter hints" | 316 | "description": "Show function name and docs in parameter hints" |
320 | }, | 317 | }, |
321 | |||
322 | "rust-analyzer.highlighting.semanticTokens": { | 318 | "rust-analyzer.highlighting.semanticTokens": { |
323 | "type": "boolean", | 319 | "type": "boolean", |
324 | "default": false, | 320 | "default": false, |
@@ -370,7 +366,7 @@ | |||
370 | "description": "Enable logging of VS Code extensions itself", | 366 | "description": "Enable logging of VS Code extensions itself", |
371 | "type": "boolean", | 367 | "type": "boolean", |
372 | "default": false | 368 | "default": false |
373 | }, | 369 | } |
374 | } | 370 | } |
375 | }, | 371 | }, |
376 | "problemPatterns": [ | 372 | "problemPatterns": [ |
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'; | |||
5 | import { CallHierarchyFeature } from 'vscode-languageclient/lib/callHierarchy.proposed'; | 5 | import { CallHierarchyFeature } from 'vscode-languageclient/lib/callHierarchy.proposed'; |
6 | import { SemanticTokensFeature, DocumentSemanticsTokensSignature } from 'vscode-languageclient/lib/semanticTokens.proposed'; | 6 | import { SemanticTokensFeature, DocumentSemanticsTokensSignature } from 'vscode-languageclient/lib/semanticTokens.proposed'; |
7 | 7 | ||
8 | export 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 | |||
32 | export async function createClient(config: Config, serverPath: string, cwd: string): Promise<lc.LanguageClient> { | 8 | export 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/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'; | |||
2 | import * as lc from 'vscode-languageclient'; | 2 | import * as lc from 'vscode-languageclient'; |
3 | 3 | ||
4 | import { Config } from './config'; | 4 | import { Config } from './config'; |
5 | import { createClient, configToServerOptions } from './client'; | 5 | import { createClient } from './client'; |
6 | import { isRustEditor, RustEditor } from './util'; | 6 | import { isRustEditor, RustEditor } from './util'; |
7 | 7 | ||
8 | export class Ctx { | 8 | export 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'; | |||
7 | const spinnerFrames = ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏']; | 7 | const spinnerFrames = ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏']; |
8 | 8 | ||
9 | export function activateStatusDisplay(ctx: Ctx) { | 9 | export 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) { |