Skip to content

Commit 5659cbc

Browse files
committed
docs/faq.md: entries on formatting issues
And add back the title that was dropped by accident. Updates #2268 Updates #1815 Updates #1805 Change-Id: Iea464b1e54f0eb5d421d28c7bea40a86e49dc517 Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/412054 Reviewed-by: Jamal Carvalho <[email protected]>
1 parent 8bc0703 commit 5659cbc

File tree

2 files changed

+42
-21
lines changed

2 files changed

+42
-21
lines changed

docs/_Sidebar.md

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

docs/faq.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff 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.
16

27
The default syntax highlighting for Go files is provided by a
38
[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
1116
"gopls": { "ui.semanticTokens": true }
1217
```
1318

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)
54+
* [`editor.suggest.snippetsPreventQuickSuggestions`](https://github.com/golang/vscode-go/issues/1805)
55+
1456
<!-- Topics
1557
* The extension deletes my code on save?
1658
* Help! The extension does not find 'go'.

0 commit comments

Comments
 (0)