diff --git a/internal/lsp/general.go b/internal/lsp/general.go index dacce21351..003aef7cff 100644 --- a/internal/lsp/general.go +++ b/internal/lsp/general.go @@ -41,9 +41,18 @@ func (s *Server) initialize(ctx context.Context, params *protocol.ParamInitializ source.SetOptions(&options, params.InitializationOptions) options.ForClientCapabilities(params.Capabilities) + // gopls only supports URIs with a file:// scheme. Any other URIs will not + // work, so fail to initialize. See golang/go#40272. if params.RootURI != "" && !params.RootURI.SpanURI().IsFile() { return nil, fmt.Errorf("unsupported URI scheme: %v (gopls only supports file URIs)", params.RootURI) } + for _, folder := range params.WorkspaceFolders { + uri := span.URIFromURI(folder.URI) + if !uri.IsFile() { + return nil, fmt.Errorf("unsupported URI scheme: %q (gopls only supports file URIs)", folder.URI) + } + } + s.pendingFolders = params.WorkspaceFolders if len(s.pendingFolders) == 0 { if params.RootURI != "" {