Skip to content

Offline, privacy-first grammar checker. Fast, open-source, Rust-powered

feat(vscode-plugin): add `harper-ls.restart` command

Matthew Espino5caf150b0767
diff --git a/packages/vscode-plugin/package.json b/packages/vscode-plugin/package.json
index 0e3972c2e..5fa2b030f 100644
--- a/packages/vscode-plugin/package.json
+++ b/packages/vscode-plugin/package.json
@@ -48,7 +48,13 @@
],
"main": "./build/extension.js",
"contributes": {
- "commands": [],
+ "commands": [
+ {
+ "command": "harper-ls.restart",
+ "title": "Harper: Restart Language Server",
+ "description": "Restart harper-ls"
+ }
+ ],
"configuration": {
"type": "object",
"title": "Harper",
diff --git a/packages/vscode-plugin/src/extension.ts b/packages/vscode-plugin/src/extension.ts
index 402280487..2b8045b48 100644
--- a/packages/vscode-plugin/src/extension.ts
+++ b/packages/vscode-plugin/src/extension.ts
@@ -1,7 +1,7 @@
import type { ExtensionContext } from 'vscode';
import type { Executable, LanguageClientOptions } from 'vscode-languageclient/node';
-import { Uri, window } from 'vscode';
+import { commands, Uri, window } from 'vscode';
import { LanguageClient, TransportKind } from 'vscode-languageclient/node';
let client: LanguageClient | undefined = undefined;
@@ -39,6 +39,8 @@ export async function activate(context: ExtensionContext): Promise<void> {
clientOptions.outputChannel = window.createOutputChannel('Harper');
context.subscriptions.push(clientOptions.outputChannel);
+ context.subscriptions.push(commands.registerCommand('harper-ls.restart', startLanguageServer));
+
await startLanguageServer();
}