WIP worker-based LSP server instead of mirror model

This commit is contained in:
Henning Dieterichs 2025-12-19 17:09:05 +01:00
parent ec78a33c7b
commit 39e9e78254
No known key found for this signature in database
GPG key ID: 771381EFFDB9EC06
8 changed files with 15895 additions and 192 deletions

View file

@ -1,5 +1,6 @@
import './style.css';
import * as monaco from '../../src/editor/editor.main';
import type { WorkerImpl } from './worker';
monaco.languages.register({ id: 'typescript' });
@ -11,3 +12,33 @@ const editor = monaco.editor.create(document.getElementById('root')!, {
language: 'typescript',
theme: 'vs-dark',
});
export class ClientImpl extends Disposable {
private readonly _workerImpl: WorkerImpl;
constructor() {
super();
const w = new Worker(new URL('./worker.ts', import.meta.url), { type: 'module' });
const t = monaco.lsp.createTransportToWorker(w);
const client = this._register(new monaco.lsp.MonacoLspClient(t));
this._workerImpl = getRemoteObject<WorkerImpl>(client.channel);
this._register(registerLocalObject(client.channel, this));
this._workerImpl.$setTextToWarnFor('warn', 'This is a warning from the LSP server!');
// this should now see all text documents
this._workerImpl.$getDiagnosticsCount().then(count => {
console.log(`Diagnostics count: ${count}`);
});
}
$callback(): void {
console.log('Callback from server received!');
}
}