Skip to content

Conversation

@Sysix
Copy link
Member

@Sysix Sysix commented Jun 2, 2025

This PR introduces the support for textDocument/diagnostics. This will be preferred over the other way around textDocument/publishDiagnostics
It is a newer concept between language server and the clients (editors).

Diagnostics are currently published by the server to the client using a notification. This model has the advantage that for workspace wide diagnostics the server has the freedom to compute them at a server preferred point in time. On the other hand the approach has the disadvantage that the server can’t prioritize the computation for the file in which the user types or which are visible in the editor. Inferring the client’s UI state from the textDocument/didOpen and textDocument/didChange notifications might lead to false positives since these notifications are ownership transfer notifications.

The specification therefore introduces the concept of diagnostic pull requests to give a client more control over the documents for which diagnostics should be computed and at which point in time.

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

For our server, we need one more feature.

The workspace/diagnostic/refresh request is sent from the server to the client. Servers can use it to ask clients to refresh all needed document and workspace diagnostics. This is useful if a server detects a project wide configuration change which requires a re-calculation of all diagnostics.

This is needed because in the current implementation we re-lint the opened files when some .oxlintrc.json configuration is changed or fix_kind server configuration. Instead of re-linting, the server will send this request to the client.


This will be a breaking change for other clients which are sending the run = onType | onSave configuration, but are supporting all needed specs for the pull diagnostics mode. The client should instead implement their own configuration and sending the textDocument/diagnostics to the server when needed.


The cargo patches are needed, because of a typo in the lsp-types project. The community created a fork and fixed it already for us: tower-lsp-community/ls-types@71ca29b
The tower-lsp-server needed an update too, or else we could not use the fixed version. I created a PR here: tower-lsp-community/tower-lsp-server#52 and used the commit ID to patch it here.

Copy link
Member Author

Sysix commented Jun 2, 2025


How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • 0-merge - adds this PR to the back of the merge queue
  • hotfix - for urgent hot fixes, skip the queue and merge this PR next

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

This stack of pull requests is managed by Graphite. Learn more about stacking.

@github-actions github-actions bot added A-editor Area - Editor and Language Server C-enhancement Category - New feature or request labels Jun 2, 2025
@codspeed-hq
Copy link

codspeed-hq bot commented Jun 2, 2025

CodSpeed Instrumentation Performance Report

Merging #11447 will not alter performance

Comparing 06-02-feat_language_server_support_textdocument_diagnostic_ (e627309) with main (4ca659c)

Summary

✅ 38 untouched benchmarks

