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
docs/features.md: discuss default formatting behavior and template support
We already have a section in the advanced.md doc abount default formatting
and imports behavior. I hope this additional reference helps users to discover
the control knob.
Didn't mention completion, diagnostics for Go template files yet.
We need to update the diagnostics section to discuss gopls's diagnostics
feature.
Updates golang#609
Change-Id: Ib2e695d847c56bd4f562d91d2938cb5c1a032764
*[Toggle between code and tests](#toggle-between-code-and-tests)
18
+
*[Syntax Highlighting](#syntax-highlighting)
18
19
*[Code Editing](#code-editing)
19
20
*[Snippets](#snippets)
20
21
*[Format and organize imports](#format-and-organize-imports)
@@ -103,6 +104,19 @@ Quickly toggle between a file and its corresponding test file by using the [`Go:
103
104
104
105
<divstyle="text-align: center;"><imgsrc="images/toggletestfile.gif"alt="Toggle between reverse.go and reverse_test.go"style="width: 75%"> </div>
105
106
107
+
108
+
## Syntax Highlighting
109
+
110
+
The default syntax highlighting for Go files is implemented in Visual Studio Code using TextMate grammar, not by this extension.
111
+
112
+
If you are using `gopls`, you can enable [Semantic Highlighting](https://code.visualstudio.com/api/language-extensions/semantic-highlight-guide) for more accurate syntax highlighting based on semantic tokenization using `"gopls": { "ui.semanticTokens": true }`.
113
+
114
+
### Go template syntax highlighting
115
+
116
+
When `gopls`'s semantic tokens feature is enabled, `gopls` also provides semantic tokens for Go template files (language identifier: `gotmpl`). By default, the extension associates all `*.tmpl` or `*.gotmpl` files in the workspace with `gotmpl` language. Users can override the language mode by using Visual Studio Code's UI or the `"files.associations"` setting. See [Visual Studio Code's doc](https://code.visualstudio.com/docs/languages/overview#_changing-the-language-for-the-selected-file) for more details.
117
+
118
+
<divstyle="text-align: center;"><imgsrc="images/gotmpl.gif"alt="Enable Go template language support by changing the language ID"style="width: 75%"> </div>
@@ -115,13 +129,16 @@ Predefined snippets for quick coding. These snippets will appear as completion s
115
129
116
130
Format code and organize imports, either manually or on save.
117
131
132
+
The extension formats Go code, organizes imports, and removes unused imports by default. For different behavior, please override per-language default settings following [the instruction](https://github.com/golang/vscode-go/blob/master/docs/advanced.md#formatting-code-and-organizing-imports).
133
+
134
+
When organizing imports, the imported packages are grouped in the default `goimports` style. In order to group some packages after 3rd-party packages, use [`"gopls": { "formatting.local": <comma-separated imports prefix>}`](https://github.com/golang/vscode-go/blob/master/docs/settings.md#formattinglocal).
135
+
118
136
#### Add import
119
137
120
-
Manually add a new import to your file through the [`Go: Add Import`](commands.md#go-add-import) command. Available packages are offered from your `GOPATH`and module cache.
138
+
The extension organizes imports automatically and can add missing imports if the package is present in your module cache already. However, you can also manually add a new import to your file through the [`Go: Add Import`](commands.md#go-add-import) command. Available packages are offered from module cache (or from your `GOPATH`in GOPATH mode).
121
139
122
140
<divstyle="text-align: center;"><imgsrc="images/addimport.gif"alt="Add byte import to Go file"style="width: 75%"> </div>
0 commit comments