monaco-languageclient icon indicating copy to clipboard operation
monaco-languageclient copied to clipboard

Get LanguageClient of LSP running in WebExtension

Open P422L opened this issue 1 year ago • 6 comments

Description

I have created a MonacoEditorReactComp with the following userConfig:

import getEditorServiceOverride from '@codingame/monaco-vscode-editor-service-override';
import './custom-lsp-1.0.0.vsix';
import { useOpenEditorStub } from 'monaco-editor-wrapper/vscode/services';
import { UserConfig } from 'monaco-editor-wrapper';

export const setupExtended = async (test?: string): Promise<UserConfig> => {
    let main = {
        text: text || "",
        fileExt: 'test'
    };
    let original = {
        text: text || "",
        fileExt: 'test'
    };

    return {
        wrapperConfig: {
            serviceConfig: {
                userServices: {
                    ...getEditorServiceOverride(useOpenEditorStub),
                },
                enableExtHostWorker: true,
                debugLogging: true
            },
            editorAppConfig: {
                $type: 'extended',
                codeResources: {
                    main,
                    original
                },
                useDiffEditor: false,
                userConfiguration: {
                    json: JSON.stringify({
                        'workbench.colorTheme': 'Custom Dark',
                    })
                }
            }
        }
    }
}

The LSP functionalities work as expected, meaning my Monaco editor is definitely connected to the LanguageClient from the .vsix file, and this LanguageClient is also connected to the LanguageServer running in the extension.

Use Case

I need to react to a custom state of the LanguageClient, meaning I need a way to communicate between the LanguageClient and my editor. Currently, I only see options to access the LanguageClient and the connection when I create it in the config, but not when I want to access a LanguageClient in an extension.

Question

How can I obtain the connection details for a LanguageClient that is running in an extension, so I can communicate with it from my editor? Is there no way I can access it via the id?

P422L avatar Sep 24 '24 07:09 P422L