Skip to content

Commit 4d69708

Browse files
committed
add "Restart Server" command
1 parent f598c47 commit 4d69708

4 files changed

Lines changed: 46 additions & 2 deletions

File tree

vscode/package.json

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,14 @@
6969
"description": "Do not show missing LSP executable warning."
7070
}
7171
}
72-
}
72+
},
73+
"commands": [
74+
{
75+
"command": "simplicityhl.restartServer",
76+
"title": "Restart server",
77+
"category": "SimplicityHL"
78+
}
79+
]
7380
},
7481
"license": "MIT",
7582
"scripts": {

vscode/src/client.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,4 +59,19 @@ export class LspClient {
5959
}
6060
return this.client.stop();
6161
}
62+
63+
public async restart(): Promise<void> {
64+
if (!this.client) {
65+
window.showWarningMessage("LSP client not initialized. Cannot restart.");
66+
return;
67+
}
68+
69+
try {
70+
await this.client.stop();
71+
await this.client.start();
72+
window.showInformationMessage("SimplicityHL Language Server restarted successfully!");
73+
} catch (e) {
74+
window.showErrorMessage(`Failed to restart LSP: ${e}`);
75+
}
76+
}
6277
}

vscode/src/commands.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { ExtensionContext, commands } from "vscode";
2+
import { LspClient } from "./client";
3+
4+
export function registerRestartCommand(
5+
context: ExtensionContext,
6+
lspClient: LspClient
7+
) {
8+
const command = commands.registerCommand(
9+
"simplicityhl.restartServer",
10+
async () => {
11+
await lspClient.restart();
12+
}
13+
);
14+
15+
context.subscriptions.push(command);
16+
}

vscode/src/extension.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
11
import { LspClient } from "./client";
2+
import { registerRestartCommand } from "./commands"
3+
import { ExtensionContext } from "vscode"
4+
25
let client: LspClient;
3-
export function activate() {
6+
7+
export function activate(context: ExtensionContext) {
48
client = new LspClient();
59
void client.start();
10+
11+
registerRestartCommand(context, client);
612
}
713
export function deactivate(): Thenable<void> | undefined {
814
if (!client) {

0 commit comments

Comments
 (0)