aboutsummaryrefslogtreecommitdiff
path: root/editors/code/src/client.ts
diff options
context:
space:
mode:
Diffstat (limited to 'editors/code/src/client.ts')
-rw-r--r--editors/code/src/client.ts29
1 files changed, 3 insertions, 26 deletions
diff --git a/editors/code/src/client.ts b/editors/code/src/client.ts
index 98f2f232f..3b1d00bca 100644
--- a/editors/code/src/client.ts
+++ b/editors/code/src/client.ts
@@ -5,15 +5,14 @@ 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 async function createClient(config: Config, serverPath: string): Promise<lc.LanguageClient> { 8export async function createClient(config: Config, serverPath: string, cwd: string): Promise<lc.LanguageClient> {
9 // '.' Is the fallback if no folder is open 9 // '.' Is the fallback if no folder is open
10 // TODO?: Workspace folders support Uri's (eg: file://test.txt). 10 // TODO?: Workspace folders support Uri's (eg: file://test.txt).
11 // It might be a good idea to test if the uri points to a file. 11 // It might be a good idea to test if the uri points to a file.
12 const workspaceFolderPath = vscode.workspace.workspaceFolders?.[0]?.uri.fsPath ?? '.';
13 12
14 const run: lc.Executable = { 13 const run: lc.Executable = {
15 command: serverPath, 14 command: serverPath,
16 options: { cwd: workspaceFolderPath }, 15 options: { cwd },
17 }; 16 };
18 const serverOptions: lc.ServerOptions = { 17 const serverOptions: lc.ServerOptions = {
19 run, 18 run,
@@ -22,32 +21,10 @@ export async function createClient(config: Config, serverPath: string): Promise<
22 const traceOutputChannel = vscode.window.createOutputChannel( 21 const traceOutputChannel = vscode.window.createOutputChannel(
23 'Rust Analyzer Language Server Trace', 22 'Rust Analyzer Language Server Trace',
24 ); 23 );
25 const cargoWatchOpts = config.cargoWatchOptions;
26 24
27 const clientOptions: lc.LanguageClientOptions = { 25 const clientOptions: lc.LanguageClientOptions = {
28 documentSelector: [{ scheme: 'file', language: 'rust' }], 26 documentSelector: [{ scheme: 'file', language: 'rust' }],
29 initializationOptions: { 27 initializationOptions: vscode.workspace.getConfiguration("rust-analyzer"),
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, 28 traceOutputChannel,
52 middleware: { 29 middleware: {
53 // Workaround for https://github.com/microsoft/vscode-languageserver-node/issues/576 30 // Workaround for https://github.com/microsoft/vscode-languageserver-node/issues/576