feat: client-side support for incremental diagnostics#752
Merged
mhuisi merged 3 commits intoleanprover:masterfrom Apr 15, 2026
Merged
feat: client-side support for incremental diagnostics#752mhuisi merged 3 commits intoleanprover:masterfrom
mhuisi merged 3 commits intoleanprover:masterfrom
Conversation
971e8ef to
a7ffb3a
Compare
Vtec234
approved these changes
Apr 7, 2026
Resolve conflict in leanclient.ts
3622e15 to
a306f70
Compare
ad748d0 to
3e583ff
Compare
pull Bot
pushed a commit
to VitalyAnkh/lean4
that referenced
this pull request
Apr 21, 2026
This PR adds server-side support for incremental diagnostics via a new `isIncremental` field on `PublishDiagnosticsParams` that is only used by the language server when clients set `incrementalDiagnosticSupport` in `LeanClientCapabilities`. ### Context The goal of this new feature is to avoid quadratic reporting of diagnostics. LSP has two means of reporting diagnostics; pull diagnostics (where the client decides when to fetch the diagnostics of a project) and push diagnostics (where the server decides when to update the set of diagnostics of a file in the client). Pull diagnostics have the inherent problem that clients need to heuristically decide when the set of diagnostics should be updated, and that diagnostics can only be incrementally reported per file, so the Lean language server has always stuck with push diagnostics instead. In principle, push diagnostics were also intended to only be reported once for a full file, but all major language clients also support replacing the old set of diagnostics for a file when a new set of diagnostics is reported for the same version of the file, so we have always reported diagnostics incrementally while the file is being processed in this way. However, this approach has a major limitation: all notifications must be a full set of diagnostics, which means that we have to report a quadratic amount of diagnostics while processing a file to the end. ### Semantics When `LeanClientCapabilities.incrementalDiagnosticSupport` is set, the language server will set `PublishDiagnosticsParams.isIncremental` when it is reporting a set of diagnostics that should simply be appended to the previously reported set of diagnostics instead of replacing it. Specifically, clients implementing this new feature should implement the following behaviour: - If `PublishDiagnosticsParams.isIncremental` is `false` or the field is missing, the current diagnostic report for a specific document should replace the previous diagnostic report for that document instead of appending to it. This is identical to the current behavior before this PR. - If `PublishDiagnosticsParams.isIncremental` is `true`, the current diagnostic report for a specific document should append to the previous diagnostic report for that document instead of replacing it. - Versions should be ignored when deciding whether to replace or append to a previous set of diagnostics. The language server ensures that the `isIncremental` flag is set correctly. ### Client-side implementation A client-side implementation for the VS Code extension can be found at [vscode-lean4#752](leanprover/vscode-lean4#752). --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com> Co-authored-by: Wojciech Nawrocki <13901751+Vtec234@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR adds client-side support for lean4#13260.
Currently, none of the consumers of diagnostics in the VS Code extension support incremental diagnostics, but adding client-side support for it already means that the server-side serialization overhead is reduced and we send less diagnostic data over the wire.