@@ -59,6 +59,27 @@ func openInLSPs(
5959 }
6060}
6161
62+// waitForLSPDiagnostics waits briefly for diagnostics publication after a file
63+// has been opened. Intended for read-only situations where viewing up-to-date
64+// files matters but latency should remain low (i.e. when using the view tool).
65+func waitForLSPDiagnostics(
66+ ctx context.Context,
67+ manager *lsp.Manager,
68+ filepath string,
69+ timeout time.Duration,
70+) {
71+ if filepath == "" || manager == nil || timeout <= 0 {
72+ return
73+ }
74+
75+ for client := range manager.Clients().Seq() {
76+ if !client.HandlesFile(filepath) {
77+ continue
78+ }
79+ client.WaitForDiagnostics(ctx, timeout)
80+ }
81+}
82+
6283// notifyLSPs notifies LSP servers that a file has changed and waits for
6384// updated diagnostics. Use this after edit/multiedit operations.
6485func notifyLSPs(