Skip to content

Commit ced5372

Browse files
committed
fix(langserver): support for clients that do not implement pull diagnostics, e.g. neovim
1 parent fbec326 commit ced5372

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

packages/language_server/src/robotcode/language_server/common/parts/diagnostics.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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(

src/robotcode/cli/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@
130130
"--debugpy-wait-for-client",
131131
is_flag=True,
132132
hidden=show_hidden_arguments(),
133+
show_envvar=True,
133134
help="Waits for a debugpy client to connect before starting the debugpy session.",
134135
)
135136
@click.version_option(version=__version__, prog_name="robotcode")

0 commit comments

Comments
 (0)