feat(lsp): use official LSP SDK and implement didSave for real-time diagnostics#91
Open
BingqingLyu wants to merge 1 commit into
Open
feat(lsp): use official LSP SDK and implement didSave for real-time diagnostics#91BingqingLyu wants to merge 1 commit into
BingqingLyu wants to merge 1 commit into
Conversation
…iagnostics - Add vscode-languageserver-protocol dependency for official LSP types - Use lsp.InitializeParams/InitializeResult/ServerCapabilities from SDK - Implement notifyDocumentSaved to trigger LSP diagnostics refresh after edits - Add client capability synchronization.didSave to register for save notifications - Store server capabilities from initialize result for capability checks
This was referenced Apr 28, 2026
Owner
Author
Conflict Group 1This PR shares modified functions with 2 other PR(s): #85, #96. These PRs should be reviewed as a batch — merging one may affect the others.
graph LR
PR91["PR #91"]
FdoStartServer_2706["doStartServer<br>LspServerManager.ts"]
PR91 -->|modifies| FdoStartServer_2706
PR85["PR #85"]
PR85 -->|modifies| FdoStartServer_2706
FexecuteSingleToolCall_1638["executeSingleToolCall<br>coreToolScheduler.ts"]
PR91 -->|modifies| FexecuteSingleToolCall_1638
PR96["PR #96"]
PR96 -->|modifies| FexecuteSingleToolCall_1638
FinitializeLspServer_2706["initializeLspServer<br>LspServerManager.ts"]
PR91 -->|modifies| FinitializeLspServer_2706
PR85 -->|modifies| FinitializeLspServer_2706
Posted by codegraph-ai conflict detection. |
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.
TLDR
Integrate official vscode-languageserver-protocol SDK for LSP types and implement textDocument/didSave notification to enable real-time diagnostics updates after file edits.
Screenshots / Video Demo
N/A — this is an internal infrastructure change. The effect is that LSP diagnostics now update immediately after edits are applied.
Dive Deeper
Problem
Previously, after applying code edits via the Edit tool, LSP diagnostics would not update until the user manually triggered a refresh. This made it difficult to verify fixes immediately.
Solution
Official LSP SDK: Added
vscode-languageserver-protocoldependency and use official types (InitializeParams,InitializeResult,ServerCapabilities) instead of custom definitions. This ensures type compatibility with the LSP specification.didSave Notification: Implemented
notifyDocumentSavedthat sendstextDocument/didSaveto LSP servers after edits. This triggers servers (like gopls, typescript-language-server) to re-read the file from disk and update their diagnostics.Capability Handling:
synchronization.didSave: truecapabilityinitializeresultgetSaveCapabilityproperly handlesTextDocumentSyncOptionsandTextDocumentSyncKindvariantsFiles Changed
types.ts: Uselsp.InitializeParams/InitializeResult/ServerCapabilitiesLspServerManager.ts: Store capabilities from initialize result, declare didSave capabilityNativeLspService.ts: ImplementnotifyDocumentSavedandgetSaveCapabilityNativeLspClient.ts: AddnotifyDocumentSavedmethodcoreToolScheduler.ts: CallnotifyDocumentSavedafter Edit tool executionTest Coverage
Added comprehensive tests for
notifyDocumentSaved:savecapability (object withincludeText)TextDocumentSyncKind.None)textDocumentSyncas number (FullorIncremental)savecapability as booleanserverNameparameterCoreToolScheduler(edit tool triggers notification)Known Limitations
typescript-language-server) do not supporttextDocument/didSave. For such servers, consider implementingdidChangenotifications or combining with PR fix(core): add LSP diagnostics caching and document refresh fallback QwenLM/qwen-code#3034'spublishDiagnosticscaching approach.Reviewer Test Plan
Verified with gopls
Tested in a single session with edit + diagnostics invoked together:
unknown field undefinedField in struct literal[ERROR] 28:28 (MissingLitField) [compiler]: unknown field undefinedFieldNo diagnostics foundThis confirms that
didSavenotification triggers gopls to re-analyze the file and update diagnostics in real-time.Testing Matrix
Linked issues / bugs
Related to QwenLM#3029 - This PR provides an alternative approach to PR QwenLM#3034 for triggering LSP diagnostics refresh after edits. While PR QwenLM#3034 uses
didClose + didOpenwithpublishDiagnosticscaching, this PR usesdidSavewhich is lighter and more semantically correct for post-edit updates. Both approaches are complementary: PR QwenLM#3034's caching is essential for push-only servers (like typescript-language-server), while this PR'sdidSaveprovides a cleaner refresh mechanism for edit operations.🤖 Generated with Qwen Code