From 489be40d3a6181b0eb0ee71e8b399692b639baf4 Mon Sep 17 00:00:00 2001 From: Edwin Cheng Date: Fri, 21 Feb 2020 09:57:24 +0800 Subject: Use ensureServerBinary instead --- editors/code/src/commands/server_version.ts | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) (limited to 'editors/code/src/commands') 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 @@ import * as vscode from 'vscode'; -import { ServerVersion } from '../installation/server'; -import { Cmd } from '../ctx'; +import { ensureServerBinary } from '../installation/server'; +import { Ctx, Cmd } from '../ctx'; +import { spawnSync } from 'child_process'; -export function serverVersion(): Cmd { - return () => { - vscode.window.showInformationMessage('rust-analyzer version : ' + ServerVersion); +export function serverVersion(ctx: Ctx): Cmd { + return async () => { + const binaryPath = await ensureServerBinary(ctx.config.serverSource); + + 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)." + ); + } + + const res = spawnSync(binaryPath, ["--version"]); + const version = res.output?.filter(x => x !== null).map(String).join(" "); + vscode.window.showInformationMessage('rust-analyzer version : ' + version); }; } -- cgit v1.2.3