diff options
author | Kirill Bulatov <[email protected]> | 2020-03-19 22:42:18 +0000 |
---|---|---|
committer | Kirill Bulatov <[email protected]> | 2020-03-30 11:39:14 +0100 |
commit | a9dd4427333d410bebf8e0923d5907b2a31efb50 (patch) | |
tree | 02b7f03bd7db0331fa28f3c967eb33b9ae5c6e32 /editors/code | |
parent | 019f269a0a4f42854c84e749fd5bb24177eafff9 (diff) |
Send the config from the client
Diffstat (limited to 'editors/code')
-rw-r--r-- | editors/code/src/client.ts | 49 | ||||
-rw-r--r-- | editors/code/src/ctx.ts | 3 |
2 files changed, 28 insertions, 24 deletions
diff --git a/editors/code/src/client.ts b/editors/code/src/client.ts index 98f2f232f..0d0832c44 100644 --- a/editors/code/src/client.ts +++ b/editors/code/src/client.ts | |||
@@ -5,6 +5,31 @@ 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 configToOptions(config: Config): object { | ||
9 | return { | ||
10 | publishDecorations: !config.highlightingSemanticTokens, | ||
11 | lruCapacity: config.lruCapacity, | ||
12 | |||
13 | inlayHintsType: config.inlayHints.typeHints, | ||
14 | inlayHintsParameter: config.inlayHints.parameterHints, | ||
15 | inlayHintsChaining: config.inlayHints.chainingHints, | ||
16 | inlayHintsMaxLength: config.inlayHints.maxLength, | ||
17 | |||
18 | cargoWatchEnable: config.cargoWatchOptions.enable, | ||
19 | cargoWatchArgs: config.cargoWatchOptions.arguments, | ||
20 | cargoWatchCommand: config.cargoWatchOptions.command, | ||
21 | cargoWatchAllTargets: config.cargoWatchOptions.allTargets, | ||
22 | |||
23 | excludeGlobs: config.excludeGlobs, | ||
24 | useClientWatching: config.useClientWatching, | ||
25 | featureFlags: config.featureFlags, | ||
26 | withSysroot: config.withSysroot, | ||
27 | cargoFeatures: config.cargoFeatures, | ||
28 | rustfmtArgs: config.rustfmtArgs, | ||
29 | vscodeLldb: vscode.extensions.getExtension("vadimcn.vscode-lldb") != null, | ||
30 | }; | ||
31 | } | ||
32 | |||
8 | export async function createClient(config: Config, serverPath: string): Promise<lc.LanguageClient> { | 33 | export async function createClient(config: Config, serverPath: string): Promise<lc.LanguageClient> { |
9 | // '.' Is the fallback if no folder is open | 34 | // '.' Is the fallback if no folder is open |
10 | // TODO?: Workspace folders support Uri's (eg: file://test.txt). | 35 | // TODO?: Workspace folders support Uri's (eg: file://test.txt). |
@@ -22,32 +47,10 @@ export async function createClient(config: Config, serverPath: string): Promise< | |||
22 | const traceOutputChannel = vscode.window.createOutputChannel( | 47 | const traceOutputChannel = vscode.window.createOutputChannel( |
23 | 'Rust Analyzer Language Server Trace', | 48 | 'Rust Analyzer Language Server Trace', |
24 | ); | 49 | ); |
25 | const cargoWatchOpts = config.cargoWatchOptions; | ||
26 | 50 | ||
27 | const clientOptions: lc.LanguageClientOptions = { | 51 | const clientOptions: lc.LanguageClientOptions = { |
28 | documentSelector: [{ scheme: 'file', language: 'rust' }], | 52 | documentSelector: [{ scheme: 'file', language: 'rust' }], |
29 | initializationOptions: { | 53 | initializationOptions: configToOptions(config), |
30 | publishDecorations: !config.highlightingSemanticTokens, | ||
31 | lruCapacity: config.lruCapacity, | ||
32 | |||
33 | inlayHintsType: config.inlayHints.typeHints, | ||
34 | inlayHintsParameter: config.inlayHints.parameterHints, | ||
35 | inlayHintsChaining: config.inlayHints.chainingHints, | ||
36 | inlayHintsMaxLength: config.inlayHints.maxLength, | ||
37 | |||
38 | cargoWatchEnable: cargoWatchOpts.enable, | ||
39 | cargoWatchArgs: cargoWatchOpts.arguments, | ||
40 | cargoWatchCommand: cargoWatchOpts.command, | ||
41 | cargoWatchAllTargets: cargoWatchOpts.allTargets, | ||
42 | |||
43 | excludeGlobs: config.excludeGlobs, | ||
44 | useClientWatching: config.useClientWatching, | ||
45 | featureFlags: config.featureFlags, | ||
46 | withSysroot: config.withSysroot, | ||
47 | cargoFeatures: config.cargoFeatures, | ||
48 | rustfmtArgs: config.rustfmtArgs, | ||
49 | vscodeLldb: vscode.extensions.getExtension("vadimcn.vscode-lldb") != null, | ||
50 | }, | ||
51 | traceOutputChannel, | 54 | traceOutputChannel, |
52 | middleware: { | 55 | middleware: { |
53 | // Workaround for https://github.com/microsoft/vscode-languageserver-node/issues/576 | 56 | // Workaround for https://github.com/microsoft/vscode-languageserver-node/issues/576 |
diff --git a/editors/code/src/ctx.ts b/editors/code/src/ctx.ts index 84c170ea8..934638c6d 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 } from './client'; | 5 | import { createClient, configToOptions } from './client'; |
6 | import { isRustEditor, RustEditor } from './util'; | 6 | import { isRustEditor, RustEditor } from './util'; |
7 | 7 | ||
8 | export class Ctx { | 8 | export class Ctx { |
@@ -20,6 +20,7 @@ export class Ctx { | |||
20 | const res = new Ctx(config, extCtx, client, serverPath); | 20 | const res = new Ctx(config, extCtx, client, serverPath); |
21 | res.pushCleanup(client.start()); | 21 | res.pushCleanup(client.start()); |
22 | await client.onReady(); | 22 | await client.onReady(); |
23 | client.onRequest('workspace/configuration', _ => [configToOptions(config)]); | ||
23 | return res; | 24 | return res; |
24 | } | 25 | } |
25 | 26 | ||