Skip to content
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
11 changes: 9 additions & 2 deletions vscode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "simplicityhl",
"displayName": "SimplicityHL Language Support",
"description": "Syntax highlighting and autocompletion for SimplicityHL (Simfony) language",
"version": "0.2.0",
"version": "0.2.1",
"publisher": "Blockstream",
"repository": {
"type": "git",
Expand Down Expand Up @@ -69,7 +69,14 @@
"description": "Do not show missing LSP executable warning."
}
}
}
},
"commands": [
{
"command": "simplicityhl.restartServer",
"title": "Restart server",
"category": "SimplicityHL"
}
]
},
"license": "MIT",
"scripts": {
Expand Down
15 changes: 15 additions & 0 deletions vscode/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,19 @@ export class LspClient {
}
return this.client.stop();
}

public async restart(): Promise<void> {
if (!this.client) {
window.showWarningMessage("LSP client not initialized. Cannot restart.");
return;
}

try {
await this.client.stop();
await this.client.start();
window.showInformationMessage("SimplicityHL Language Server restarted successfully!");
} catch (e) {
window.showErrorMessage(`Failed to restart LSP: ${e}`);
}
}
}
16 changes: 16 additions & 0 deletions vscode/src/commands.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { ExtensionContext, commands } from "vscode";
import { LspClient } from "./client";

export function registerRestartCommand(
context: ExtensionContext,
lspClient: LspClient
) {
const command = commands.registerCommand(
"simplicityhl.restartServer",
async () => {
await lspClient.restart();
}
);

context.subscriptions.push(command);
}
8 changes: 7 additions & 1 deletion vscode/src/extension.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
import { LspClient } from "./client";
import { registerRestartCommand } from "./commands"
import { ExtensionContext } from "vscode"

let client: LspClient;
export function activate() {

export function activate(context: ExtensionContext) {
client = new LspClient();
void client.start();

registerRestartCommand(context, client);
}
export function deactivate(): Thenable<void> | undefined {
if (!client) {
Expand Down