jupyterlab-lsp
jupyterlab-lsp copied to clipboard
Setting `serverSettings` through Python config
Description
I am trying to pass the serverSettings for pyright using c.LanguageServerManager.language_servers -
c.LanguageServerManager.language_servers = {
"pyright": {
"argv": ["/path/to/pyright/node_modules/pyright/langserver.index.js", "--stdio"],
"languages": ["python"],
"version": 2,
"mime_types": ["text/python", "text/x-ipython"],
"display_name": "pyright",
"serverSettings": {
"python.analysis.extraPaths": get_extra_paths_for_pyright()
}
}
}
Reproduce
Add the some extraPaths in the config provided above and paste it in the ~/.jupyter/jupyter_server_config.py
Expected behavior
I would expect extraPaths passed here to be respected instead of only accepting serverSettings mentioned in overrides.json
I'm hoping to use extraPaths too, but haven't been able to get it to work. fwiw, when editing from the settings UI I'm seeing this:
Unsupported field schema for field jp-SettingsEditor-@krassowski/jupyterlab-lsp:plugin_python.analysis.extraPaths: Missing items definition.
{
"type": "array",
"__additional_property": true
}
- I would suggest we name it
workspace_configurationto disambiguate it from initialization options (#801) and any potential future configuration/settings; - we need to pass the options to frontend so that it knows that these are new defaults, otherwise settings editor will overwrite them:
- a) the defaults are passed via specs, so we could modify defaults on spec level
- b) we could have a custom logic for handling the defaults; this would allow to tell user "Setting X (default set to Y specification level);
- we are already passing defaults to the server: https://github.com/jupyter-lsp/jupyterlab-lsp/blob/2a524df12da74227bd09316fe339f3a62d66aef2/packages/jupyterlab-lsp/src/settings.ts#L319-L329
- the setting validation on LSP server side after
workspace/configurationrequest might sometimes fail; we should back off and remove defaults in that case, warning user about it (we should look forerrorin response)
I am going back and forth between modifying the defaults on jupyter-server extension side vs on frontend side. I lean towards resolving them on server; this will require all frontends to always send the defaults to the LSP server, but we already do that on master (as not doing so would possibly lead to inconsistent state between what is shown to the user in settings editor and what server does if a newer version of LSP server gets used).
@divyansshhh, did it work for you?
I am still struggling with overriding serverSettings part via jupyter_server_config.py.