Skip to content

Commit dc433f9

Browse files
committed
lsp: Call workspace/diagnostic/refresh when relevant
Where we would call `sync_diagnostics` in the push model, use the same trigger to send a refresh request to the clients that support it. This should ensure diagnostics are reported in a more timely fashion.
1 parent 61733e6 commit dc433f9

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

lib/esbonio/changes/998.fix.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Improve diagnostic experience in editors like neovim which do not support `workspace/diagnostic/refresh` requests

lib/esbonio/esbonio/server/server.py

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -292,14 +292,23 @@ def get_language_at(self, document: TextDocument, position: types.Position) -> s
292292
return ""
293293

294294
def sync_diagnostics(self) -> None:
295-
"""Update the client with the currently stored diagnostics.
295+
"""Update the client with the currently stored diagnostics using
296+
a ``textDocument/publishDiagnostics`` notification.
296297
297-
When the client supports the pull diagnostics model, this is a no-op.
298+
When using the pull diagnostics model, this triggers a
299+
``workspace/diagnostic/refresh`` request instead.
298300
"""
299-
pull_support = get_capability(
300-
self.client_capabilities, "text_document.diagnostic", None
301+
diagnostic_provider = self.server_capabilities.diagnostic_provider
302+
workspace_diagnostic = get_capability(
303+
self.client_capabilities,
304+
"workspace.diagnostics",
305+
types.DiagnosticWorkspaceClientCapabilities(),
301306
)
302-
if pull_support is not None:
307+
308+
if diagnostic_provider is not None:
309+
if workspace_diagnostic.refresh_support:
310+
# Signal to the client that is should ask again for more diagnostics
311+
self.workspace_diagnostic_refresh(None)
303312
return
304313

305314
uris = {uri for _, uri in self._diagnostics.keys()}

0 commit comments

Comments
 (0)