Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to to use multiple workspacefolders? #653

Open
zerocewl opened this issue May 6, 2024 · 2 comments
Open

How to to use multiple workspacefolders? #653

zerocewl opened this issue May 6, 2024 · 2 comments

Comments

@zerocewl
Copy link

zerocewl commented May 6, 2024

I'm trying to enable auto completion in the monaco editor from different custom python folders using python-lsp-server. For a single folder this works fine using the workspaceFolder setting from the clientConfig as suggested in the python example config. So for my requirements i tried to use workspaceFolders, but i can not manage to set more folders, i think i'm missing something on the client side.

In the languageClientConfig startOptions i used workspace/didChangeWorkspaceFolders which seems to work with python-lsp-server.

On the client side is no setting for workspaceFolders so i tried to implement a custom workspaceProvider together with a custom workspace file, but this setting seem not to be used at all.

e.g.

  const userConfig: UserConfig = {
    languageClientConfig: {
      options: {
        name: 'Python Language Server',
        $type: 'WebSocket',
        host: 'localhost',
        port: 9002,
        path: 'python',
        startOptions: {
          onCall: (languageClient?: MonacoLanguageClient) => {
            languageClient?.sendRequest(
              'workspace/didChangeConfiguration',
              pluginConfig
            );
            languageClient?.sendRequest('workspace/didChangeWorkspaceFolders', {
              event: {
                added: [
                  {
                    name: 'workspace',
                    uri: URI.file(customUrl).toString(),
                  },
                ],
                removed: [
                ],
              },
            });
          },
          reportStatus: true,
        },
      },
      clientOptions: {
...
    },
    wrapperConfig: {
      serviceConfig: {
        userServices: {
          ...getConfigurationServiceOverride(),
        },
        debugLogging: true,
        workspaceConfig: {
          workspaceProvider: {
            trusted: true,
            workspace: {
              label: 'workspace',
              workspaceUri: monaco.Uri.file(customUrl ?? ''),
            },
            async open() {
              return true;
            },
          },
        },
      },
 ...

Can you suggest what i'm missing here?
Is there any working example how to use multiple workspaceFolders?

@kaisalmen
Copy link
Collaborator

Is there any working example how to use multiple workspaceFolders?

Hi @zerocewl no we don't have such an example. What I observed though is that the pyright language server requires to have the files physically available (e.g. import). The import to hello2.py in this example is not marked as erroneous if the file exists. As client and server don't share the same file system this leads to problems. I am currently looking for a solution.

I don't know how pyright behaves in this scenario with multiple workspaces. Have you tried this in VSCode just to see if or how it works there?

@CGNonofr
Copy link
Collaborator

CGNonofr commented May 6, 2024

To have multiple workspace folders, you can use the workspaceUri but it should link to an existing file on the virtual filesystem

see https://github.com/CodinGame/monaco-vscode-api/blob/656c48cddc9ac2c9aead4d087edf18be991a49c7/demo/src/setup.common.ts#L174-L178

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants