diff options
Diffstat (limited to 'editors/code/src')
-rw-r--r-- | editors/code/src/client.ts | 26 | ||||
-rw-r--r-- | editors/code/src/commands/runnables.ts | 4 | ||||
-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, 11 insertions, 54 deletions
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/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'; | |||
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) { |