@@ -141,11 +141,18 @@ def __init__(self, protocol: LanguageServerProtocol) -> None:
141141
142142 self .refresh_task : Optional [asyncio .Task [Any ]] = None
143143
144+ self .client_supports_pull = False
145+
144146 async def initialized (self , sender : Any ) -> None :
145147 self ._ensure_diagnostics_thread_started ()
146148
147149 self ._workspace_diagnostics_task = create_sub_task (self .run_workspace_diagnostics (), loop = self .diagnostics_loop )
148150
151+ if not self .client_supports_pull :
152+ self .parent .documents .did_open .add (self .update_document_diagnostics )
153+ self .parent .documents .did_change .add (self .update_document_diagnostics )
154+ self .parent .documents .did_save .add (self .update_document_diagnostics )
155+
149156 def extend_capabilities (self , capabilities : ServerCapabilities ) -> None :
150157 if (
151158 self .parent .client_capabilities is not None
@@ -158,6 +165,7 @@ def extend_capabilities(self, capabilities: ServerCapabilities) -> None:
158165 identifier = f"robotcodelsp_{ uuid .uuid4 ()} " ,
159166 work_done_progress = True ,
160167 )
168+ self .client_supports_pull = True
161169
162170 @property
163171 def diagnostics_loop (self ) -> asyncio .AbstractEventLoop :
@@ -486,6 +494,9 @@ def publish_diagnostics(self, document: TextDocument, diagnostics: List[Diagnost
486494 ),
487495 )
488496
497+ async def update_document_diagnostics (self , sender : Any , document : TextDocument ) -> None :
498+ self .create_document_diagnostics_task (document , True )
499+
489500 @rpc_method (name = "textDocument/diagnostic" , param_type = DocumentDiagnosticParams )
490501 @threaded ()
491502 async def _text_document_diagnostic (
0 commit comments