Skip to content

Commit 71e5f0a

Browse files
committed
(vscode) massively simplify extension
the class was pointless, I think this should be enough for the foreseeable
1 parent 70fc565 commit 71e5f0a

File tree

1 file changed

+14
-53
lines changed

1 file changed

+14
-53
lines changed

packages/hdx_vscode/src/main.js

+14-53
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,19 @@
11
const vscode = require("vscode");
2-
const lc = require("vscode-languageclient/node");
2+
const { LanguageClient } = require("vscode-languageclient/node");
33

4-
module.exports = { activate, deactivate };
5-
6-
async function deactivate() {}
4+
module.exports = { activate };
75

86
/**
97
* @param {vscode.ExtensionContext} context
10-
* @returns Promise<HdxExtensionContext>
8+
* @returns Promise<void>
119
*/
1210
async function activate(context) {
13-
console.error("Extension active");
14-
const hdxContext = new HdxExtensionContext(context);
15-
await hdxContext.activate();
16-
return hdxContext;
17-
}
18-
19-
class HdxExtensionContext {
20-
/**
21-
* @public
22-
* @readonly
23-
* @type lc.LanguageClient
24-
*/
25-
client;
26-
27-
/**
28-
* @public
29-
* @readonly
30-
* @type vscode.ExtensionContext
31-
*/
32-
context;
33-
34-
constructor(context) {
35-
this.context = context;
36-
}
37-
38-
async activate() {
39-
this.client = await this.createClient();
40-
this.client.start();
41-
}
42-
43-
async deactivate() {
44-
return this.client?.stop();
45-
}
46-
47-
/**
48-
* @returns Promise<lc.LanguageClient>
49-
*/
50-
async createClient() {
51-
const traceOutputChannel = vscode.window.createOutputChannel("hdx Language Server Trace");
52-
const env = Object.assign({}, process.env);
53-
const serverOptions = {
11+
const traceOutputChannel = vscode.window.createOutputChannel("hdx Language Server Trace");
12+
const env = Object.assign({}, process.env);
13+
const client = new LanguageClient(
14+
"hdx",
15+
"hdx Language Server",
16+
{
5417
run: {
5518
command: env.HDX_SERVER_PATH || "hdx",
5619
args: ["lsp"],
@@ -61,14 +24,12 @@ class HdxExtensionContext {
6124
args: ["--debug", "lsp"],
6225
options: { env },
6326
},
64-
};
65-
const clientOptions = {
27+
},
28+
{
6629
documentSelector: [{ scheme: "file", language: "css" }],
6730
diagnosticCollectionName: "hdx",
6831
traceOutputChannel,
69-
};
70-
71-
console.log({ serverOptions, clientOptions });
72-
return new lc.LanguageClient("hdx", "hdx Language Server", serverOptions, clientOptions);
73-
}
32+
},
33+
);
34+
context.subscriptions.push(client.start());
7435
}

0 commit comments

Comments
 (0)