CLI-ran SonarLint Language Server and SonarCube connection

  • Operating system: CentOS 7
  • SonarLintversion: SonarLint Language Server 2.18.0.70385
  • Programming language you’re coding in: java
  • Is connected mode used:
    • Connected to SonarCloud or SonarQube (and which version): not used

Hello! I am using SonarLint Language Server, which is launched using sonarlint.nvim, by callling ‘java -jar sonarlint-language-server.jar’ (details ommited for brevity)
I wish to connect SonarLint to my organization’s SonarCube instance. I couldn’t find any documentation regarding this, but I see that, for example, there is connected mode for VSCode plugin, that implements this functionality.
Is it possible to provide connection parameters such as ORGANZIATION_KEY and TOKEN via -D argumetns when laucnhing a language server jar? Is there any way to make this connection work with CLI-ran language server?

Thanks in advance!

Hello @shipitsoneo, and welcome to the community!

I’m sorry it took so long to respond.
In LSP, it’s a concern of the client to store configuration. And language server is supposed to request config from the client.
Providing the connection settings as JVM arguments is not possible with our LS, and generally, it’s not the best idea. Because the configuration might change while the extension is running. And likely you don’t want to stop the LS process and restart a new one with a new set of arguments on every configuration change.

So right way to do it is to securely store configs like tokens and organization keys on the client side, and support LSP methods responsible to transfer configuration to LS:
Did change configuration
Get configuration

To better understand how SonarLint features work in terms of communication between the client and language server, I suggest reviewing the files here.
You will find the corresponding code on the language server side by searching by string literals defining the methods like in this line.

I hope it helps and is still relevant.
Have a great day!

1 Like