Skip to content

x/tools/gopls: didChangeConfiguration ignores the new configuration #41311

@ainar-g

Description

@ainar-g

I was trying to enable staticcheck using gopls version v0.5.0-pre1 and natebosch/vim-lsc, but couldn't. The plugin configuration was:

let g:lsc_server_commands = {
\   'go': {
\     'name': 'gopls',
\     'command': 'gopls serve',
\     'log_level': -1,
\     'suppress_stderr': v:true,
\     'workspace_config': {
\       'staticcheck': v:true,
\     },
\   },
\ }

I also used -rpc.trace and made sure that gopls actually receives the configuration with the workspace/didChangeConfiguration method. I inspected the code, and it seems like parameter changed of the server implementation is currently ignored:

func (s *Server) didChangeConfiguration(ctx context.Context, changed interface{}) error {
	// go through all the views getting the config
	for _, view := range s.session.Views() {
		options := view.Options()
		if err := s.fetchConfig(ctx, view.Name(), view.Folder(), &options); err != nil {
			return err
		}
		view, err := view.SetOptions(ctx, options)
		if err != nil {
			return err
		}
		go func() {
			snapshot, release := view.Snapshot(ctx)
			defer release()
			s.diagnoseDetached(snapshot)
		}()
	}
	return nil
}

If I enable stderr logging and add a log.Printf("%#v", changed) there, I can see, that the parameters are there:

[lsc:Error] StdErr from gopls: 2020/09/10 12:19:36 &protocol.DidChangeConfigurationParams{Settings:map[string]interface {}{"staticcheck":true}}

Is this a bug? Is there any additional information I should add?

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeToolsThis label describes issues relating to any tools in the x/tools repository.goplsIssues related to the Go language server, gopls.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions