Skip to content

Commit

Permalink
(vscode) massively simplify extension
Browse files Browse the repository at this point in the history
the class was pointless, I think this should be enough for the foreseeable
  • Loading branch information
keithamus committed Dec 18, 2024
1 parent b779cd6 commit 98f39dd
Showing 1 changed file with 14 additions and 53 deletions.
67 changes: 14 additions & 53 deletions packages/hdx_vscode/src/main.js
Original file line number Diff line number Diff line change
@@ -1,56 +1,19 @@
const vscode = require("vscode");
const lc = require("vscode-languageclient/node");
const { LanguageClient } = require("vscode-languageclient/node");

module.exports = { activate, deactivate };

async function deactivate() {}
module.exports = { activate };

/**
* @param {vscode.ExtensionContext} context
* @returns Promise<HdxExtensionContext>
* @returns Promise<void>
*/
async function activate(context) {
console.error("Extension active");
const hdxContext = new HdxExtensionContext(context);
await hdxContext.activate();
return hdxContext;
}

class HdxExtensionContext {
/**
* @public
* @readonly
* @type lc.LanguageClient
*/
client;

/**
* @public
* @readonly
* @type vscode.ExtensionContext
*/
context;

constructor(context) {
this.context = context;
}

async activate() {
this.client = await this.createClient();
this.client.start();
}

async deactivate() {
return this.client?.stop();
}

/**
* @returns Promise<lc.LanguageClient>
*/
async createClient() {
const traceOutputChannel = vscode.window.createOutputChannel("hdx Language Server Trace");
const env = Object.assign({}, process.env);
const serverOptions = {
const traceOutputChannel = vscode.window.createOutputChannel("hdx Language Server Trace");
const env = Object.assign({}, process.env);
const client = new LanguageClient(
"hdx",
"hdx Language Server",
{
run: {
command: env.HDX_SERVER_PATH || "hdx",
args: ["lsp"],
Expand All @@ -61,14 +24,12 @@ class HdxExtensionContext {
args: ["--debug", "lsp"],
options: { env },
},
};
const clientOptions = {
},
{
documentSelector: [{ scheme: "file", language: "css" }],
diagnosticCollectionName: "hdx",
traceOutputChannel,
};

console.log({ serverOptions, clientOptions });
return new lc.LanguageClient("hdx", "hdx Language Server", serverOptions, clientOptions);
}
},
);
context.subscriptions.push(client.start());
}

0 comments on commit 98f39dd

Please sign in to comment.