import { LanguageClient, LanguageClientOptions, ServerOptions, TransportKind, } from 'vscode-languageclient/node' import * as vscode from 'vscode' export function activate(context: vscode.ExtensionContext) { const serverModule = context.asAbsolutePath('server/dist/server.js') const serverOptions: ServerOptions = { run: { module: serverModule, transport: TransportKind.ipc }, debug: { module: serverModule, transport: TransportKind.ipc }, } const clientOptions: LanguageClientOptions = { documentSelector: [{ scheme: 'file', language: 'shrimp' }], } const client = new LanguageClient( 'shrimpLanguageServer', 'Shrimp Language Server', serverOptions, clientOptions ) client.start() context.subscriptions.push(client) // Command: Show Parse Tree context.subscriptions.push( vscode.commands.registerCommand('shrimp.showParseTree', async () => { const editor = vscode.window.activeTextEditor if (!editor || editor.document.languageId !== 'shrimp') { vscode.window.showErrorMessage('No active Shrimp file') return } const result = await client.sendRequest('shrimp/parseTree', { uri: editor.document.uri.toString(), }) const doc = await vscode.workspace.openTextDocument({ content: result, language: 'text', }) await vscode.window.showTextDocument(doc, { preview: false }) }) ) // Command: Show Bytecode context.subscriptions.push( vscode.commands.registerCommand('shrimp.showBytecode', async () => { const editor = vscode.window.activeTextEditor if (!editor || editor.document.languageId !== 'shrimp') { vscode.window.showErrorMessage('No active Shrimp file') return } const result = await client.sendRequest('shrimp/bytecode', { uri: editor.document.uri.toString(), }) const doc = await vscode.workspace.openTextDocument({ content: result, language: 'text', }) await vscode.window.showTextDocument(doc, { preview: false }) }) ) } export function deactivate() {}