How to use the monaco-languageclient.MonacoServices.install function in monaco-languageclient

To help you get started, we’ve selected a few monaco-languageclient examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github TypeFox / monaco-languageclient / example / src / client.ts View on Github external
// create Monaco editor
const value = `{
    "$schema": "http://json.schemastore.org/coffeelint",
    "line_endings": "unix"
}`;
const editor = monaco.editor.create(document.getElementById("container")!, {
    model: monaco.editor.createModel(value, 'json', monaco.Uri.parse('inmemory://model.json')),
    glyphMargin: true,
    lightbulb: {
        enabled: true
    }
});

// install Monaco language client services
MonacoServices.install(editor);

// create the web socket
const url = createUrl('/sampleServer')
const webSocket = createWebSocket(url);
// listen when the web socket is opened
listen({
    webSocket,
    onConnection: connection => {
        // create and start the language client
        const languageClient = createLanguageClient(connection);
        const disposable = languageClient.start();
        connection.onClose(() => disposable.dispose());
    }
});

function createLanguageClient(connection: MessageConnection): MonacoLanguageClient {
github exercism / website / app / javascript / components / editor / FileEditor.tsx View on Github external
editor.addAction({
      id: 'runTests',
      label: 'Run tests',
      keybindings: [monacoEditor.KeyCode.F2],
      run: onRunTests,
    })

    editor.addAction({
      id: 'submit',
      label: 'Submit',
      keybindings: [monacoEditor.KeyCode.F3],
      run: onSubmit,
    })

    MonacoServices.install(editor)

    editor.setModel(filesRef.current[0].model)

    // Fix a custom code font rendering bug
    // See https://github.com/exercism/website/issues/742#issuecomment-816806513
    document.fonts.ready.then(() => monacoEditor.editor.remeasureFonts())

    editorDidMount({ getFiles, setFiles, openPalette })
  }
github onflow / cadence / npm-packages / cadence-language-server-demo / src / index.ts View on Github external
{
        theme: 'vs-light',
        language: CADENCE_LANGUAGE_ID,
        model: model,
        minimap: {
          enabled: false
        },
      }
    );

    // The Monaco Language Client services have to be installed globally, once.
    // An editor must be passed, which is only used for commands.
    // As the Cadence language server is not providing any commands this is OK

    if (id === 1) {
      MonacoServices.install(editor);
    }

    const server = await createServer(
      'cadence-language-server.wasm',
      (address: string): string | undefined => {
        if (address === '0000000000000001') {
          return models[0].getValue()
        }
      }
    )

    // The stop button demonstrates how to dispose the editor
    // and stop the language server

    buttonElement.addEventListener('click', () => {
      editor.dispose()
github microsoft / BotFramework-Composer / Composer / packages / tools / language-servers / language-understanding / demo / src / client.ts View on Github external
const editor = monaco.editor.create(document.getElementById('container')!, {
  model: monaco.editor.createModel(value, 'bflu', monaco.Uri.parse('inmemory://model.json')),
  glyphMargin: true,
  autoClosingBrackets: 'always',
  wordBasedSuggestions: false,
  autoIndent: true,
  formatOnType: true,
  lightbulb: {
    enabled: true,
  },
  theme: 'lutheme',
});

// install Monaco language client services
MonacoServices.install(editor);

// create the web socket
const url = createUrl('/luServer');
const webSocket = createWebSocket(url);
// listen when the web socket is opened
listen({
  webSocket,
  onConnection: connection => {
    // create and start the language client
    const languageClient = createLanguageClient(connection);
    const disposable: Disposable = languageClient.start();
    connection.onClose(() => disposable.dispose());
    // editor.addCommand(monaco.KeyMod.Alt | monaco.KeyCode.F9, function () {
    //   connection.sendRequest(DocumentOnTypeFormattingRequest.type );
    // });
  },
github microsoft / BotFramework-Composer / Composer / packages / tools / language-servers / language-generation / demo / src / client.ts View on Github external
const value = `#ted
- hello hello
- range
- great 
- ted hello `;
const editor = monaco.editor.create(document.getElementById('container')!, {
  model: monaco.editor.createModel(value, 'botbuilderlg', monaco.Uri.parse('inmemory://model.json')),
  glyphMargin: true,
  lightbulb: {
    enabled: true,
  },
  theme: 'lgtheme',
});

// install Monaco language client services
MonacoServices.install(editor);

// create the web socket
const url = createUrl('/lgServer');
const webSocket = createWebSocket(url);
// listen when the web socket is opened
listen({
  webSocket,
  onConnection: connection => {
    // create and start the language client
    const languageClient = createLanguageClient(connection);
    const disposable = languageClient.start();
    connection.onClose(() => disposable.dispose());
  },
});

function createLanguageClient(connection: MessageConnection): MonacoLanguageClient {
github theia-ide / typescript-language-server / example / src / client.ts View on Github external
// create Monaco editor
const value = `export class Bar {
}
`;
const rootUri = (window as any).rootUri;
const editor = monaco.editor.create(document.getElementById("container")!, {
    model: monaco.editor.createModel(value, "typescript", monaco.Uri.parse(rootUri + '/bar.ts')),
    glyphMargin: true,
    lightbulb: {
        enabled: true
    }
});

// install Monaco language client services
MonacoServices.install(editor, { rootUri });
const p2m = new ProtocolToMonacoConverter();

// create the web socket
const url = createUrl('/sampleServer')
const webSocket = createWebSocket(url);
// listen when the web socket is opened
listen({
    webSocket,
    onConnection: connection => {
        // create and start the language client
        const languageClient = createLanguageClient(connection);
        languageClient.onReady().then(() => {
            languageClient.onRequest(TypeScriptRenameRequest.type, params => {
                editor.setPosition(p2m.asPosition(params.position));
                editor.trigger('', 'editor.action.rename', {});
            });
github exercism / website / app / javascript / components / student / editor / ExercismMonacoEditor.tsx View on Github external
const handleEditorDidMount = (
    editor: monacoEditor.editor.IStandaloneCodeEditor
  ) => {
    editorRef.current = editor

    editor.addAction({
      id: 'runTests',
      label: 'Run tests',
      keybindings: [monacoEditor.KeyCode.F2],
      run: onRunTests,
    })

    MonacoServices.install(editor)

    editorDidMount(editor)
  }
github microsoft / BotFramework-Composer / Composer / packages / lib / code-editor / src / LgEditor.tsx View on Github external
const editorDidMount = (editor: monacoEditor.editor.IStandaloneCodeEditor, monaco: typeof monacoEditor) => {
    if (!window.monacoServiceInstance) {
      window.monacoServiceInstance = MonacoServices.install(editor as monacoCore.editor.IStandaloneCodeEditor | any);
    }

    if (!window.monacoLGEditorInstance) {
      const uri = get(editor.getModel(), 'uri._formatted', '');
      const url = createUrl(lgServer);
      const webSocket: WebSocket = createWebSocket(url);
      listen({
        webSocket,
        onConnection: (connection: MessageConnection) => {
          const languageClient = createLanguageClient('LG Language Client', ['botbuilderlg'], connection);
          if (!window.monacoLGEditorInstance) {
            window.monacoLGEditorInstance = languageClient;
          }
          initializeDocuments(lgOption, uri);
          const disposable = languageClient.start();
          connection.onClose(() => disposable.dispose());