A Zed extension that integrates SonarLint static code analysis for Java projects.
- Static Code Analysis: Real-time detection of bugs, vulnerabilities, and code smells in Java code
- Automatic Setup: Downloads and configures SonarLint language server automatically
- Cross-Platform: Works on Windows, macOS, and Linux
- Java Runtime Detection: Automatically finds and uses system Java installations
- Comprehensive Rule Set: Supports all SonarLint Java analyzers
- Java 8 or later: SonarLint requires a Java Runtime Environment (JRE) to operate
- Zed Editor: This extension is designed for the Zed code editor
- Add this extension to your Zed extensions directory
- Restart Zed
- Open a Java project - the extension will automatically download and configure SonarLint
This extension:
- Downloads SonarLint: Automatically downloads the SonarLint VSCode extension and extracts the language server components
- Detects Java: Finds your system Java installation or uses JAVA_HOME
- Launches Language Server: Starts the SonarLint language server with appropriate Java analyzers
- Provides Analysis: Integrates with Zed's LSP system to show diagnostics and suggestions
The extension uses default SonarLint configuration with:
- Telemetry disabled
- Standard Java test file patterns
- Default rule set enabled
To connect to a SonarQube server or SonarCloud, create a .sonarlint/settings.json
file in your project root or add configuration to .zed/settings.json
:
{
"sonarlint": {
"connectedMode": {
"connections": {
"sonarqube": [
{
"serverUrl": "https://your-sonarqube-server.com",
"token": "your-user-token",
"connectionId": "my-sonarqube"
}
]
},
"project": {
"connectionId": "my-sonarqube",
"projectKey": "your-project-key"
}
}
}
}
{
"sonarlint": {
"connectedMode": {
"connections": {
"sonarcloud": [
{
"token": "your-sonarcloud-token",
"organizationKey": "your-organization",
"connectionId": "my-sonarcloud"
}
]
},
"project": {
"connectionId": "my-sonarcloud",
"projectKey": "your-project-key"
}
}
}
}
- Quality Profiles: Uses the same rules and configuration as your SonarQube/SonarCloud project
- Issue Suppressions: Respects False Positive and Won't Fix issue statuses
- Custom Rules: Access to organization-specific rules and configurations
- Taint Analysis: Advanced security vulnerability detection
- Team Synchronization: Shared project settings across team members
-
Generate User Token:
- SonarQube: Go to User Settings → Security → Generate Token
- SonarCloud: Go to My Account → Security → Generate Token
-
Find Project Key: Available in your SonarQube/SonarCloud project dashboard
-
Configure Connection: Add the configuration to your project settings
-
Team Sharing: Commit the configuration file (without tokens) and have team members add their personal tokens
See the examples/
directory for complete configuration examples:
examples/sonarlint-settings.json
- Place in.sonarlint/settings.json
examples/zed-settings.json
- Place in.zed/settings.json
The extension loads configuration in this order (first found wins):
.sonarlint/settings.json
in project rootsonarlint
section in.zed/settings.json
- Default standalone configuration
.zed/sonarlint/
├── sonarlint.vsix # Downloaded VSCode extension
├── server/
│ └── sonarlint-ls.jar # SonarLint language server
└── analyzers/
├── sonarjava.jar # Java analyzer
└── [other analyzers] # Additional language analyzers
To build the extension:
cargo build --release
To test:
cargo check
- Language Server Protocol: Uses SonarLint's LSP implementation
- Artifact Source: Downloads from VS Code marketplace
- Java Detection: Supports system Java, JAVA_HOME, and common installation paths
- Architecture: Rust-based extension following Zed's extension patterns
If you get "Java runtime not found" errors:
- Install Java 8 or later
- Ensure
java
is in your PATH, or - Set the
JAVA_HOME
environment variable
- Check Zed's extension logs
- Verify Java installation with
java -version
- Ensure internet connectivity for initial download
Contributions are welcome! Please follow the existing code style and add tests for new features.
This extension follows the same licensing as the underlying SonarLint components.