jupyter-lsp / jupyterlab-lsp

Coding assistance for JupyterLab (code navigation + hover suggestions + linters + autocompletion + rename) using Language Server Protocol
https://jupyterlab-lsp.readthedocs.io
BSD 3-Clause "New" or "Revised" License
1.78k stars 146 forks source link

Allo to pass Initialization Options #801

Open henryju opened 2 years ago

henryju commented 2 years ago

Our language server is expecting some initialization options in the InitializeParams. Looking at the code, it seems it is not possible: https://github.com/jupyter-lsp/jupyterlab-lsp/blob/84121b44323172b16ab25c1bcd98d41ec1ee8513/packages/jupyterlab-lsp/src/connection.ts#L410

Would be great to have a way to pass them in the jupyter_server_config.json:

{
    "LanguageServerManager": {
      "language_servers": {
        "sonarlint": {
          "version": 2,
          "argv": ["C:\\Prog\\Projects\\sonarlint\\sonarlint-language-server\\sonarlint-ls.bat"],
          "languages": ["python"],
          "mime_types": ["text/python", "text/x-ipython"],
          "display_name": "SonarLint LS",
          "initializationOptions": {
            // my LS initializationOptions
          }
        }
      }
    }
  }
krassowski commented 2 years ago

Could you please provide an example of initialisation options? Would you expect user to be able to modify the initializationOptions in the settings? I presume that they differ from configuration / settings, right?

henryju commented 2 years ago

My understanding is that initialization options are not intended to be user-controlled, but more a way to customize the behavior of a language server depending on the client using it. The same could be achieved using command line arguments, but I guess it can quickly become a problem if there are too many params or if trying to pass structured data.

For SonarLint LS, here are the initialization params we have today: https://github.com/SonarSource/sonarlint-vscode/blob/3ca327c4034f32ed452fb7a2ecff6e1aaa85ab0c/src/extension.ts#L209