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

Server-specific options are not used for workspace/configuration response #2495

Closed
smackesey opened this issue Oct 21, 2020 · 7 comments
Closed

Comments

@smackesey
Copy link
Contributor

Describe the bug

For language servers configured without a CoC extension (i.e. those under the "languageserver" field in the settings), the workspace/configuration request is not correctly handled. When CoC receives this request, it should build the response from the content of `"languageserver"/""/"settings". Instead CoC looks at the top level of the configuration for the keys.

This is a problem for some language servers that do not initialize all settings with workspace/didChangeConfiguration request on startup (which is populated by the settings). For example, some settings in Microsoft's pylance appear to be set only via the response to the server's workspace/configuration request:

[Trace - 3:17:08 PM] Received request 'workspace/configuration - (3)'.
Params: {
    "items": [
        {
            "scopeUri": "file:///Users/smackesey/stm/conf/ext/vim",
            "section": "python"
        }
    ]
}

In order to return the appropriate response, coc-settings.json must have have python.* settings defined at the top level, which CoC complains about because it doesn't know about these settings.

Reproduce the bug

This should be reproducible with any language server that sends a workspace/configuration request. Pylance is an example. Configure the language server with trace.server verbose and check the Coc log. You will see that the response to workspace/configuration is built from the top level and not from the language server settings.

@chemzqm
Copy link
Member

chemzqm commented Oct 22, 2020

It's expected, you need coc extension

@chemzqm chemzqm closed this as completed Oct 22, 2020
@smackesey
Copy link
Contributor Author

Would you accept a PR changing this behavior? The current behavior makes no sense. At the very least, it should be documented.

@chemzqm
Copy link
Member

chemzqm commented Oct 22, 2020

It should be bug of your language server, you can provide verbose output

@smackesey
Copy link
Contributor Author

This can't be a bug of the language server, since the server has no control over how CoC builds the response to the workspace/configuration request sent by the server. The problem is that CoC builds the response from the top level settings in coc-settings.json instead of using the settings defined for the specific language server.

@chemzqm chemzqm reopened this Oct 23, 2020
chemzqm added a commit that referenced this issue Oct 23, 2020
For configured languageserver, only use configured settings from
languageserver section.

Closes #2495
@chemzqm
Copy link
Member

chemzqm commented Oct 23, 2020

Fixed, configuration for user defined language server read configuration from settings field only.

@smackesey
Copy link
Contributor Author

smackesey commented Oct 23, 2020

Hmm... actually this commit does not seem to have fixed the problem. What happens now is that settings aren't read from either the top level or the server specific settings. I see this in the log for pylance:

[Trace - 9:12:48 AM] Received request 'workspace/configuration - (4)'.
Params: {
    "items": [
        {
            "scopeUri": "file:///Users/smackesey/stm/conf/ext/vim",
            "section": "python.analysis"
        }
    ]
}


[Trace - 9:12:48 AM] Sending response 'workspace/configuration - (4)'. Processing request took 1ms
Result: [
    null
]

Even though I have python.analysis.* settings like this:

...
"languageserver": {
  "pylance": {
     ...
    "settings": {
      ...
      "python.analysis.typeCheckingMode": "basic",
      ...
    }
  }
},
...
"python.analysis.typeCheckingMode": "basic",
...

@chemzqm
Copy link
Member

chemzqm commented Oct 23, 2020

Avoid . in keys of settings

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

2 participants