2020-02-21 10:04:03 +08:00
|
|
|
import * as vscode from 'vscode';
|
2020-02-21 09:57:24 +08:00
|
|
|
import { ensureServerBinary } from '../installation/server';
|
|
|
|
|
import { Ctx, Cmd } from '../ctx';
|
|
|
|
|
import { spawnSync } from 'child_process';
|
2020-02-21 10:04:03 +08:00
|
|
|
|
2020-02-21 09:57:24 +08:00
|
|
|
export function serverVersion(ctx: Ctx): Cmd {
|
|
|
|
|
return async () => {
|
2020-03-09 19:57:55 +02:00
|
|
|
const binaryPath = await ensureServerBinary(ctx.config);
|
2020-02-21 09:57:24 +08:00
|
|
|
|
|
|
|
|
if (binaryPath == null) {
|
|
|
|
|
throw new Error(
|
|
|
|
|
"Rust Analyzer Language Server is not available. " +
|
|
|
|
|
"Please, ensure its [proper installation](https://rust-analyzer.github.io/manual.html#installation)."
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2020-02-21 15:51:55 +08:00
|
|
|
const version = spawnSync(binaryPath, ["--version"], { encoding: "utf8" }).stdout;
|
2020-02-21 09:57:24 +08:00
|
|
|
vscode.window.showInformationMessage('rust-analyzer version : ' + version);
|
2020-02-21 10:04:03 +08:00
|
|
|
};
|
2020-02-20 16:49:31 +08:00
|
|
|
}
|