aboutsummaryrefslogtreecommitdiff
path: root/editors/code/src/commands/server_version.ts
blob: 421301b42cdfcd570cd83f0a587e7370d0aa8621 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import * as vscode from 'vscode';
import { ensureServerBinary } from '../installation/server';
import { Ctx, Cmd } from '../ctx';
import { spawnSync } from 'child_process';

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 version = spawnSync(binaryPath, ["--version"], { encoding: "utf8" }).stdout;
        vscode.window.showInformationMessage('rust-analyzer version : ' + version);
    };
}