aboutsummaryrefslogtreecommitdiff
path: root/editors/code/src/commands/server_version.ts
blob: d64ac726e2cc6ad8afb07ff22a1b00d18def2b9e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
import * as vscode from "vscode";
import { spawnSync } from "child_process";
import { Ctx, Cmd } from '../ctx';

export function serverVersion(ctx: Ctx): Cmd {
    return async () => {
        const { stdout } = spawnSync(ctx.serverPath, ["--version"], { encoding: "utf8" });
        const commitHash = stdout.slice(`rust-analyzer `.length).trim();
        const { releaseTag } = ctx.config.package;

        void vscode.window.showInformationMessage(
            `rust-analyzer version: ${releaseTag ?? "unreleased"} (${commitHash})`
        );
    };
}