Add initial inline diagnostics support (#25297)

https://github.com/user-attachments/assets/eb881707-e575-47ef-9ae0-67d8085d8065

Closes https://github.com/zed-industries/zed/pull/22668
Closes https://github.com/zed-industries/zed/issues/4901

Takes https://github.com/zed-industries/zed/pull/22668 and fixes all
review items on top.
Inline diagnostics are disabled by default, but can be enabled via
settings permanently, or temporarily toggled with the `editor:
ToggleInlineDiagnostics` action and the corresponding editor menu item
<img width="242" alt="image"
src="https://github.com/user-attachments/assets/8e177511-4626-4434-902b-d6aa4d3fafd0"
/>

Inline diagnostics does not show currently active diagnostics group, as
it gets inline into the editor too, inside the text.
Inline git blame takes precedence and is shown instead of the
diagnostics, edit predictions dim the diagnostics if located on the same
line.

One notable drawback of the implementation is the inability to wrap,
making inline diagnostics cut off the right side:


![image](https://github.com/user-attachments/assets/6e87268a-b51a-4a2b-8b8d-01d932c62fea)

(same as inline git blame and other elements to the right of the text)
Given that it's disabled by default and go to next/prev diagnostics will
show them better, seems fine to leave in the first iteration.


Release Notes:

- Added initial inline diagnostics support

---------

Co-authored-by: Paul J. Davis <paul.davis@tiledb.com>
Co-authored-by: Danilo Leal <daniloleal09@gmail.com>
This commit is contained in:
Kirill Bulatov 2025-02-21 01:39:47 +02:00 committed by GitHub
parent 74c581b9f4
commit 5ae93ce68d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 579 additions and 81 deletions

View file

@ -1204,6 +1204,112 @@ To interpret all `.c` files as C++, files called `MyLockFile` as TOML and files
}
```
## Diagnostics
- Description: Configuration for diagnostics-related features.
- Setting: `diagnostics`
- Default:
```json
{
"diagnostics": {
"include_warnings": true,
"inline": {
"enabled": false
}
"update_with_cursor": false,
"primary_only": false,
"use_rendered": false,
}
}
```
### Inline Diagnostics
- Description: Whether or not to show diagnostics information inline.
- Setting: `inline`
- Default:
```json
{
"diagnostics": {
"inline": {
"enabled": false,
"update_debounce_ms": 150,
"padding": 4,
"min_column": 0,
"max_severity": null
}
}
}
```
**Options**
1. Enable inline diagnostics.
```json
{
"diagnostics": {
"inline": {
"enabled": true
}
}
}
```
2. Delay diagnostic updates until some time after the last diagnostic update.
```json
{
"diagnostics": {
"inline": {
"enabled": true,
"update_debounce_ms": 150
}
}
}
```
3. Set padding between the end of the source line and the start of the diagnostic.
```json
{
"diagnostics": {
"inline": {
"enabled": true,
"padding": 4
}
}
}
```
4. Horizontally align inline diagnostics at the given column.
```json
{
"diagnostics": {
"inline": {
"enabled": true,
"min_column": 80
}
}
}
```
5. Show only warning and error diagnostics.
```json
{
"diagnostics": {
"inline": {
"enabled": true,
"max_severity": "warning"
}
}
}
```
## Git
- Description: Configuration for git-related features.