diff --git a/package.json b/package.json index 042f92b..094dbf9 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "displayName": "Tales LSP", "publisher": "sand-witch", "description": "", - "version": "0.0.1", + "version": "0.0.2", "engines": { "vscode": "^1.74.0" }, @@ -20,6 +20,12 @@ ], "main": "./dist/extension", "contributes": { + "commands": [ + { + "command": "tales-lsp.recreate-server", + "title": "Tales LSP: Recreate server" + } + ], "configuration": { "type": "object", "title": "Example configuration", diff --git a/src/extension.ts b/src/extension.ts index 4be9960..07cf1c1 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -1,6 +1,6 @@ // The module 'vscode' contains the VS Code extensibility API // Import the module and reference it with the alias vscode in your code below -// import * as vscode from 'vscode'; +import * as vscode from 'vscode'; import { LanguageClient, @@ -11,14 +11,11 @@ import { let client: LanguageClient; -// This method is called when your extension is activated -// Your extension is activated the very first time the command is executed -export function activate(context: any) { - +function initClient() { // If the extension is launched in debug mode then the debug server options are used // Otherwise the run options are used const serverOptions: ServerOptions = { - run: { command: "tale-tale", transport: TransportKind.stdio }, + run: { command: "tale-lsp", transport: TransportKind.stdio }, debug: { command: "tales-lsp", transport: TransportKind.stdio, @@ -41,6 +38,19 @@ export function activate(context: any) { // Start the client. This will also launch the server client.start(); +}; + +// This method is called when your extension is activated +// Your extension is activated the very first time the command is executed +export function activate(context: any) { + let recreateServer = vscode.commands.registerCommand('tales-lsp.recreate-server', () => { + deactivate(); + initClient(); + }); + context.subscriptions.push(recreateServer); + try { + initClient(); + } catch {}; } export function deactivate(): Thenable | undefined {