mirror of
https://github.com/microsoft/monaco-editor.git
synced 2025-12-22 10:25:42 +01:00
WIP worker-based LSP server instead of mirror model
This commit is contained in:
parent
ec78a33c7b
commit
39e9e78254
8 changed files with 15895 additions and 192 deletions
|
|
@ -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!');
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue