/ concept-collection / stan-web-ide
Sign in
concept-collection / stan-web-ide
stan-web-ide / src / stan / lspWorker.ts
15 lines · 860 BCodeBlameHistory
21efcb6stan web IDE: run Stan sampling in the browserJeremy Magland 1// Web worker running the Stan language server (stanc3 compiled to JS),
2// which provides diagnostics, hover, completion, and formatting for .stan
3// files. Speaks LSP over postMessage (vscode-languageserver's browser
4// transport); the app side is the small client in lsp.ts.
6import startLanguageServer from 'stan-language-server';
7import { BrowserMessageReader, BrowserMessageWriter, createConnection } from 'vscode-languageserver/browser';
9const reader = new BrowserMessageReader(self as unknown as Worker);
10const writer = new BrowserMessageWriter(self as unknown as Worker);
11const connection = createConnection(reader, writer);
13// the connection types differ between the node and browser entry points of
14// vscode-languageserver, but the runtime shape is the same
15startLanguageServer(connection as unknown as Parameters<typeof startLanguageServer>[0]);
moveopenescclose