internal/lsp: default to workspace module mode even with vendor dirs

We were previously opting out of workspace module mode when any module
had vendor directories. While we still haven't decided how to handle
vendoring, it simplifies things to opt experimentalWorkspaceModule users
in to the workspace module mode when they have modules with vendoring.

Temporarily require default mode for the inconsistent vendoring test
(golang/go#41819).

Fixes golang/go#41725

Change-Id: Ifa494daea51a2a3bb2e6bc3026bfb9e8118d31a3
Reviewed-on: https://go-review.googlesource.com/c/tools/+/259623
Trust: Rebecca Stambler <rstambler@golang.org>
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
diff --git a/gopls/internal/regtest/vendor_test.go b/gopls/internal/regtest/vendor_test.go
index cf2715e..b34ac33 100644
--- a/gopls/internal/regtest/vendor_test.go
+++ b/gopls/internal/regtest/vendor_test.go
@@ -38,7 +38,13 @@
 	var q int // hardcode a diagnostic
 }
 `
-	runner.Run(t, pkgThatUsesVendoring, func(t *testing.T, env *Env) {
+	// TODO(rstambler): Remove this when golang/go#41819 is resolved.
+	withOptions(
+		EditorConfig{
+			WithoutExperimentalWorkspaceModule: true,
+		},
+		WithProxyFiles(basicProxy),
+	).run(t, pkgThatUsesVendoring, func(t *testing.T, env *Env) {
 		env.OpenFile("a/a1.go")
 		env.Await(
 			// The editor should pop up a message suggesting that the user
@@ -58,5 +64,5 @@
 				DiagnosticAt("a/a1.go", 6, 5),
 			),
 		)
-	}, WithProxyFiles(basicProxy))
+	})
 }
diff --git a/internal/lsp/cache/view.go b/internal/lsp/cache/view.go
index 5af7801..2679503 100644
--- a/internal/lsp/cache/view.go
+++ b/internal/lsp/cache/view.go
@@ -1044,7 +1044,7 @@
 	if fi, err := os.Stat(filepath.Join(v.rootURI.Filename(), "vendor")); err != nil || !fi.IsDir() {
 		return true, nil
 	}
-	vendorEnabled := modFile.Go.Version != "" && semver.Compare("v"+modFile.Go.Version, "v1.14") >= 0
+	vendorEnabled := modFile.Go != nil && modFile.Go.Version != "" && semver.Compare("v"+modFile.Go.Version, "v1.14") >= 0
 	return !vendorEnabled, nil
 }
 
@@ -1068,13 +1068,6 @@
 	if options.TempModfile && ws.goversion >= 14 {
 		mode |= tempModfile
 	}
-	// Don't default to multi-workspace mode if one of the modules contains a
-	// vendor directory. We still have to decide how to handle vendoring.
-	for _, mod := range modules {
-		if info, _ := os.Stat(filepath.Join(mod.rootURI.Filename(), "vendor")); info != nil {
-			return mode
-		}
-	}
 	// If the user is intentionally limiting their workspace scope, don't
 	// enable multi-module workspace mode.
 	// TODO(rstambler): This should only change the calculation of the root,