@Sysix Sysix changed the base branch from 05-31-feat_language_server_support_workpace_diagnostic_ to graphite-base/11447 June 2, 2025 17:37
@Sysix Sysix changed the base branch from graphite-base/11447 to 05-31-feat_language_server_support_workpace_diagnostic_ June 2, 2025 17:37
@Sysix Sysix changed the base branch from 05-31-feat_language_server_support_workpace_diagnostic_ to graphite-base/11447 June 2, 2025 17:38
@Sysix Sysix changed the base branch from graphite-base/11447 to 05-31-feat_language_server_support_workpace_diagnostic_ June 2, 2025 17:38
@Sysix Sysix changed the base branch from 05-31-feat_language_server_support_workpace_diagnostic_ to graphite-base/11447 June 2, 2025 17:39
@Sysix Sysix changed the base branch from graphite-base/11447 to 05-31-feat_language_server_support_workpace_diagnostic_ June 2, 2025 17:39
@Sysix Sysix changed the base branch from 05-31-feat_language_server_support_workpace_diagnostic_ to graphite-base/11447 June 2, 2025 17:40
@Sysix Sysix changed the base branch from graphite-base/11447 to 05-31-feat_language_server_support_workpace_diagnostic_ June 2, 2025 17:40
@Sysix Sysix changed the base branch from 05-31-feat_language_server_support_workpace_diagnostic_ to graphite-base/11447 June 2, 2025 17:41
@Sysix Sysix force-pushed the 06-02-feat_language_server_support_textdocument_diagnostic_ branch from 7b4da00 to d0fbfb4 Compare June 2, 2025 17:41
@Sysix Sysix force-pushed the graphite-base/11447 branch from d384b02 to 4b057c7 Compare June 2, 2025 17:41
@Sysix Sysix changed the base branch from graphite-base/11447 to 05-31-refactor_language_server_linter_runtime_returns_fxhashmap_ June 2, 2025 17:41
@Sysix Sysix force-pushed the 06-02-feat_language_server_support_textdocument_diagnostic_ branch 2 times, most recently from ff92bd2 to 320977c Compare June 2, 2025 21:18
@Sysix Sysix force-pushed the 05-31-refactor_language_server_linter_runtime_returns_fxhashmap_ branch from 4b057c7 to 7268fc6 Compare June 2, 2025 21:18
@Sysix Sysix changed the base branch from 05-31-refactor_language_server_linter_runtime_returns_fxhashmap_ to graphite-base/11447 June 3, 2025 18:09
@Sysix Sysix force-pushed the graphite-base/11447 branch from 7268fc6 to f729734 Compare June 3, 2025 18:09
@Sysix Sysix force-pushed the 06-02-feat_language_server_support_textdocument_diagnostic_ branch from 320977c to 8440072 Compare June 3, 2025 18:09
@Sysix Sysix changed the base branch from graphite-base/11447 to main June 3, 2025 18:09
@Sysix Sysix changed the base branch from main to graphite-base/11447 June 3, 2025 19:12
@Sysix Sysix force-pushed the 06-02-feat_language_server_support_textdocument_diagnostic_ branch from 8440072 to 9b11fcc Compare June 3, 2025 19:12
@Sysix Sysix changed the base branch from graphite-base/11447 to 06-03-refactor_language_server_simplify_workspace_didchangeconfiguration_call June 3, 2025 19:12
@Sysix Sysix changed the base branch from graphite-base/11447 to 06-05-refactor_language_server_convert_only_once_uri_to_path_when_creating_serverlinter_ June 5, 2025 18:59
@Sysix Sysix force-pushed the 06-02-feat_language_server_support_textdocument_diagnostic_ branch 4 times, most recently from 07b6c68 to 4a3116e Compare June 5, 2025 20:04
@graphite-app graphite-app bot changed the base branch from 06-05-refactor_language_server_convert_only_once_uri_to_path_when_creating_serverlinter_ to graphite-base/11447 June 5, 2025 20:27
@graphite-app graphite-app bot force-pushed the graphite-base/11447 branch from f0047ac to db0b099 Compare June 5, 2025 20:30
@graphite-app graphite-app bot force-pushed the 06-02-feat_language_server_support_textdocument_diagnostic_ branch from 4a3116e to 771f995 Compare June 5, 2025 20:30
@graphite-app graphite-app bot changed the base branch from graphite-base/11447 to main June 5, 2025 20:31
@graphite-app graphite-app bot force-pushed the 06-02-feat_language_server_support_textdocument_diagnostic_ branch from 771f995 to 4df4e72 Compare June 5, 2025 20:31
@Sysix Sysix force-pushed the 06-02-feat_language_server_support_textdocument_diagnostic_ branch from 4df4e72 to 73b168d Compare June 7, 2025 11:11
@Sysix Sysix marked this pull request as ready for review June 7, 2025 11:53
@Sysix Sysix requested a review from camc314 as a code owner June 7, 2025 11:53
@Sysix Sysix force-pushed the 06-02-feat_language_server_support_textdocument_diagnostic_ branch from 73b168d to d2f513d Compare June 7, 2025 12:12
Comment on lines +291 to +294
[patch.crates-io]
# this patch has the fix for `WorkspaceClientCapabilities`, see tower-lsp-community/tower-lsp-server#50
lsp-types = { git = "https://github.com/tower-lsp-community/lsp-types", rev = "7332122ee5572c3f2c247b37cd1af77289b2e1c8" }
tower-lsp-server = { git = "https://github.com/tower-lsp-community/tower-lsp-server", rev = "27cbe421c6cdc6e9cd607abaf1ece8c060e5cd4e" }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cc @Boshen is this ok? i remember you mentioning using git tags means cargo can't cache it

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Boshen want to make sure you agree to this before, before resolving the conversation and starting the queue

@Sysix Sysix force-pushed the 06-02-feat_language_server_support_textdocument_diagnostic_ branch from d2f513d to 06f3ec3 Compare June 9, 2025 13:47
@graphite-app graphite-app bot added the 0-merge Merge with Graphite Merge Queue label Jun 12, 2025
@graphite-app
Copy link
Contributor

graphite-app bot commented Jun 13, 2025

Merge activity

  • Jun 13, 11:40 AM UTC: This pull request can not be added to the Graphite merge queue. Please try rebasing and resubmitting to merge when ready.
  • Jun 13, 11:40 AM UTC: Graphite disabled "merge when ready" on this PR due to: a merge conflict with the target branch; resolve the conflict and try again..
  • Jun 13, 11:40 AM UTC: The merge label '0-merge' was detected. This PR will be added to the Graphite merge queue once it meets the requirements.
  • Jun 19, 8:53 PM UTC: The merge label '0-merge' was detected. This PR will be added to the Graphite merge queue once it meets the requirements.
  • Jun 20, 12:27 PM UTC: This pull request can not be added to the Graphite merge queue. Please try rebasing and resubmitting to merge when ready.
  • Jun 20, 12:27 PM UTC: Graphite disabled "merge when ready" on this PR due to: a merge conflict with the target branch; resolve the conflict and try again..
  • Jun 20, 12:27 PM UTC: The merge label '0-merge' was detected. This PR will be added to the Graphite merge queue once it meets the requirements.

@Sysix Sysix force-pushed the 06-02-feat_language_server_support_textdocument_diagnostic_ branch from 06f3ec3 to e627309 Compare June 13, 2025 11:55
@Sysix Sysix removed the 0-merge Merge with Graphite Merge Queue label Jun 19, 2025
@graphite-app graphite-app bot added the 0-merge Merge with Graphite Merge Queue label Jun 19, 2025
@Sysix Sysix marked this pull request as draft August 28, 2025 20:25
@Sysix
Copy link
Member Author

Sysix commented Sep 5, 2025

After the integration with tsgolint, the client can not tell when it is the right time to request for diagnostics.
When tsgolint supports linting on memory file too, I will relook into this feature. Closing for now, but keeping the branch alive

@Sysix Sysix closed this Sep 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

0-merge Merge with Graphite Merge Queue A-editor Area - Editor and Language Server C-enhancement Category - New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants