diff options
-rw-r--r-- | editors/code/src/commands/server_version.ts | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/editors/code/src/commands/server_version.ts b/editors/code/src/commands/server_version.ts index 307408a37..34c18bf3b 100644 --- a/editors/code/src/commands/server_version.ts +++ b/editors/code/src/commands/server_version.ts | |||
@@ -1,10 +1,22 @@ | |||
1 | import * as vscode from 'vscode'; | 1 | import * as vscode from 'vscode'; |
2 | import { ServerVersion } from '../installation/server'; | 2 | import { ensureServerBinary } from '../installation/server'; |
3 | import { Cmd } from '../ctx'; | 3 | import { Ctx, Cmd } from '../ctx'; |
4 | import { spawnSync } from 'child_process'; | ||
4 | 5 | ||
5 | export function serverVersion(): Cmd { | 6 | export function serverVersion(ctx: Ctx): Cmd { |
6 | return () => { | 7 | return async () => { |
7 | vscode.window.showInformationMessage('rust-analyzer version : ' + ServerVersion); | 8 | const binaryPath = await ensureServerBinary(ctx.config.serverSource); |
9 | |||
10 | if (binaryPath == null) { | ||
11 | throw new Error( | ||
12 | "Rust Analyzer Language Server is not available. " + | ||
13 | "Please, ensure its [proper installation](https://rust-analyzer.github.io/manual.html#installation)." | ||
14 | ); | ||
15 | } | ||
16 | |||
17 | const res = spawnSync(binaryPath, ["--version"]); | ||
18 | const version = res.output?.filter(x => x !== null).map(String).join(" "); | ||
19 | vscode.window.showInformationMessage('rust-analyzer version : ' + version); | ||
8 | }; | 20 | }; |
9 | } | 21 | } |
10 | 22 | ||