diff options
Diffstat (limited to 'editors/code/src/client.ts')
-rw-r--r-- | editors/code/src/client.ts | 31 |
1 files changed, 19 insertions, 12 deletions
diff --git a/editors/code/src/client.ts b/editors/code/src/client.ts index 2e3d4aba2..efef820ab 100644 --- a/editors/code/src/client.ts +++ b/editors/code/src/client.ts | |||
@@ -1,39 +1,42 @@ | |||
1 | import * as lc from 'vscode-languageclient'; | 1 | import * as lc from 'vscode-languageclient'; |
2 | import * as vscode from 'vscode'; | ||
2 | 3 | ||
3 | import { window, workspace } from 'vscode'; | ||
4 | import { Config } from './config'; | 4 | import { Config } from './config'; |
5 | import { ensureLanguageServerBinary } from './installation/language_server'; | 5 | import { ensureServerBinary } from './installation/server'; |
6 | import { CallHierarchyFeature } from 'vscode-languageclient/lib/callHierarchy.proposed'; | ||
6 | 7 | ||
7 | export async function createClient(config: Config): Promise<null | lc.LanguageClient> { | 8 | export async function createClient(config: Config): Promise<null | lc.LanguageClient> { |
8 | // '.' Is the fallback if no folder is open | 9 | // '.' Is the fallback if no folder is open |
9 | // TODO?: Workspace folders support Uri's (eg: file://test.txt). | 10 | // TODO?: Workspace folders support Uri's (eg: file://test.txt). |
10 | // 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. |
11 | const workspaceFolderPath = workspace.workspaceFolders?.[0]?.uri.fsPath ?? '.'; | 12 | const workspaceFolderPath = vscode.workspace.workspaceFolders?.[0]?.uri.fsPath ?? '.'; |
12 | 13 | ||
13 | const raLspServerPath = await ensureLanguageServerBinary(config.langServerSource); | 14 | const serverPath = await ensureServerBinary(config.serverSource); |
14 | if (!raLspServerPath) return null; | 15 | if (!serverPath) return null; |
15 | 16 | ||
16 | const run: lc.Executable = { | 17 | const run: lc.Executable = { |
17 | command: raLspServerPath, | 18 | command: serverPath, |
18 | options: { cwd: workspaceFolderPath }, | 19 | options: { cwd: workspaceFolderPath }, |
19 | }; | 20 | }; |
20 | const serverOptions: lc.ServerOptions = { | 21 | const serverOptions: lc.ServerOptions = { |
21 | run, | 22 | run, |
22 | debug: run, | 23 | debug: run, |
23 | }; | 24 | }; |
24 | const traceOutputChannel = window.createOutputChannel( | 25 | const traceOutputChannel = vscode.window.createOutputChannel( |
25 | 'Rust Analyzer Language Server Trace', | 26 | 'Rust Analyzer Language Server Trace', |
26 | ); | 27 | ); |
28 | const cargoWatchOpts = config.cargoWatchOptions; | ||
29 | |||
27 | const clientOptions: lc.LanguageClientOptions = { | 30 | const clientOptions: lc.LanguageClientOptions = { |
28 | documentSelector: [{ scheme: 'file', language: 'rust' }], | 31 | documentSelector: [{ scheme: 'file', language: 'rust' }], |
29 | initializationOptions: { | 32 | initializationOptions: { |
30 | publishDecorations: true, | 33 | publishDecorations: true, |
31 | lruCapacity: config.lruCapacity, | 34 | lruCapacity: config.lruCapacity, |
32 | maxInlayHintLength: config.maxInlayHintLength, | 35 | maxInlayHintLength: config.maxInlayHintLength, |
33 | cargoWatchEnable: config.cargoWatchOptions.enable, | 36 | cargoWatchEnable: cargoWatchOpts.enable, |
34 | cargoWatchArgs: config.cargoWatchOptions.arguments, | 37 | cargoWatchArgs: cargoWatchOpts.arguments, |
35 | cargoWatchCommand: config.cargoWatchOptions.command, | 38 | cargoWatchCommand: cargoWatchOpts.command, |
36 | cargoWatchAllTargets: config.cargoWatchOptions.allTargets, | 39 | cargoWatchAllTargets: cargoWatchOpts.allTargets, |
37 | excludeGlobs: config.excludeGlobs, | 40 | excludeGlobs: config.excludeGlobs, |
38 | useClientWatching: config.useClientWatching, | 41 | useClientWatching: config.useClientWatching, |
39 | featureFlags: config.featureFlags, | 42 | featureFlags: config.featureFlags, |
@@ -78,6 +81,10 @@ export async function createClient(config: Config): Promise<null | lc.LanguageCl | |||
78 | } | 81 | } |
79 | }, | 82 | }, |
80 | }; | 83 | }; |
81 | res.registerProposedFeatures(); | 84 | |
85 | // To turn on all proposed features use: res.registerProposedFeatures(); | ||
86 | // Here we want to just enable CallHierarchyFeature since it is available on stable. | ||
87 | // Note that while the CallHierarchyFeature is stable the LSP protocol is not. | ||
88 | res.registerFeature(new CallHierarchyFeature(res)); | ||
82 | return res; | 89 | return res; |
83 | } | 90 | } |