Skip to content

Commit

Permalink
add possibility to recreate server connection
Browse files Browse the repository at this point in the history
  • Loading branch information
s-and-witch committed Nov 27, 2023
1 parent 492718f commit d7417ae
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 7 deletions.
8 changes: 7 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"displayName": "Tales LSP",
"publisher": "sand-witch",
"description": "",
"version": "0.0.1",
"version": "0.0.2",
"engines": {
"vscode": "^1.74.0"
},
Expand All @@ -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",
Expand Down
22 changes: 16 additions & 6 deletions src/extension.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -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,
Expand All @@ -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<void> | undefined {
Expand Down

0 comments on commit d7417ae

Please sign in to comment.