Skip to content

How to set configurations to client? #201

Closed

Description

@zerocewl

Is there a way to send client config settings to a language client, e.g pyls?

I read the example from #32, where a simple example was provided. However the vscode api changed, in fact the provided example does not work.
I tried to adapt the example to the changed api, but my config is not send to pyls.

Is there any minimal working example for this?

Activity

  1. stale commented on Apr 23, 2020

    @stale

    This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

  2. raxod502 commented on Jun 23, 2020

    @raxod502

    @TypeFox Any update here? There is no documentation provided on how to do this, and without such documentation it is impossible to use this project with Python language servers among others.

  3. raxod502 commented on Jun 23, 2020

    @raxod502

    Oh thank god I finally figured it out (by spending some hours inspecting the innards of vscode-languageserver-node). You have to add a middleware, like this:

    new MonacoLanguageClient({
      name: "Your Name",
      clientOptions: {
        documentSelector: [{ pattern: "**" }],
        middleware: {
          workspace: {
            configuration: (params, token, configuration) => {
              return [{ foo: "bar" }];
            },
          },
        },
      },
      connectionProvider: {
        get: (errorHandler, closeHandler) =>
          Promise.resolve(
            createConnection(connection, errorHandler, closeHandler)
          ),
      },
    })

    (I won't guarantee the other stuff in that code will work for you, I had to hack a bunch of other things as well. But the middleware key should be correct. Of course you must adjust the actual content of the LSP configuration to taste.)

    The relevant part of vscode-languageserver-node is where the middleware is pulled out and turned into config.

  4. raxod502 commented on Aug 22, 2020

    @raxod502

    For anyone wondering how to actually use this project, you can refer to a complete working example integrating with backend language servers for Python, Ruby, Bash, Go, Rust, and 19 other languages.

  5. umesh-timalsina commented on Sep 22, 2020

    @umesh-timalsina

    Hello @raxod502. What is the middleware key are you referring to? Is it the name of the language server? Or is it something else?

  6. raxod502 commented on Sep 22, 2020

    @raxod502

    By "middleware key" I simply meant the data that appears immediately after middleware: in the sample code.

  7. umesh-timalsina commented on Sep 23, 2020

    @umesh-timalsina

    In Riju, I see that you are using Microsoft's python language server. Is the binary available somewhere? Also, what steps did you take to configure it. It would be helpful for my use case to use a standalone server written in a single language rather than a patchwork of different libraries and extensions.

  8. raxod502 commented on Sep 24, 2020

    @raxod502

    I suggest referring to the code.

  9. itthought commented on Oct 11, 2020

    @itthought

    I am running Microsoft's python language server on a separate machine and want to connect with the monaco editor. And as per language server documentation I need to pass "python.linting.enabled": true config setting to the language server for enabling linting support.

    I am using below config for creating MonacoLanguageClient instance.

    new MonacoLanguageClient({
          name: 'Simple Client',
          clientOptions: {
            // use a language id as a document selector
            documentSelector: ['python'],
            initializationOptions: {
              interpreter: {
                properties: {
                  UseDefaultDatabase: true,
                  Version: '2.7',
                  InterpreterPath: '/usr/bin/python',
                  LibraryPath: '/usr/lib/python2.7'
                }
              },
              asyncStartup: true,
            },
    
            middleware: {
              workspace: {
                configuration: (params, token, configuration) => {
                  return[{python: { linting: {enabled: true}}}];
                },
              }
            },
            synchronize: {
              configurationSection: ''
            },
    
            // disable the default error handler
            errorHandler: {
              error: () => ErrorAction.Continue,
              closed: () => CloseAction.DoNotRestart
            }
          },
          // create a language client connection from the JSON RPC connection on demand
          connectionProvider: {
            get: (errorHandler, closeHandler) => {
              return Promise.resolve(createConnection( connection as any, errorHandler, closeHandler));
            }
          }
        });
    

    Its always sending blank setting to language server.
    {"jsonrpc":"2.0","method":"workspace/didChangeConfiguration","params":{"settings":{}}}

    Is there anyway to send custom setting to language server?

  10. raxod502 commented on Oct 17, 2020

    @raxod502

    I can't speak for the didChangeConfiguration message, Riju (linked above) has support for setting the initializationOptions in the initialize method (key init in Riju language configuration) as well as sending configuration in response to the workspace/configuration message (key config in Riju language configuration, currently unused but I just tested that it does work).

  11. dkattan commented on Jun 6, 2021

    @dkattan

    @itthought did you ever have any success populating the settings payload?

    @raxod502 it looks like Riju was taken down, did you perhaps rename it?

  12. raxod502 commented on Jun 7, 2021

    @raxod502

    it looks like Riju was taken down, did you perhaps rename it?

    Unfortunately, that's not what happened. Please see https://intuitiveexplanations.com/tech/replit/ for the details.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions