diff options
author | Dan Willemsen <dwillemsen@google.com> | 2022-03-29 00:50:59 -0700 |
---|---|---|
committer | Dan Willemsen <dwillemsen@google.com> | 2022-03-29 00:52:27 -0700 |
commit | f10932f763d058b0dcb3acfb795c869996fef47b (patch) | |
tree | 7e04d345c214f3efac3c4b86c7ec3e831c500437 /internal/lsp/general.go | |
parent | d6d1ab63f7e2d16fb9a1f1d29755d12da90aa0bb (diff) | |
parent | e693fb417253d14786976bd29a456961aa8b6343 (diff) | |
download | golang-x-tools-f10932f763d058b0dcb3acfb795c869996fef47b.tar.gz |
Merge commit 'e693fb417253d14786976bd29a456961aa8b6343'
Change-Id: I65e50880732e718fa2264e47ef7cc19e37cc2f05
Diffstat (limited to 'internal/lsp/general.go')
-rw-r--r-- | internal/lsp/general.go | 35 |
1 files changed, 18 insertions, 17 deletions
diff --git a/internal/lsp/general.go b/internal/lsp/general.go index 3c409d3d0..a3662efd0 100644 --- a/internal/lsp/general.go +++ b/internal/lsp/general.go @@ -103,7 +103,7 @@ func (s *Server) initialize(ctx context.Context, params *protocol.ParamInitializ if dep.Path == "github.com/sergi/go-diff" && dep.Version == "v1.2.0" { if err := s.eventuallyShowMessage(ctx, &protocol.ShowMessageParams{ Message: `It looks like you have a bad gopls installation. -Please reinstall gopls by running 'GO111MODULE=on go get golang.org/x/tools/gopls@latest'. +Please reinstall gopls by running 'GO111MODULE=on go install golang.org/x/tools/gopls@latest'. See https://github.com/golang/go/issues/45732 for more information.`, Type: protocol.Error, }); err != nil { @@ -149,8 +149,8 @@ See https://github.com/golang/go/issues/45732 for more information.`, IncludeText: false, }, }, - Workspace: protocol.Workspace5Gn{ - WorkspaceFolders: protocol.WorkspaceFolders4Gn{ + Workspace: protocol.Workspace6Gn{ + WorkspaceFolders: protocol.WorkspaceFolders5Gn{ Supported: true, ChangeNotifications: "workspace/didChangeWorkspaceFolders", }, @@ -188,20 +188,17 @@ func (s *Server) initialized(ctx context.Context, params *protocol.InitializedPa } s.pendingFolders = nil + var registrations []protocol.Registration if options.ConfigurationSupported && options.DynamicConfigurationSupported { - registrations := []protocol.Registration{ - { - ID: "workspace/didChangeConfiguration", - Method: "workspace/didChangeConfiguration", - }, - { - ID: "workspace/didChangeWorkspaceFolders", - Method: "workspace/didChangeWorkspaceFolders", - }, - } - if options.SemanticTokens { - registrations = append(registrations, semanticTokenRegistration(options.SemanticTypes, options.SemanticMods)) - } + registrations = append(registrations, protocol.Registration{ + ID: "workspace/didChangeConfiguration", + Method: "workspace/didChangeConfiguration", + }) + } + if options.SemanticTokens && options.DynamicRegistrationSemanticTokensSupported { + registrations = append(registrations, semanticTokenRegistration(options.SemanticTypes, options.SemanticMods)) + } + if len(registrations) > 0 { if err := s.client.RegisterCapability(ctx, &protocol.RegistrationParams{ Registrations: registrations, }); err != nil { @@ -235,6 +232,9 @@ func (s *Server) addFolders(ctx context.Context, folders []protocol.WorkspaceFol } work := s.progress.Start(ctx, "Setting up workspace", "Loading packages...", nil, nil) snapshot, release, err := s.addView(ctx, folder.Name, uri) + if err == source.ErrViewExists { + continue + } if err != nil { viewErrors[uri] = err work.End(fmt.Sprintf("Error loading packages: %s", err)) @@ -466,7 +466,8 @@ func (s *Server) beginFileRequest(ctx context.Context, pURI protocol.DocumentURI release() return nil, nil, false, func() {}, err } - if expectKind != source.UnknownKind && fh.Kind() != expectKind { + kind := snapshot.View().FileKind(fh) + if expectKind != source.UnknownKind && kind != expectKind { // Wrong kind of file. Nothing to do. release() return nil, nil, false, func() {}, nil |