internal/lsp: handle the didChangeConfiguration message

It uses it to update the config of all active views cleanly
Fixes golang/go#32258

Change-Id: I7a849941d5022499d48ad640c5b7bc9cf79eb9b9
Reviewed-on: https://go-review.googlesource.com/c/tools/+/206148
Run-TryBot: Ian Cottrell <iancottrell@google.com>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
diff --git a/internal/lsp/server.go b/internal/lsp/server.go
index 2a4345f..bc053a5 100644
--- a/internal/lsp/server.go
+++ b/internal/lsp/server.go
@@ -113,8 +113,8 @@
 	return s.changeFolders(ctx, params.Event)
 }
 
-func (s *Server) DidChangeConfiguration(context.Context, *protocol.DidChangeConfigurationParams) error {
-	return notImplemented("DidChangeConfiguration")
+func (s *Server) DidChangeConfiguration(ctx context.Context, params *protocol.DidChangeConfigurationParams) error {
+	return s.updateConfiguration(ctx, params.Settings)
 }
 
 func (s *Server) DidChangeWatchedFiles(ctx context.Context, params *protocol.DidChangeWatchedFilesParams) error {
diff --git a/internal/lsp/workspace.go b/internal/lsp/workspace.go
index d20b9d3..1e4fa66 100644
--- a/internal/lsp/workspace.go
+++ b/internal/lsp/workspace.go
@@ -43,5 +43,14 @@
 	s.fetchConfig(ctx, name, uri, &options)
 
 	return s.session.NewView(ctx, name, uri, options)
+}
 
+func (s *Server) updateConfiguration(ctx context.Context, changed interface{}) error {
+	// go through all the views getting the config
+	for _, view := range s.session.Views() {
+		options := s.session.Options()
+		s.fetchConfig(ctx, view.Name(), view.Folder(), &options)
+		view.SetOptions(ctx, options)
+	}
+	return nil
 }