Agda Language Server WASM Loader
A helper extension to load and spin up a functional instance of the WebAssembly build of Agda Language Server.
This extension is designed to work jointly with Agda mode for VS Code, and contains a patched instance of WASM WASI Core Extension. As a result, the consumer of this package is expected to prepare a WASM module compiled with WebAssembly.compile
, along with all data files and interface files, placed in a in-memory VFS.
Sample usage
Use this in your extension activation script as a starting point:
import { LanguageClient, LanguageClientOptions } from 'vscode-languageclient'
const ext = extensions.getExtension('qbane.als-wasm-loader')
if (!ext.isActive) {
await ext.activate()
}
const {
AgdaLanguageServerFactory,
WasmAPILoader,
createUriConverters,
} = ext.exports
const wasm = WasmAPILoader.load()
const alsWasmRaw = await workspace.fs.readFile(Uri.joinPath(context.extensionUri, 'path/to/als.wasm'))
const mod = WebAssembly.compile(alsWasmRaw)
const factory = new AgdaLanguageServerFactory(wasm, mod)
const memfsAgdaDataDir = await wasm.createMemoryFileSystem()
// TODO: prepare memfs like below:
// const resp = await fetch('path/to/agda-data.zip')
// ext.exports.prepareMemfsFromAgdaDataZip(await resp.bytes(), memfsAgdaDataDir)
const serverOptions = () => factory.createServer(memfsAgdaDataDir, {
// TODO: process options
})
const clientOptions = {
// TODO: add more client options
uriConverters: createUriConverters(),
}
const client = new LanguageClient('als', 'Agda Language Server', serverOptions, clientOptions)
client.registerProposedFeatures()
client.onRequest('agda', (res, opts) => {
// TODO: add your own callback handling logic
})
Acknowledgements
The included WASM WASI Core Extension fixes some WASM/WASI issues to satisfy Haskell-based WASM modules' need, including but not limited to: