Skip to content

Commit 0fa3646

Browse files
committed
Use ensureServerBinary instead
1 parent 9ca789d commit 0fa3646

File tree

1 file changed

+17
-5
lines changed

1 file changed

+17
-5
lines changed
Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,22 @@
11
import * as vscode from 'vscode';
2-
import { ServerVersion } from '../installation/server';
3-
import { Cmd } from '../ctx';
2+
import { ensureServerBinary } from '../installation/server';
3+
import { Ctx, Cmd } from '../ctx';
4+
import { spawnSync } from 'child_process';
45

5-
export function serverVersion(): Cmd {
6-
return () => {
7-
vscode.window.showInformationMessage('rust-analyzer version : ' + ServerVersion);
6+
export function serverVersion(ctx: Ctx): Cmd {
7+
return async () => {
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);
820
};
921
}
1022

0 commit comments

Comments
 (0)