gopls: rm GofumptFormat from internal/settings

Since CL 612055 var GofumptFormat can never be nil, and since CL 609655
it is a very simple wrapper.

Remove it, and use mvdan.cc/gofumpt/format directly in internal/golang.

Note that this removes some documentation bits about gofumpt options, but
those are already described in internal/golang.Format inline comments.

Change-Id: Ic7d5b8412e913f2dbbc14befb978f8a4f743334a
Reviewed-on: https://go-review.googlesource.com/c/tools/+/611844
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Robert Findley <rfindley@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
diff --git a/gopls/internal/golang/format.go b/gopls/internal/golang/format.go
index 3fffbe3..8f735f3 100644
--- a/gopls/internal/golang/format.go
+++ b/gopls/internal/golang/format.go
@@ -21,12 +21,12 @@
 	"golang.org/x/tools/gopls/internal/cache/parsego"
 	"golang.org/x/tools/gopls/internal/file"
 	"golang.org/x/tools/gopls/internal/protocol"
-	"golang.org/x/tools/gopls/internal/settings"
 	"golang.org/x/tools/gopls/internal/util/safetoken"
 	"golang.org/x/tools/internal/diff"
 	"golang.org/x/tools/internal/event"
 	"golang.org/x/tools/internal/imports"
 	"golang.org/x/tools/internal/tokeninternal"
+	gofumptFormat "mvdan.cc/gofumpt/format"
 )
 
 // Format formats a file with a given range.
@@ -67,7 +67,7 @@
 
 	// Apply additional formatting, if any is supported. Currently, the only
 	// supported additional formatter is gofumpt.
-	if format := settings.GofumptFormat; snapshot.Options().Gofumpt && format != nil {
+	if snapshot.Options().Gofumpt {
 		// gofumpt can customize formatting based on language version and module
 		// path, if available.
 		//
@@ -76,17 +76,17 @@
 		// TODO: under which circumstances can we fail to find module information?
 		// Can this, for example, result in inconsistent formatting across saves,
 		// due to pending calls to packages.Load?
-		var langVersion, modulePath string
+		var opts gofumptFormat.Options
 		meta, err := NarrowestMetadataForFile(ctx, snapshot, fh.URI())
 		if err == nil {
 			if mi := meta.Module; mi != nil {
 				if v := mi.GoVersion; v != "" {
-					langVersion = "go" + v
+					opts.LangVersion = "go" + v
 				}
-				modulePath = mi.Path
+				opts.ModulePath = mi.Path
 			}
 		}
-		b, err := format(ctx, langVersion, modulePath, buf.Bytes())
+		b, err := gofumptFormat.Source(buf.Bytes(), opts)
 		if err != nil {
 			return nil, err
 		}
diff --git a/gopls/internal/settings/gofumpt.go b/gopls/internal/settings/gofumpt.go
deleted file mode 100644
index d9bf310..0000000
--- a/gopls/internal/settings/gofumpt.go
+++ /dev/null
@@ -1,21 +0,0 @@
-// Copyright 2022 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-package settings
-
-import (
-	"context"
-
-	"mvdan.cc/gofumpt/format"
-)
-
-// GofumptFormat allows the gopls module to wire in a call to
-// gofumpt/format.Source. langVersion and modulePath are used for some
-// Gofumpt formatting rules -- see the Gofumpt documentation for details.
-var GofumptFormat = func(ctx context.Context, langVersion, modulePath string, src []byte) ([]byte, error) {
-	return format.Source(src, format.Options{
-		LangVersion: langVersion,
-		ModulePath:  modulePath,
-	})
-}