MCPcopy Create free account
hub / github.com/EmNudge/watlings / createEditor

Function createEditor

web-build/src/editor.ts:552–578  ·  view source on GitHub ↗
(
  parent: HTMLElement,
  initialCode: string,
  onChange?: (code: string) => void,
)

Source from the content-addressed store, hash-verified

550}
551
552export async function createEditor(
553 parent: HTMLElement,
554 initialCode: string,
555 onChange?: (code: string) => void,
556): Promise<WatEditor> {
557 const lsp = await initLSP();
558 const lspResult = createLspExtensions(lsp);
559
560 return buildEditor(
561 parent,
562 initialCode,
563 [
564 watLanguageSupport(),
565 keymap.of([
566 { key: "F12", run: (v) => lspResult.goToDefinition(v) },
567 { key: "Mod-b", run: (v) => lspResult.goToDefinition(v) },
568 { key: "Shift-F12", run: (v) => lspResult.findReferences(v) },
569 { key: "Mod-Shift-b", run: (v) => lspResult.findReferences(v) },
570 ...baseKeymap,
571 ]),
572 closeBrackets(),
573 autocompletion({ override: [lspResult.completionSource] }),
574 ...lspResult.extensions,
575 ],
576 onChange,
577 );
578}

Callers

nothing calls this directly

Calls 3

createLspExtensionsFunction · 0.85
buildEditorFunction · 0.85
watLanguageSupportFunction · 0.85

Tested by

no test coverage detected