// The whole VS Code extension: start `vfmt-server` over stdio and let the // language client do the rest. There is deliberately no command, no status // bar item and no setting other than the server's path — every feature the // user sees comes from the server, so anything else added here would be // editor-specific logic above the protocol (docs/features/editor-packaging). const vscode = require('vscode'); const { LanguageClient, TransportKind } = require('vscode-languageclient/node'); /** The single client, kept only so `deactivate` can stop it. */ let client; /** Spawn the server and attach it to Verilog/SystemVerilog documents. */ function activate(context) { const serverPath = vscode.workspace.getConfiguration('vfmt').get('serverPath') || 'vfmt-server'; // No arguments: `vfmt-server` takes none and speaks LSP on stdin/stdout. // `editors/vscode/smoke.js` spawns it exactly this way. const serverOptions = { command: serverPath, args: [], transport: TransportKind.stdio, }; // No `scheme` filter: the server serves `untitled:` buffers too, for // everything single-file (docs/features/vfmt-server/README.md). const clientOptions = { documentSelector: [{ language: 'verilog' }, { language: 'systemverilog' }], }; client = new LanguageClient('vfmt', 'vfmt', serverOptions, clientOptions); context.subscriptions.push(client); client.start(); } /** Stop the server; VS Code waits on the returned promise. */ function deactivate() { return client ? client.stop() : undefined; } module.exports = { activate, deactivate };