You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/faq.md
+42Lines changed: 42 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -1,3 +1,8 @@
1
+
# Frequently Asked Questions
2
+
3
+
**NOTE: [Debugging](debugging.md#faqs) has its own FAQ documentation.**
4
+
5
+
## Syntax highlighting doesn't seem to work.
1
6
2
7
The default syntax highlighting for Go files is provided by a
3
8
[TextMate rule](https://github.com/jeff-hykin/better-go-syntax) embedded in VS Code,
@@ -11,6 +16,43 @@ by turning on [Gopls' `ui.semanticTokens` setting](https://github.com/golang/vsc
11
16
"gopls": { "ui.semanticTokens": true }
12
17
```
13
18
19
+
## Code formatting by this extension doesn't seem to work.
20
+
21
+
When you have multiple formatter extensions, be sure to set this
22
+
extension as the default formatter for go language.
23
+
```json5
24
+
"[go]": {
25
+
"editor.defaultFormatter":"golang.go"
26
+
}
27
+
```
28
+
29
+
## How can I stop the extension from formatting files on save?
30
+
31
+
Formatting and organizing imports for Go are enabled by default. This is implemented
32
+
by setting the [language-specific editor settings](https://code.visualstudio.com/docs/getstarted/settings#_languagespecific-editor-settings), that take precedence
33
+
over user/workspace editor settings.
34
+
35
+
You can choose to disable them by configuring the following settings.
36
+
37
+
```json5
38
+
"[go]": {
39
+
"editor.formatOnSave":false,
40
+
"editor.codeActionsOnSave": {
41
+
"source.organizeImports":false
42
+
}
43
+
}
44
+
```
45
+
46
+
This decision was made a while ago to help users follow the best practice,
47
+
and to detect broken code early (e.g. unused imports causes compile errors in Go).
48
+
Unfortunately, these language-specific editor settings overriden by the
49
+
extension is not easily visible from the settings UI, and confuses users new to Go.
50
+
In the following issues, we are discussing and collecting ideas to improve
51
+
the situation without interrupting existing users.
52
+
53
+
*[`editor.formatOnSave` and `editor.codeActionsOnSave`](https://github.com/golang/vscode-go/issues/1815)
0 commit comments