Skip to content

Commit 91d4bdb

Browse files
kolyshkingopherbot
authored andcommitted
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 <[email protected]> Auto-Submit: Robert Findley <[email protected]> Reviewed-by: Robert Findley <[email protected]> Reviewed-by: Alan Donovan <[email protected]>
1 parent 198986d commit 91d4bdb

File tree

2 files changed

+6
-27
lines changed

2 files changed

+6
-27
lines changed

gopls/internal/golang/format.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@ import (
2121
"golang.org/x/tools/gopls/internal/cache/parsego"
2222
"golang.org/x/tools/gopls/internal/file"
2323
"golang.org/x/tools/gopls/internal/protocol"
24-
"golang.org/x/tools/gopls/internal/settings"
2524
"golang.org/x/tools/gopls/internal/util/safetoken"
2625
"golang.org/x/tools/internal/diff"
2726
"golang.org/x/tools/internal/event"
2827
"golang.org/x/tools/internal/imports"
2928
"golang.org/x/tools/internal/tokeninternal"
29+
gofumptFormat "mvdan.cc/gofumpt/format"
3030
)
3131

3232
// Format formats a file with a given range.
@@ -67,7 +67,7 @@ func Format(ctx context.Context, snapshot *cache.Snapshot, fh file.Handle) ([]pr
6767

6868
// Apply additional formatting, if any is supported. Currently, the only
6969
// supported additional formatter is gofumpt.
70-
if format := settings.GofumptFormat; snapshot.Options().Gofumpt && format != nil {
70+
if snapshot.Options().Gofumpt {
7171
// gofumpt can customize formatting based on language version and module
7272
// path, if available.
7373
//
@@ -76,17 +76,17 @@ func Format(ctx context.Context, snapshot *cache.Snapshot, fh file.Handle) ([]pr
7676
// TODO: under which circumstances can we fail to find module information?
7777
// Can this, for example, result in inconsistent formatting across saves,
7878
// due to pending calls to packages.Load?
79-
var langVersion, modulePath string
79+
var opts gofumptFormat.Options
8080
meta, err := NarrowestMetadataForFile(ctx, snapshot, fh.URI())
8181
if err == nil {
8282
if mi := meta.Module; mi != nil {
8383
if v := mi.GoVersion; v != "" {
84-
langVersion = "go" + v
84+
opts.LangVersion = "go" + v
8585
}
86-
modulePath = mi.Path
86+
opts.ModulePath = mi.Path
8787
}
8888
}
89-
b, err := format(ctx, langVersion, modulePath, buf.Bytes())
89+
b, err := gofumptFormat.Source(buf.Bytes(), opts)
9090
if err != nil {
9191
return nil, err
9292
}

gopls/internal/settings/gofumpt.go

Lines changed: 0 additions & 21 deletions
This file was deleted.

0 commit comments

Comments
 (0)