src/goTools.ts: recognize gofumpt, gofumports formatters

gofumpt and gofumports can be used as drop-in replacements of
gofmt and goimports, so we directed users to utilize
`"go.alternateTools"`
(https://github.com/mvdan/gofumpt#installation)

However, this is pretty convoluted and less user-friendly.
As more users are adopting gofumpt and gofumports,
promote them as officially recognized formatters.

It would be ideal if the extension allows to choose
any formatter as long as the tool follows a certain spec,
but we are not there yet. And, as we are moving towards
using the language server as the formatter, this setting
will become obsolete.

Updates golang/vscode-go#587

Change-Id: Ib1fc5c91c0d6fc7fed37132c6cbd0dfa44b6a08b
Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/252922
Run-TryBot: Hyang-Ah Hana Kim <hyangah@gmail.com>
TryBot-Result: kokoro <noreply+kokoro@google.com>
Reviewed-by: Suzy Mueller <suzmue@golang.org>
diff --git a/docs/settings.md b/docs/settings.md
index 754eff9..7634e3f 100644
--- a/docs/settings.md
+++ b/docs/settings.md
@@ -178,9 +178,9 @@
 
 ### `go.formatTool`
 
-Not applicable when using the language server. Choosing 'goimports' or 'goreturns' will add missing imports and remove unused imports.
+Not applicable when using the language server. Choosing 'goimports', 'goreturns', or 'gofumports' will add missing imports and remove unused imports.
 
-Allowed Values:`[gofmt goimports goreturns goformat]`
+Allowed Values:`[gofmt goimports goreturns goformat gofumpt gofumports]`
 
 Default: `goreturns`
 
diff --git a/package.json b/package.json
index fcba719..02b740c 100644
--- a/package.json
+++ b/package.json
@@ -1236,13 +1236,15 @@
         "go.formatTool": {
           "type": "string",
           "default": "goreturns",
-          "description": "Not applicable when using the language server. Choosing 'goimports' or 'goreturns' will add missing imports and remove unused imports.",
+          "description": "Not applicable when using the language server. Choosing 'goimports', 'goreturns', or 'gofumports' will add missing imports and remove unused imports.",
           "scope": "resource",
           "enum": [
             "gofmt",
             "goimports",
             "goreturns",
-            "goformat"
+            "goformat",
+            "gofumpt",
+            "gofumports"
           ]
         },
         "go.formatFlags": {
diff --git a/src/goFormat.ts b/src/goFormat.ts
index 8ad78d7..7810c04 100644
--- a/src/goFormat.ts
+++ b/src/goFormat.ts
@@ -34,7 +34,7 @@
 		}
 
 		// Fix for https://github.com/Microsoft/vscode-go/issues/613 and https://github.com/Microsoft/vscode-go/issues/630
-		if (formatTool === 'goimports' || formatTool === 'goreturns') {
+		if (formatTool === 'goimports' || formatTool === 'goreturns' || formatTool === 'gofumports') {
 			formatFlags.push('-srcdir', filename);
 		}
 
diff --git a/src/goTools.ts b/src/goTools.ts
index 0153fe3..0e1941a 100644
--- a/src/goTools.ts
+++ b/src/goTools.ts
@@ -273,6 +273,18 @@
 		isImportant: true,
 		description: 'Go to definition & text shown on hover'
 	},
+	'gofumports': {
+		name: 'gofumports',
+		importPath: 'mvdan.cc/gofumpt/gofumports',
+		isImportant: false,
+		description: 'Formatter'
+	},
+	'gofumpt': {
+		name: 'gofumpt',
+		importPath: 'mvdan.cc/gofumpt',
+		isImportant: false,
+		description: 'Formatter'
+	},
 	'goimports': {
 		name: 'goimports',
 		importPath: 'golang.org/x/tools/cmd/goimports',