Skip to content

Commit

Permalink
feat(vscode): provide command to restart the LSP server
Browse files Browse the repository at this point in the history
Although mostly useful during development, add a custom command to the
VSCode extension, which allows to restart the LSP server.
  • Loading branch information
dnaka91 committed Dec 5, 2023
1 parent ca1f300 commit 21e5001
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
11 changes: 9 additions & 2 deletions vscode-extension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,20 @@
"description": "Controls the maximum number of problems produced by the server."
}
}
}
},
"commands": [
{
"command": "stef.restart",
"title": "Restart LSP Server",
"category": "Stef"
}
]
},
"vsce": {
"dependencies": false
},
"scripts": {
"esbuild": "esbuild ./src/extension.ts --outfile=dist/extension.js --external:vscode --format=cjs --platform=node --bundle",
"esbuild": "esbuild src/extension.ts --outfile=dist/extension.js --external:vscode --format=cjs --platform=node --bundle",
"watch": "bun run esbuild --watch",
"build": "bun run esbuild --minify",
"lint": "biome check --apply src/**/*.ts",
Expand Down
12 changes: 11 additions & 1 deletion vscode-extension/src/extension.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ExtensionContext, workspace } from "vscode";
import { ExtensionContext, commands, workspace } from "vscode";
import {
Executable,
LanguageClient,
Expand All @@ -9,7 +9,17 @@ import {

let client: LanguageClient;

enum Cmds {
Restart = "stef.restart",
}

export function activate(context: ExtensionContext) {
context.subscriptions.push(
commands.registerCommand(Cmds.Restart, () => {
client?.restart();
}),
);

const executable: Executable = {
command: "stef-lsp",
transport: TransportKind.stdio,
Expand Down

0 comments on commit 21e5001

Please sign in to comment.