Skip to content

Commit a5e5fed

Browse files
committed
internal/lsp: stop showing workspace misconfiguration message
This is helpful for users to diagnose issues, but it annoys people who have workspaces with both non-Go and Go projects. I'm going to spend some more time thinking about this, particularly about which error messages we should retry the initial workspace load for. Updates golang/go#32394 Change-Id: I7d02b385da232914fe7342837dc3a9c4185399fd Reviewed-on: https://go-review.googlesource.com/c/tools/+/225237 Reviewed-by: Heschi Kreinick <[email protected]>
1 parent 6fb6f5a commit a5e5fed

File tree

2 files changed

+1
-19
lines changed

2 files changed

+1
-19
lines changed

internal/lsp/diagnostics.go

+1-16
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ package lsp
66

77
import (
88
"context"
9-
"fmt"
109
"strings"
1110
"sync"
1211

@@ -62,7 +61,7 @@ func (s *Server) diagnose(ctx context.Context, snapshot source.Snapshot, alwaysA
6261
return nil
6362
}
6463
if err != nil {
65-
event.Error(ctx, "diagnose: could not generate diagnostics for go.mod file", err)
64+
event.Error(ctx, "diagnose: could not generate diagnostics for go.mod file", err, tag.Directory.Of(snapshot.View().Folder))
6665
}
6766
// Ensure that the reports returned from mod.Diagnostics are only related to the
6867
// go.mod file for the module.
@@ -85,21 +84,7 @@ func (s *Server) diagnose(ctx context.Context, snapshot source.Snapshot, alwaysA
8584
if ctx.Err() != nil {
8685
return nil
8786
}
88-
// If we encounter a genuine error when getting workspace packages,
89-
// notify the user that their workspace may be misconfigured.
9087
if err != nil {
91-
// TODO(golang/go#37971): Remove this guard.
92-
if !snapshot.View().ValidBuildConfiguration() {
93-
s.showedInitialErrorMu.Lock()
94-
if !s.showedInitialError {
95-
err := s.client.ShowMessage(ctx, &protocol.ShowMessageParams{
96-
Type: protocol.Error,
97-
Message: fmt.Sprintf("Your workspace is misconfigured: %s. Please see https://github.com/golang/tools/blob/master/gopls/doc/troubleshooting.md for more information or file an issue (https://github.com/golang/go/issues/new) if you believe this is a mistake.", err.Error()),
98-
})
99-
s.showedInitialError = err == nil
100-
}
101-
s.showedInitialErrorMu.Unlock()
102-
}
10388
event.Error(ctx, "diagnose: no workspace packages", err, tag.Snapshot.Of(snapshot.ID()), tag.Directory.Of(snapshot.View().Folder))
10489
return nil
10590
}

internal/lsp/server.go

-3
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,6 @@ type Server struct {
7474
deliveredMu sync.Mutex
7575
delivered map[span.URI]sentDiagnostics
7676

77-
showedInitialError bool
78-
showedInitialErrorMu sync.Mutex
79-
8077
// diagnosticsSema limits the concurrency of diagnostics runs, which can be expensive.
8178
diagnosticsSema chan struct{}
8279

0 commit comments

Comments
 (0)