Files
mist-analyzer-vscode/src/extension.ts
T
2026-05-20 13:21:22 +02:00

54 lines
1.3 KiB
TypeScript

import * as path from 'path';
import { workspace, ExtensionContext } from 'vscode';
import {
LanguageClient,
LanguageClientOptions,
ServerOptions,
TransportKind
} from 'vscode-languageclient/node';
let client: LanguageClient | undefined;
export async function activate(context: ExtensionContext) {
// If the extension is launched in debug mode then the debug server options are used
// Otherwise the run options are used
let serverOptions: ServerOptions = {
run: {
command: "cmd.exe",
args: ["/c", "D:\\projects\\mist\\mist\\analyzer.bat"],
transport: TransportKind.stdio
},
debug: {
command: "cmd.exe",
args: ["/c", "D:\\projects\\mist\\mist\\analyzer.bat"],
transport: TransportKind.stdio
}
};
// Options to control the language client
let clientOptions: LanguageClientOptions = {
// Register the server for plain text documents
documentSelector: [{ scheme: 'file', language: 'mist' }],
synchronize: {
fileEvents: workspace.createFileSystemWatcher('**/mist.json')
}
};
// Create the language client and start the client.
client = new LanguageClient(
'MistAnalyzer',
'Mist Analyzer',
serverOptions,
clientOptions
);
// Start the client. This will also launch the server
await client.start();
}
export async function deactivate() {
await client?.dispose();
client = undefined;
}