Skip to content
This repository has been archived by the owner on Aug 31, 2023. It is now read-only.

feat(vscode): display the version of the language server in the status bar #3616

Merged
merged 1 commit into from
Nov 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions editors/vscode/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions editors/vscode/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,12 @@ import {
StreamInfo,
} from "vscode-languageclient/node";
import { isAbsolute, join } from "path";
import { existsSync, readFileSync } from "fs";
import { existsSync } from "fs";
import { setContextValue } from "./utils";
import { Session } from "./session";
import { syntaxTree } from "./commands/syntaxTree";
import { Commands } from "./commands";
import { StatusBar } from "./statusBar";
import { updateSettingsRequest } from "./lsp_requests";

let client: LanguageClient;

Expand Down Expand Up @@ -90,13 +89,14 @@ export async function activate(context: ExtensionContext) {

context.subscriptions.push(
client.onDidChangeState((evt) => {
statusBar.setServerState(evt.newState);
statusBar.setServerState(client, evt.newState);
}),
);

const handleActiveTextEditorChanged = (textEditor?: TextEditor) => {
if (!textEditor) {
statusBar.setActive(false);
return;
}

const { document } = textEditor;
Expand Down
14 changes: 12 additions & 2 deletions editors/vscode/src/statusBar.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { StatusBarAlignment, StatusBarItem, ThemeColor, window } from "vscode";
import { State } from "vscode-languageclient";
import { LanguageClient } from "vscode-languageclient/node";
import { Commands } from "./commands";

/**
Expand All @@ -24,6 +25,7 @@ export class StatusBar {

private serverState: State = State.Starting;
private isActive: boolean = false;
private serverVersion: string = "";

constructor() {
this.statusBarItem = window.createStatusBarItem(
Expand All @@ -37,8 +39,15 @@ export class StatusBar {
this.update();
}

public setServerState(state: State) {
public setServerState(client: LanguageClient, state: State) {
this.serverState = state;

if (state === State.Running) {
this.serverVersion = client.initializeResult?.serverInfo?.version ?? "";
} else {
this.serverVersion = "";
}

this.update();
}

Expand All @@ -61,7 +70,8 @@ export class StatusBar {
status = Status.Error;
}

this.statusBarItem.text = `$(${status}) Rome`;
this.statusBarItem.text =
`$(${status}) Rome ${this.serverVersion}`.trimEnd();

switch (status) {
case Status.Pending: {
Expand Down
115 changes: 0 additions & 115 deletions editors/vscode/src/status_bar.ts

This file was deleted.