diff --git a/package-lock.json b/package-lock.json index 7f0118e..12f35cf 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,14 +1,15 @@ { - "name": "futhark", + "name": "futhark-vscode", "version": "0.0.1", "lockfileVersion": 2, "requires": true, "packages": { "": { - "name": "futhark", + "name": "futhark-vscode", "version": "0.0.1", "license": "SEE LICENSE IN LICENSE", "dependencies": { + "@types/which": "^2.0.1", "vscode-languageclient": "^7.0.0", "which": "^2.0.2" }, @@ -129,6 +130,11 @@ "integrity": "sha512-awvdx4vX7SkMKyvWIlRjycjb4blYRSQI3Bav0YMn+lJLGN6gJgb20urN/dQCv/2ejDu5S6ADEBt6O15DOpIAkg==", "dev": true }, + "node_modules/@types/which": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/@types/which/-/which-2.0.1.tgz", + "integrity": "sha512-Jjakcv8Roqtio6w1gr0D7y6twbhx6gGgFGF5BLwajPpnOIOxFkakFhCq+LmyyeAz7BX6ULrjBOxdKaCDy+4+dQ==" + }, "node_modules/@typescript-eslint/eslint-plugin": { "version": "5.10.2", "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-5.10.2.tgz", @@ -1976,6 +1982,11 @@ "integrity": "sha512-awvdx4vX7SkMKyvWIlRjycjb4blYRSQI3Bav0YMn+lJLGN6gJgb20urN/dQCv/2ejDu5S6ADEBt6O15DOpIAkg==", "dev": true }, + "@types/which": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/@types/which/-/which-2.0.1.tgz", + "integrity": "sha512-Jjakcv8Roqtio6w1gr0D7y6twbhx6gGgFGF5BLwajPpnOIOxFkakFhCq+LmyyeAz7BX6ULrjBOxdKaCDy+4+dQ==" + }, "@typescript-eslint/eslint-plugin": { "version": "5.10.2", "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-5.10.2.tgz", diff --git a/package.json b/package.json index 3b11fa1..40e6e34 100644 --- a/package.json +++ b/package.json @@ -45,7 +45,14 @@ "type": "object", "title": "Futhark", "properties": {} - } + }, + "commands": [ + { + "command": "futhark.commands.restartServer", + "title": "Restart Futhark Language Server", + "category": "Futhark" + } + ] }, "scripts": { "vscode:prepublish": "rm -rf ./out && npm run esbuild -- --minify", @@ -63,6 +70,7 @@ "typescript": "^4.5.5" }, "dependencies": { + "@types/which": "^2.0.1", "vscode-languageclient": "^7.0.0", "which": "^2.0.2" } diff --git a/src/extension.ts b/src/extension.ts index bc13216..2757617 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -1,5 +1,5 @@ import which from 'which' -import { window } from 'vscode' +import { window, commands, ExtensionContext } from 'vscode' import { LanguageClient, LanguageClientOptions, @@ -10,7 +10,7 @@ import { let client: LanguageClient // entry point of the extension -export async function activate() { +export async function activate(context: ExtensionContext) { which('futhark') .then((resolvedPath) => { // run `futhark lsp` to fire up the language server @@ -35,6 +35,17 @@ export async function activate() { clientOptions ) + const restartCommand = commands.registerCommand( + 'futhark.commands.restartServer', + async () => { + client.info('Restarting server...') + await client.stop() + client.info('Starting server...') + client.start() + } + ) + context.subscriptions.push(restartCommand) + client.start() }) .catch((err) => {