Skip to main content
Back to Extensions Directory
coc.nvim fallback icon

coc-sonarlint

asmodeus812

Coc sonar lint language server extension client

Installation CommandVim prompt
:CocInstall coc-sonarlint
GitHub owner
asmodeus812
Version
v1.0.27
npm package
coc-sonarlint
Requirements
coc ^0.0.82
License
MIT
Repository
GitHub
npm latest published 2026-11-21Registry summary

Published Package Summary

coc-sonarlint

SonarQube for IDE (formerly SonarLint) for coc.nvim. It runs the SonarLint language server of Sonar and reports quality and security issues while you type, in C, C++, Java, Go, JavaScript, TypeScript, Python, PHP, HTML, CSS, YAML/JSON (CloudFormation, Kubernetes, Azure Resource Manager), and secrets in any file. With Connected Mode it uses the rule sets and project settings of a SonarQube Server or SonarQube Cloud project.

Rule descriptions, hotspot details and connection details open as styled, syntax-highlighted text in a reusable split or floating window, rendered like a browser would: the same stylesheets as in VS Code, tabs and framework selectors you can toggle with <CR>, links that show their address, all linked to your colorscheme.

Using it inside Neovim (commands, diagnostics, code actions, description views, findings, hotspots) is described in :help coc-sonarlint, available once the extension is active. This README covers requirements, installation, setup, settings and troubleshooting.

Requirements

  • Neovim with coc.nvim 0.0.82 or later.
  • A Java Runtime (JRE) 17 or later to run the language server.
  • For JavaScript and TypeScript: Node.js above 20.12.0, or 22.11.0 or later.
  • For C and C++: a compile_commands.json compilation database.
  • For Java: coc-java or a compatible extension.

Installation

:CocInstall coc-sonarlint

The language server and the analyzers ship with the extension. The extension starts when you open a file of a supported language or a workspace that contains a .sonar.properties file (see :help coc-sonarlint-start).

Rule, hotspot and connection descriptions render like a browser page when the optional coc-htmlview extension is installed (recommended); without it they open in a built-in renderer that works in Vim and Neovim: a scratch buffer in a float (Neovim) or split (Vim) laid out like a browser with its default styles, with switchable tabs (<CR>, ]c/[c), links (<CR>/gx, <Tab>) and q to close, but without the stylesheets, capsules and code syntax colors (see :help coc-sonarlint-view-builtin):

:CocInstall https://github.com/asmodeus812/coc-htmlview

Setup

Java runtime

The language server needs Java 17 or later. The extension uses the first one it finds:

  1. The sonarlint.ls.javaHome setting, for example:
{
    "sonarlint.ls.javaHome": "/usr/lib/jvm/java-17-openjdk"
}
  1. A JRE bundled in the jre/ folder of the extension.
  2. The JDK_HOME environment variable.
  3. The JAVA_HOME environment variable.
  4. A Java installation found on the system (the PATH).

If the setting points to a missing folder or to a folder without bin/java, the extension logs this to the SonarLint output and tries the next source. If no Java 17+ is found, it offers to download a JRE that only SonarLint uses (command SonarLint.InstallManagedJre). Extra JVM arguments go in sonarlint.ls.vmargs, for example -Xmx1024m.

JavaScript and TypeScript

Analysis needs Node.js above 20.12.0, or 22.11.0 or later. The extension finds Node itself; to set it explicitly:

{
    "sonarlint.pathToNodeExecutable": "/home/yourname/.nvm/versions/node/v22.11.0/bin/node"
}

C and C++

C and C++ analysis needs a compile_commands.json compilation database from your build system:

{
    "sonarlint.pathToCompileCommands": "/home/yourname/repos/proj/compile_commands.json"
}

The command SonarLint.ConfigureCompilationDatabase lets you pick one of the compile_commands.json files in the workspace. With the Microsoft compiler, the environment must be ready to build the code. If no database is configured, you get a warning, see Troubleshooting.

Java projects

Java analysis needs coc-java (or a compatible extension), which provides the classpath of the project.

Connected Mode

Connected Mode applies the rules and settings of a SonarQube Server or SonarQube Cloud project to your local workspace. You configure two things: a connection to the server and a binding of the workspace folder to a project on it. Bind one local project to one remote project where you can.

  1. Create a user token on the server. Project tokens have fewer permissions and some features do not work with them. Add the connection to your global settings (:CocConfig); connectionId is a unique name you choose:
