[ty] Support publishing diagnostics in the server (#18309)

## Summary

This PR adds support for [publishing
diagnostics](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#textDocument_publishDiagnostics)
from the ty language server.

It only adds support for it for text documents and not notebook
documents because the server doesn't have full notebook support yet.

Closes: astral-sh/ty#79

## Test Plan

Testing this out in Helix and Zed since those are the two editors that I
know of that doesn't support pull diagnostics:

### Helix


https://github.com/user-attachments/assets/e193f804-0b32-4f7e-8b83-6f9307e3d2d4



### Zed



https://github.com/user-attachments/assets/93ec7169-ce2b-4521-b009-a82d8afb9eaa
This commit is contained in:
Dhruv Manilawala 2025-05-28 02:45:11 -05:00 committed by GitHub
parent 6d210dd0c7
commit 48c425c15b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 234 additions and 59 deletions

View file

@ -34,7 +34,6 @@ impl Index {
}
}
#[expect(dead_code)]
pub(super) fn text_document_urls(&self) -> impl Iterator<Item = &Url> + '_ {
self.documents
.iter()
@ -135,7 +134,7 @@ impl Index {
}
pub(super) fn open_notebook_document(&mut self, notebook_url: Url, document: NotebookDocument) {
for cell_url in document.urls() {
for cell_url in document.cell_urls() {
self.notebook_cells
.insert(cell_url.clone(), notebook_url.clone());
}