// Starts `rex lsp` and connects the editor to it. All the work is done by the compiler. const vscode = require('vscode'); const { LanguageClient } = require('vscode-languageclient/node'); let client; function activate() { const command = vscode.workspace.getConfiguration('rex').get('serverPath') || 'rex'; client = new LanguageClient( 'rex', 'Rex Language Server', { command, args: ['lsp'] }, { documentSelector: [{ scheme: 'file', language: 'rex' }] } ); client.start().catch((err) => { vscode.window.showErrorMessage( `Could not start "${command} lsp": ${err.message}. Put the rex program on your PATH or set "rex.serverPath".` ); }); } function deactivate() { return client ? client.stop() : undefined; } module.exports = { activate, deactivate };