"sonarlint.connectedMode.connections.sonarqube": [
    {
        "serverUrl": "http://localhost:9000",
        "token": "<your-user-token>",
        "connectionId": "sonar-local"
    }
],
  1. Bind the workspace folder in its local settings (:CocLocalConfig). projectKey is the key you gave the project when you created it on the server, here organization my_org and project sonar-demo:
"sonarlint.connectedMode.project": {
    "connectionId": "sonar-local",
    "projectKey": "my_org_sonar-demo"
}

Instead of step 2 you can add a sonar-project.properties file (or .sonarcloud.properties, same content) to the workspace. The workspace is then bound to that project key automatically. The file is also needed for the first scan of a project:

sonar.projectKey=my_org_sonar-demo
sonar.organization=my_org
sonar.projectName=sonar-demo
sonar.sources=src
sonar.exclusions=**/__pycache__/**,**/*.md

Local server

You can run SonarQube locally with Docker. The server image is sonarqube:lts-community and the scanner image is sonarsource/sonar-scanner-cli.

  1. Start the server with the docker-compose.yml of this repository: docker-compose up -d.
  2. Open http://localhost:9000, log in with admin/admin, create a project and a user token.
  3. Scan the project once (or let the server import it from GitHub or another platform) with sonar-scan.sh from this repository. Run it from the project folder (for a monorepo, its root); it reads the project key, name and organization from sonar-project.properties:
cd my-project-to-scan
./path-to-sonar-scan-script/sonar-scan.sh --token "<usr-token>" --host http://localhost:9000

The scanner runs in a throwaway container, uploads the code and the server analyzes it.

Troubleshooting

  • Nothing is reported: check that the extension is active (:CocList extensions) and open the log with SonarLint.ShowSonarLintOutput. SonarLint.EnableLogsAndShowOutput turns on verbose logs and opens the log.
  • The server does not start, or "The Java Runtime Environment can not be located. ...": no usable Java 17+ was found (see Java runtime). Choose "Let Sonarlint download the JRE", or set sonarlint.ls.javaHome to a Java 17+ home: the folder that contains bin/java, not bin.
  • No JavaScript or TypeScript issues: set sonarlint.pathToNodeExecutable to a supported Node.
  • "SonarLint might be unable to analyze C and C++ file(s) because there is no configured compilation database.": set sonarlint.pathToCompileCommands, or choose "Configure compile commands now". "Ask me later again" hides it for this session, "Do not ask for this workspace" and "Never ask or prompt me again" turn it off for the workspace or for good.
  • "Connection to '...' failed: Please verify your token.": the token in the connection settings is not valid for the server. Create a new user token.
  • To see the traffic between coc.nvim and the server, set sonarlint.trace.server to verbose.

Development

npm install
npm run build
npm run watch    # rebuild on change

License

Copyright 2017-2025 SonarSource.

Licensed under the GNU Lesser General Public License, Version 3.0

Read the complete README
  • Coc sonar lint language server extension client
Activation Events
  • onLanguage:c
  • onLanguage:cpp
  • onLanguage:cuda
  • onLanguage:yaml
  • onLanguage:json
  • onLanguage:jsonc
  • onLanguage:objc
  • onLanguage:objcpp
  • onLanguage:opencl
  • onLanguage:objective-c
  • onLanguage:objective-cpp
  • onLanguage:php
  • onLanguage:java
  • onLanguage:cs
  • onLanguage:vb
  • onLanguage:css
  • onLanguage:less
  • onLanguage:scss
  • onLanguage:go
  • onLanguage:gomod
  • onLanguage:python
  • onLanguage:jupyter
  • onLanguage:jsx-tags
  • onLanguage:javascript
  • onLanguage:javascriptreact
  • onLanguage:javascript.jsx
  • onLanguage:typescript
  • onLanguage:typescript.tsx
  • onLanguage:typescript.jsx
  • onLanguage:typescriptreact
  • workspaceContains:.sonar.properties
Developer Resources

Want to build, test, or contribute to coc.nvim extensions? Explore our official SDK and testing toolkits.

Open Developer Guide

Version History

This published npm package does not include a history.md or changelog.md file. Browse its npm versions or repository releases for available release information.