https://bugs.kde.org/show_bug.cgi?id=457944

            Bug ID: 457944
           Summary: Add LSP diagnostic code to UI
           Product: kate
           Version: Git
          Platform: Compiled Sources
                OS: Linux
            Status: REPORTED
          Severity: normal
          Priority: NOR
         Component: general
          Assignee: kwrite-bugs-n...@kde.org
          Reporter: gl.ivanov...@gmail.com
  Target Milestone: ---

SUMMARY

Language server can provide an optional `code` of a diagnostic:
https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#diagnostic
Currently Kate's LSP Client plugin does not expose this information in UI.

However, this information may be useful, at least for `clangd`
(https://clangd.llvm.org/) the diagnostic code contains machine-friendly
diagnostic code that can be used to suppress a specific diagnostic with a
`#pragma clang diagnostic ignored "-Wsomething-something"` for Clang warnings
(https://clang.llvm.org/docs/UsersManual.html#controlling-diagnostics-via-pragmas)
or with a `// NOLINT(something-something)` comment for Clang Tidy warnings
(https://clang.llvm.org/extra/clang-tidy/#suppressing-undesired-diagnostics).
Having diagnostic code in UI allows user to easily copy-paste it from LSP tab
to source file being edited.

The following patch seems to address the issue (but I've only tested it against
`clangd` language server):
```
diff --git a/addons/lspclient/lspclientpluginview.cpp
b/addons/lspclient/lspclientpluginview.cpp
index d0acbc9bb..436758d73 100644
--- a/addons/lspclient/lspclientpluginview.cpp
+++ b/addons/lspclient/lspclientpluginview.cpp
@@ -2538,6 +2538,9 @@ public:
             if (diag.source.length()) {
                 source = QStringLiteral("[%1] ").arg(diag.source);
             }
+            if (diag.code.length()) {
+                source += QStringLiteral("(%1) ").arg(diag.code);
+            }
             item->setData(diagnosticsIcon(diag.severity), Qt::DecorationRole);
             // rendering of lines with embedded newlines does not work so well
             // so ... split message by lines
```

SOFTWARE/OS VERSIONS
Linux/KDE Plasma: Ubuntu 22.04
KDE Frameworks Version: 5.92.0
Qt Version: 5.15.3

ADDITIONAL INFORMATION
Kate built from source (reports version 22.11.70)

-- 
You are receiving this mail because:
You are watching all bug changes.

Reply via email to