2 Commits bd316c9fac ... 79b3428441

Author SHA1 Message Date
  VHDL Tool 79b3428441 dev notes 6 months ago
  VHDL Tool efb802c511 make more similar to reference example 6 months ago
2 changed files with 20 additions and 2 deletions
  1. 8 0
      development.md
  2. 12 2
      src/extension.ts

+ 8 - 0
development.md

@@ -0,0 +1,8 @@
1
+# Reference
2
+Basic example: https://github.com/microsoft/vscode-extension-samples/tree/main/lsp-sample/client
3
+
4
+# Incantations
5
+tsc -p .
6
+npm install
7
+code .
8
+<F5>

+ 12 - 2
src/extension.ts

@@ -25,6 +25,8 @@ export function executableExists(exe: string): boolean {
25 25
   return out.status === 0 || (isWindows && fs.existsSync(exe));
26 26
 }
27 27
 
28
+let client: LanguageClient;
29
+
28 30
 export function activate(context: ExtensionContext) {
29 31
 
30 32
 	if (executableExists('vhdl-tool')) {
@@ -46,13 +48,21 @@ export function activate(context: ExtensionContext) {
46 48
 		}
47 49
 		
48 50
 		// Create the language client and start the client.
49
-		let disposable = new LanguageClient('vhdltool', 'Language Server VHDL', serverOptions, clientOptions).start();
51
+		let client = new LanguageClient('vhdltool', 'Language Server VHDL', serverOptions, clientOptions);
50 52
 		
51 53
 		// Push the disposable to the context's subscriptions so that the client can be deactivated on extension deactivation
52
-		context.subscriptions.push(disposable);
54
+		client.start();
53 55
 	} else {
54 56
 		const notInstalledMsg: string =
55 57
 			'Please download VHDL-Tool from https://www.vhdltool.com/download and place it somewhere in your $PATH';
56 58
 		window.showErrorMessage(notInstalledMsg);
57 59
 	}
58 60
 }
61
+
62
+export function deactivate(): Thenable<void> | undefined {
63
+	if (!client) {
64
+		return undefined;
65
+	}
66
+	return client.stop();
67
+}
68
+