Integrating SonarLint with the Sublime Text LSP package

I am in the process of creating a SonarLint helper package for the LSP package. It would be much appreciated if someone could point me in the right direction with two problems I’m having.

Clarify workspace/didChangeConfiguration settings structure

This language server has at least two “commands” for which it expects the LSP client to handle them that I know of.

  • SonarLint.OpenRuleDesc: should render HTML, I’ve got this under control.
  • SonarLint.DeactivateRule: should deactivate a rule. This is what I’m having trouble with.

I don’t understand the exact settings structure that this language server expects to see in the workspace/didChangeConfiguration notification. Can anyone describe the structure? In particular, what structure should it have to be able to understand disabled rules?

Document custom requests and notifications

I cannot find a list of this server’s custom requests and notifications. I see at least three here: https://github.com/SonarSource/sonarlint-vscode/blob/master/src/client.ts

But I don’t know what they are supposed to do. Can anyone describe these?

Hello, welcome to the community! And thank you for your question.

First, I’d like to mention that the SonarLint language server is mainly used by the SonarLint for VSCode extension. We test it quite extensively with VSCode, and I cannot guarantee that it will behave correctly with other implementations of the LSP.

This being said:

  • The expected settings structure is described in the README and package.json of SonarLint for VSCode; here is a more complete sample on rule (de)activation:
{
  "sonarlint.rules": {
    "javascript:S1440": {
      "level": "on" // This activates a rule that is not active by default
    },
    "javascript:S3776": {
      "level": "on",
      "parameters": { // For rules that declare parameters
        "threshold": "10"
      }
    },
    "javascript:S878" {
      "level": "off" // This deactivates a rule that is active by default
    }
  }
}
  • The server’s custom requests are also declared in SonarLintExtendedLanguageServer.java
    • listAllRules returns the list of all rules known to the language server (i.e all those declared by the underlying analyzers), grouped by language. In VSCode, this is used to show the “SonarLint Rules” tree view
      image

    • didClasspathUpdate and didJavaServerModeChange are specific to the support of Java and rely on features provided by vscode-java to react to project configuration and classpath changes. You can have a look at sonarlint-vscode's java.ts.


For a first version, I would strongly advise that you restrict available languages to Python, PHP and HTML - this will lower the number of moving pieces.

Once you have those, adding correct support for JS and TS might be a good second step, since the JS/TS analyzer relies on the availability of a Node.js runtime.

Proper support for Java is a bit tricky, since there is a bit of back and forth between the SonarLint LS and the JDT LS, which in VSCode is handled by the client side of SonarLint VSCode.