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.ts25
1 files changed, 14 insertions, 11 deletions
diff --git a/editors/code/src/client.ts b/editors/code/src/client.ts
index d2759969b..11894973c 100644
--- a/editors/code/src/client.ts
+++ b/editors/code/src/client.ts
@@ -1,45 +1,48 @@
1import * as lc from 'vscode-languageclient'; 1import * as lc from 'vscode-languageclient';
2import * as vscode from 'vscode';
2 3
3import { window, workspace } from 'vscode';
4import { Config } from './config'; 4import { Config } from './config';
5import { ensureLanguageServerBinary } from './installation/language_server'; 5import { ensureServerBinary } from './installation/server';
6import { CallHierarchyFeature } from 'vscode-languageclient/lib/callHierarchy.proposed'; 6import { CallHierarchyFeature } from 'vscode-languageclient/lib/callHierarchy.proposed';
7 7
8export async function createClient(config: Config): Promise<null | lc.LanguageClient> { 8export async function createClient(config: Config): Promise<null | 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 = workspace.workspaceFolders?.[0]?.uri.fsPath ?? '.'; 12 const workspaceFolderPath = vscode.workspace.workspaceFolders?.[0]?.uri.fsPath ?? '.';
13 13
14 const raLspServerPath = await ensureLanguageServerBinary(config.langServerSource); 14 const serverPath = await ensureServerBinary(config.serverSource);
15 if (!raLspServerPath) return null; 15 if (!serverPath) return null;
16 16
17 const run: lc.Executable = { 17 const run: lc.Executable = {
18 command: raLspServerPath, 18 command: serverPath,
19 options: { cwd: workspaceFolderPath }, 19 options: { cwd: workspaceFolderPath },
20 }; 20 };
21 const serverOptions: lc.ServerOptions = { 21 const serverOptions: lc.ServerOptions = {
22 run, 22 run,
23 debug: run, 23 debug: run,
24 }; 24 };
25 const traceOutputChannel = window.createOutputChannel( 25 const traceOutputChannel = vscode.window.createOutputChannel(
26 'Rust Analyzer Language Server Trace', 26 'Rust Analyzer Language Server Trace',
27 ); 27 );
28 const cargoWatchOpts = config.cargoWatchOptions;
29
28 const clientOptions: lc.LanguageClientOptions = { 30 const clientOptions: lc.LanguageClientOptions = {
29 documentSelector: [{ scheme: 'file', language: 'rust' }], 31 documentSelector: [{ scheme: 'file', language: 'rust' }],
30 initializationOptions: { 32 initializationOptions: {
31 publishDecorations: true, 33 publishDecorations: true,
32 lruCapacity: config.lruCapacity, 34 lruCapacity: config.lruCapacity,
33 maxInlayHintLength: config.maxInlayHintLength, 35 maxInlayHintLength: config.maxInlayHintLength,
34 cargoWatchEnable: config.cargoWatchOptions.enable, 36 cargoWatchEnable: cargoWatchOpts.enable,
35 cargoWatchArgs: config.cargoWatchOptions.arguments, 37 cargoWatchArgs: cargoWatchOpts.arguments,
36 cargoWatchCommand: config.cargoWatchOptions.command, 38 cargoWatchCommand: cargoWatchOpts.command,
37 cargoWatchAllTargets: config.cargoWatchOptions.allTargets, 39 cargoWatchAllTargets: cargoWatchOpts.allTargets,
38 excludeGlobs: config.excludeGlobs, 40 excludeGlobs: config.excludeGlobs,
39 useClientWatching: config.useClientWatching, 41 useClientWatching: config.useClientWatching,
40 featureFlags: config.featureFlags, 42 featureFlags: config.featureFlags,
41 withSysroot: config.withSysroot, 43 withSysroot: config.withSysroot,
42 cargoFeatures: config.cargoFeatures, 44 cargoFeatures: config.cargoFeatures,
45 rustfmtArgs: config.rustfmtArgs,
43 }, 46 },
44 traceOutputChannel, 47 traceOutputChannel,
45 }; 48 };