Skip to content

[FEATURE]: Configure minimum LSP diagnostic severity level (show Warnings, not just Errors) #17869

@KKdev15

Description

@KKdev15

Feature hasn't been suggested before.

  • I have verified this feature I'm about to request hasn't been suggested before.

Describe the enhancement you want to request

Summary

Allow users to configure the minimum severity level for LSP diagnostics shown to the AI agent. Currently, only Error (severity 1) diagnostics are displayed after file edits. Warning (severity 2) and lower severity diagnostics are silently filtered out, preventing the AI agent from seeing and acting on style violations and linting issues.

Problem

Many LSP servers report style guide violations, best practices, and linting issues as Warnings rather than Errors. Since OpenCode filters these out, the AI agent cannot:

  • Follow documentation and code style guides
  • Proactively fix linting issues
  • Ensure clean, consistent code

Example 1: ubCode LSP (Sphinx-Needs / ReStructuredText)

The ubCode LSP provides linting for .rst files and Sphinx-Needs directives. After configuring it in OpenCode:

{
  "lsp": {
    "ubcode": {
      "command": ["/path/to/ubcode-lsp/python", "-m", "ubcode_lsp.cli"],
      "extensions": [".rst"]
    }
  }
}

The LSP process starts and connects correctly (verified via ps aux), but no diagnostics are shown to the AI agent after editing .rst files—even when introducing obvious errors like malformed title underlines or unknown directives. This is because ubCode reports all issues as Warnings (severity 2).

Example 2: markdownlint-lsp

The markdownlint-lsp server reports all markdown style violations as Warnings by default. The only workaround is to manually patch the npm package source code.

In lib/server.mjs (line 477):

const diagnostic = Diagnostic.create(
  { /* range */ },
  `${issue.ruleDescription} (${issue.ruleNames.join("/")})`,
  DiagnosticSeverity.Warning,  // <-- Must manually change to .Error
  issue.ruleNames[0],
  "markdownlint",
);

This workaround is fragile and breaks on every package update.

Justification

AI agents should see all relevant diagnostics to:

  1. Follow style guides — Style violations are typically reported as warnings
  2. Write clean code — Agents can proactively fix issues before they accumulate
  3. Maintain consistency — Documentation style rules (RST, Markdown) are enforced via warnings
  4. Reduce manual review — Users shouldn't have to manually check for issues the LSP already detected

Proposed Solution

Add a configuration option to control the minimum severity level:

Option A: Global setting

{
  "lsp": {
    "minSeverity": 2 // 2 = warning
  }
}

Option B: Per-LSP setting

{
  "lsp": {
    "ubcode": {
      "command": ["..."],
      "extensions": [".rst"],
      "minSeverity": 2
    },
    "markdownlint": {
      "command": ["..."],
      "extensions": [".md"],
      "minSeverity": 2
    }
  }
}

Severity levels (per LSP spec)

Value Name Description
1 Error Current default (only these are shown)
2 Warning Style violations, linting issues
3 Information Informational messages
4 Hint Suggestions

Related Issues

Environment

  • OpenCode version: latest
  • OS: Linux (Ubuntu 22.04)
  • Affected LSP servers: ubCode, markdownlint-lsp, likely many others that report warnings

Metadata

Metadata

Assignees

Labels

coreAnything pertaining to core functionality of the application (opencode server stuff)

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions