ZIm/crates/collab/src
Vitaly Slobodin 7aa70a4858
lsp: Implement support for the textDocument/diagnostic command (#19230)
Closes [#13107](https://github.com/zed-industries/zed/issues/13107)

Enabled pull diagnostics by default, for the language servers that
declare support in the corresponding capabilities.

```
"diagnostics": {
    "lsp_pull_diagnostics_debounce_ms": null
}
```
settings can be used to disable the pulling.

Release Notes:

- Added support for the LSP `textDocument/diagnostic` command.

# Brief

This is draft PR that implements the LSP `textDocument/diagnostic`
command. The goal is to receive your feedback and establish further
steps towards fully implementing this command. I tried to re-use
existing method and structures to ensure:

1. The existing functionality works as before
2. There is no interference between the diagnostics sent by a server and
the diagnostics requested by a client.

The current implementation is done via a new LSP command
`GetDocumentDiagnostics` that is sent when a buffer is saved and when a
buffer is edited. There is a new method called `pull_diagnostic` that is
called for such events. It has debounce to ensure we don't spam a server
with commands every time the buffer is edited. Probably, we don't need
the debounce when the buffer is saved.

All in all, the goal is basically to get your feedback and ensure I am
on the right track. Thanks!


## References

1.
https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#textDocument_pullDiagnostics

## In action

You can clone any Ruby repo since the `ruby-lsp` supports the pull
diagnostics only.

Steps to reproduce:

1. Clone this repo https://github.com/vitallium/stimulus-lsp-error-zed
2. Install Ruby (via `asdf` or `mise).
4. Install Ruby gems via `bundle install`
5. Install Ruby LSP with `gem install ruby-lsp`
6. Check out this PR and build Zed
7. Open any file and start editing to see diagnostics in realtime.



https://github.com/user-attachments/assets/0ef6ec41-e4fa-4539-8f2c-6be0d8be4129

---------

Co-authored-by: Kirill Bulatov <mail4score@gmail.com>
Co-authored-by: Kirill Bulatov <kirill@zed.dev>
2025-06-05 19:42:52 +00:00
..
api collab: Return subscription period from GET /billing/subscriptions (#31987) 2025-06-03 15:29:08 +00:00
bin windows: Make collab run on Windows (#23117) 2025-01-17 09:39:13 +02:00
db Add channel reordering functionality (#31833) 2025-06-04 16:56:33 +00:00
llm Add overdue invoices check (#31290) 2025-05-23 20:02:02 +00:00
rpc Use anyhow more idiomatically (#31052) 2025-05-20 23:06:07 +00:00
stripe_client collab: Fix deserialization of create meter event response (#31982) 2025-06-03 15:23:38 +00:00
tests lsp: Implement support for the textDocument/diagnostic command (#19230) 2025-06-05 19:42:52 +00:00
api.rs collab: Add GET /users/look_up endpoint (#31059) 2025-05-21 01:29:16 +00:00
auth.rs Use anyhow more idiomatically (#31052) 2025-05-20 23:06:07 +00:00
cents.rs Send llm events to snowflake too (#21091) 2024-11-22 20:40:39 -07:00
completion.rs Supermaven (#10788) 2024-05-03 12:50:42 -07:00
db.rs Add channel reordering functionality (#31833) 2025-06-04 16:56:33 +00:00
env.rs Use anyhow more idiomatically (#31052) 2025-05-20 23:06:07 +00:00
errors.rs Remove more unused code related to GitHub auth and errors 2022-04-21 08:57:49 -06:00
executor.rs chore: Prepare for Rust edition bump to 2024 (without autofix) (#27791) 2025-03-31 20:10:36 +02:00
lib.rs collab: Use StripeClient in sync_subscription (#31761) 2025-05-30 16:08:58 +00:00
llm.rs collab: Remove GET /billing/monthly_spend endpoint (#31123) 2025-05-21 21:30:12 +00:00
main.rs Use anyhow more idiomatically (#31052) 2025-05-20 23:06:07 +00:00
migrations.rs Use anyhow more idiomatically (#31052) 2025-05-20 23:06:07 +00:00
rpc.rs lsp: Implement support for the textDocument/diagnostic command (#19230) 2025-06-05 19:42:52 +00:00
seed.rs feature_flags: Remove remoting feature flag (#29390) 2025-04-25 03:41:11 +00:00
stripe_billing.rs collab: Use StripeClient in sync_subscription (#31761) 2025-05-30 16:08:58 +00:00
stripe_client.rs collab: Use StripeClient in sync_subscription (#31761) 2025-05-30 16:08:58 +00:00
tests.rs collab: Introduce StripeClient trait to abstract over Stripe interactions (#31615) 2025-05-28 18:34:44 +00:00
user_backfiller.rs Use anyhow more idiomatically (#31052) 2025-05-20 23:06:07 +00:00