[vscode-go] docs/features.md: discuss default formatting behavior and template support

212 views
Skip to first unread message

Hyang-Ah Hana Kim (Gerrit)

unread,
Jan 24, 2022, 8:07:28 PM1/24/22
to Suzy Mueller, goph...@pubsubhelper.golang.org, Hyang-Ah Hana Kim, golang-co...@googlegroups.com

Attention is currently required from: Suzy Mueller.

Hyang-Ah Hana Kim would like Suzy Mueller to review this change.

View Change

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/vscode-go#609

Change-Id: Ib2e695d847c56bd4f562d91d2938cb5c1a032764
---
M docs/features.md
A docs/images/gotmpl.gif
2 files changed, 38 insertions(+), 2 deletions(-)

diff --git a/docs/features.md b/docs/features.md
index 1598ad4..61d8c8a 100644
--- a/docs/features.md
+++ b/docs/features.md
@@ -15,6 +15,7 @@
* [Find interface implementations](#find-interface-implementations)
* [Document outline](#document-outline)
* [Toggle between code and tests](#toggle-between-code-and-tests)
+* [Syntax Highlighting](#syntax-highlighting)
* [Code Editing](#code-editing)
* [Snippets](#snippets)
* [Format and organize imports](#format-and-organize-imports)
@@ -103,6 +104,19 @@

<div style="text-align: center;"><img src="images/toggletestfile.gif" alt="Toggle between reverse.go and reverse_test.go" style="width: 75%"> </div>

+
+## Syntax Highlighting
+
+The default syntax highlighting for Go files is implemented in Visual Studio Code using TextMate grammar, not by this extension.
+
+If you are using `gopls`, you can enable [Semantic Highlighting](https://code.visualstudio.com/api/language-extensions/semantic-highlight-guide), more accurate syntax highlighting based on semantic tokenization using `"gopls": { "ui.semanticTokens": true }`.
+
+### Go template syntax highlighting
+
+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. But 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.
+
+<div style="text-align: center;"><img src="images/gotmpl.gif" alt="Toggle between reverse.go and reverse_test.go" style="width: 75%"> </div>
+
## Code Editing

### [Snippets](https://code.visualstudio.com/docs/editor/userdefinedsnippets)
@@ -115,13 +129,16 @@

Format code and organize imports, either manually or on save.

+The extension is configured to 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).
+
+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).
+
#### Add import

-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.
+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).

<div style="text-align: center;"><img src="images/addimport.gif" alt="Add byte import to Go file" style="width: 75%"> </div>

-
### [Rename symbol](https://code.visualstudio.com/docs/editor/refactoring#_rename-symbol)

Rename all occurrences of a symbol in your workspace.
diff --git a/docs/images/gotmpl.gif b/docs/images/gotmpl.gif
new file mode 100644
index 0000000..c8fdaed
--- /dev/null
+++ b/docs/images/gotmpl.gif
Binary files differ

To view, visit change 380615. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: vscode-go
Gerrit-Branch: master
Gerrit-Change-Id: Ib2e695d847c56bd4f562d91d2938cb5c1a032764
Gerrit-Change-Number: 380615
Gerrit-PatchSet: 1
Gerrit-Owner: Hyang-Ah Hana Kim <hya...@gmail.com>
Gerrit-Reviewer: Hyang-Ah Hana Kim <hya...@gmail.com>
Gerrit-Reviewer: Suzy Mueller <suz...@golang.org>
Gerrit-Attention: Suzy Mueller <suz...@golang.org>
Gerrit-MessageType: newchange

kokoro (Gerrit)

unread,
Jan 24, 2022, 8:23:56 PM1/24/22
to Hyang-Ah Hana Kim, goph...@pubsubhelper.golang.org, Suzy Mueller, golang-co...@googlegroups.com

Attention is currently required from: Suzy Mueller.

Kokoro presubmit build finished with status: SUCCESS
Logs at: https://source.cloud.google.com/results/invocations/f75ab6a4-bfe5-404a-8da8-740cdb7ff70c

Patch set 1:TryBot-Result +1

View Change

    To view, visit change 380615. To unsubscribe, or for help writing mail filters, visit settings.

    Gerrit-Project: vscode-go
    Gerrit-Branch: master
    Gerrit-Change-Id: Ib2e695d847c56bd4f562d91d2938cb5c1a032764
    Gerrit-Change-Number: 380615
    Gerrit-PatchSet: 1
    Gerrit-Owner: Hyang-Ah Hana Kim <hya...@gmail.com>
    Gerrit-Reviewer: Hyang-Ah Hana Kim <hya...@gmail.com>
    Gerrit-Reviewer: Suzy Mueller <suz...@golang.org>
    Gerrit-Reviewer: kokoro <noreply...@google.com>
    Gerrit-Attention: Suzy Mueller <suz...@golang.org>
    Gerrit-Comment-Date: Tue, 25 Jan 2022 01:23:51 +0000
    Gerrit-HasComments: No
    Gerrit-Has-Labels: Yes
    Gerrit-MessageType: comment

    Suzy Mueller (Gerrit)

    unread,
    Jan 25, 2022, 12:54:24 PM1/25/22
    to Hyang-Ah Hana Kim, goph...@pubsubhelper.golang.org, kokoro, golang-co...@googlegroups.com

    Attention is currently required from: Hyang-Ah Hana Kim.

    View Change

    4 comments:

    To view, visit change 380615. To unsubscribe, or for help writing mail filters, visit settings.

    Gerrit-Project: vscode-go
    Gerrit-Branch: master
    Gerrit-Change-Id: Ib2e695d847c56bd4f562d91d2938cb5c1a032764
    Gerrit-Change-Number: 380615
    Gerrit-PatchSet: 1
    Gerrit-Owner: Hyang-Ah Hana Kim <hya...@gmail.com>
    Gerrit-Reviewer: Hyang-Ah Hana Kim <hya...@gmail.com>
    Gerrit-Reviewer: Suzy Mueller <suz...@golang.org>
    Gerrit-Reviewer: kokoro <noreply...@google.com>
    Gerrit-Attention: Hyang-Ah Hana Kim <hya...@gmail.com>
    Gerrit-Comment-Date: Tue, 25 Jan 2022 17:54:14 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    Gerrit-MessageType: comment

    Hyang-Ah Hana Kim (Gerrit)

    unread,
    Jan 25, 2022, 4:46:52 PM1/25/22
    to Hyang-Ah Hana Kim, goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com

    Attention is currently required from: Hyang-Ah Hana Kim.

    Hyang-Ah Hana Kim uploaded patch set #2 to this change.

    View Change

    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/vscode-go#609

    Change-Id: Ib2e695d847c56bd4f562d91d2938cb5c1a032764
    ---
    M docs/features.md
    A docs/images/gotmpl.gif
    2 files changed, 38 insertions(+), 2 deletions(-)

    To view, visit change 380615. To unsubscribe, or for help writing mail filters, visit settings.

    Gerrit-Project: vscode-go
    Gerrit-Branch: master
    Gerrit-Change-Id: Ib2e695d847c56bd4f562d91d2938cb5c1a032764
    Gerrit-Change-Number: 380615
    Gerrit-PatchSet: 2
    Gerrit-Owner: Hyang-Ah Hana Kim <hya...@gmail.com>
    Gerrit-Reviewer: Hyang-Ah Hana Kim <hya...@gmail.com>
    Gerrit-Reviewer: Suzy Mueller <suz...@golang.org>
    Gerrit-Reviewer: kokoro <noreply...@google.com>
    Gerrit-Attention: Hyang-Ah Hana Kim <hya...@gmail.com>
    Gerrit-MessageType: newpatchset

    Hyang-Ah Hana Kim (Gerrit)

    unread,
    Jan 25, 2022, 4:49:15 PM1/25/22
    to Hyang-Ah Hana Kim, goph...@pubsubhelper.golang.org, kokoro, Suzy Mueller, golang-co...@googlegroups.com

    Attention is currently required from: Suzy Mueller.

    View Change

    5 comments:

      • Done

      • Done

      • lol. copy&paste error :-)

      • remove "is configured to" or change "formats", "organizes" and "removes" to "format" "organize" and […]

        Done

    To view, visit change 380615. To unsubscribe, or for help writing mail filters, visit settings.

    Gerrit-Project: vscode-go
    Gerrit-Branch: master
    Gerrit-Change-Id: Ib2e695d847c56bd4f562d91d2938cb5c1a032764
    Gerrit-Change-Number: 380615
    Gerrit-PatchSet: 2
    Gerrit-Owner: Hyang-Ah Hana Kim <hya...@gmail.com>
    Gerrit-Reviewer: Hyang-Ah Hana Kim <hya...@gmail.com>
    Gerrit-Reviewer: Suzy Mueller <suz...@golang.org>
    Gerrit-Reviewer: kokoro <noreply...@google.com>
    Gerrit-Attention: Suzy Mueller <suz...@golang.org>
    Gerrit-Comment-Date: Tue, 25 Jan 2022 21:49:09 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    Comment-In-Reply-To: Suzy Mueller <suz...@golang.org>
    Gerrit-MessageType: comment

    kokoro (Gerrit)

    unread,
    Jan 25, 2022, 5:04:17 PM1/25/22
    to Hyang-Ah Hana Kim, goph...@pubsubhelper.golang.org, Suzy Mueller, golang-co...@googlegroups.com

    Attention is currently required from: Suzy Mueller.

    Kokoro presubmit build finished with status: SUCCESS
    Logs at: https://source.cloud.google.com/results/invocations/f434888a-b8a6-4799-86a3-fd5d7fa61b99

    Patch set 2:TryBot-Result +1

    View Change

      To view, visit change 380615. To unsubscribe, or for help writing mail filters, visit settings.

      Gerrit-Project: vscode-go
      Gerrit-Branch: master
      Gerrit-Change-Id: Ib2e695d847c56bd4f562d91d2938cb5c1a032764
      Gerrit-Change-Number: 380615
      Gerrit-PatchSet: 2
      Gerrit-Owner: Hyang-Ah Hana Kim <hya...@gmail.com>
      Gerrit-Reviewer: Hyang-Ah Hana Kim <hya...@gmail.com>
      Gerrit-Reviewer: Suzy Mueller <suz...@golang.org>
      Gerrit-Reviewer: kokoro <noreply...@google.com>
      Gerrit-Attention: Suzy Mueller <suz...@golang.org>
      Gerrit-Comment-Date: Tue, 25 Jan 2022 22:04:10 +0000

      kokoro (Gerrit)

      unread,
      Jan 26, 2022, 3:36:31 PM1/26/22
      to Hyang-Ah Hana Kim, goph...@pubsubhelper.golang.org, Suzy Mueller, golang-co...@googlegroups.com

      Attention is currently required from: Suzy Mueller.

      Kokoro presubmit build finished with status: SUCCESS

      Logs at: https://source.cloud.google.com/results/invocations/69059c88-6710-4d99-93a0-7c5a6f5e0616

      Patch set 3:TryBot-Result +1

      View Change

        To view, visit change 380615. To unsubscribe, or for help writing mail filters, visit settings.

        Gerrit-Project: vscode-go
        Gerrit-Branch: master
        Gerrit-Change-Id: Ib2e695d847c56bd4f562d91d2938cb5c1a032764
        Gerrit-Change-Number: 380615
        Gerrit-PatchSet: 3
        Gerrit-Owner: Hyang-Ah Hana Kim <hya...@gmail.com>
        Gerrit-Reviewer: Hyang-Ah Hana Kim <hya...@gmail.com>
        Gerrit-Reviewer: Suzy Mueller <suz...@golang.org>
        Gerrit-Reviewer: kokoro <noreply...@google.com>
        Gerrit-Attention: Suzy Mueller <suz...@golang.org>
        Gerrit-Comment-Date: Wed, 26 Jan 2022 20:36:27 +0000

        kokoro (Gerrit)

        unread,
        Jan 26, 2022, 6:19:18 PM1/26/22
        to Hyang-Ah Hana Kim, goph...@pubsubhelper.golang.org, Suzy Mueller, golang-co...@googlegroups.com

        Attention is currently required from: Suzy Mueller.

        Kokoro presubmit build finished with status: SUCCESS

        Logs at: https://source.cloud.google.com/results/invocations/37350a85-bf64-4f00-82d1-ac4cd6c01dab

        Patch set 4:TryBot-Result +1

        View Change

          To view, visit change 380615. To unsubscribe, or for help writing mail filters, visit settings.

          Gerrit-Project: vscode-go
          Gerrit-Branch: master
          Gerrit-Change-Id: Ib2e695d847c56bd4f562d91d2938cb5c1a032764
          Gerrit-Change-Number: 380615
          Gerrit-PatchSet: 4
          Gerrit-Owner: Hyang-Ah Hana Kim <hya...@gmail.com>
          Gerrit-Reviewer: Hyang-Ah Hana Kim <hya...@gmail.com>
          Gerrit-Reviewer: Suzy Mueller <suz...@golang.org>
          Gerrit-Reviewer: kokoro <noreply...@google.com>
          Gerrit-Attention: Suzy Mueller <suz...@golang.org>
          Gerrit-Comment-Date: Wed, 26 Jan 2022 23:19:12 +0000

          Peter Weinberger (Gerrit)

          unread,
          Jan 28, 2022, 6:24:51 PM1/28/22
          to Hyang-Ah Hana Kim, goph...@pubsubhelper.golang.org, kokoro, Suzy Mueller, golang-co...@googlegroups.com

          Attention is currently required from: Suzy Mueller, Hyang-Ah Hana Kim.

          Patch set 4:Code-Review +2

          View Change

          1 comment:

          To view, visit change 380615. To unsubscribe, or for help writing mail filters, visit settings.

          Gerrit-Project: vscode-go
          Gerrit-Branch: master
          Gerrit-Change-Id: Ib2e695d847c56bd4f562d91d2938cb5c1a032764
          Gerrit-Change-Number: 380615
          Gerrit-PatchSet: 4
          Gerrit-Owner: Hyang-Ah Hana Kim <hya...@gmail.com>
          Gerrit-Reviewer: Hyang-Ah Hana Kim <hya...@gmail.com>
          Gerrit-Reviewer: Peter Weinberger <p...@google.com>
          Gerrit-Reviewer: Suzy Mueller <suz...@golang.org>
          Gerrit-Reviewer: kokoro <noreply...@google.com>
          Gerrit-Attention: Suzy Mueller <suz...@golang.org>
          Gerrit-Attention: Hyang-Ah Hana Kim <hya...@gmail.com>
          Gerrit-Comment-Date: Fri, 28 Jan 2022 23:24:47 +0000
          Gerrit-HasComments: Yes
          Gerrit-Has-Labels: Yes
          Gerrit-MessageType: comment

          Hyang-Ah Hana Kim (Gerrit)

          unread,
          Jan 31, 2022, 4:28:52 PM1/31/22
          to Hyang-Ah Hana Kim, goph...@pubsubhelper.golang.org, Peter Weinberger, kokoro, Suzy Mueller, golang-co...@googlegroups.com

          Attention is currently required from: Suzy Mueller.

          View Change

          1 comment:

          • Patchset:

            • It looks like Gerrit dropped part of your comment.

          To view, visit change 380615. To unsubscribe, or for help writing mail filters, visit settings.

          Gerrit-Project: vscode-go
          Gerrit-Branch: master
          Gerrit-Change-Id: Ib2e695d847c56bd4f562d91d2938cb5c1a032764
          Gerrit-Change-Number: 380615
          Gerrit-PatchSet: 4
          Gerrit-Owner: Hyang-Ah Hana Kim <hya...@gmail.com>
          Gerrit-Reviewer: Hyang-Ah Hana Kim <hya...@gmail.com>
          Gerrit-Reviewer: Peter Weinberger <p...@google.com>
          Gerrit-Reviewer: Suzy Mueller <suz...@golang.org>
          Gerrit-Reviewer: kokoro <noreply...@google.com>
          Gerrit-Attention: Suzy Mueller <suz...@golang.org>
          Gerrit-Comment-Date: Mon, 31 Jan 2022 21:28:48 +0000
          Gerrit-HasComments: Yes
          Gerrit-Has-Labels: No
          Comment-In-Reply-To: Peter Weinberger <p...@google.com>
          Gerrit-MessageType: comment

          Hyang-Ah Hana Kim (Gerrit)

          unread,
          Jan 31, 2022, 4:28:56 PM1/31/22
          to Hyang-Ah Hana Kim, goph...@pubsubhelper.golang.org, golang-...@googlegroups.com, Peter Weinberger, kokoro, Suzy Mueller, golang-co...@googlegroups.com

          Hyang-Ah Hana Kim submitted this change.

          View Change


          Approvals: Peter Weinberger: Looks good to me, approved Hyang-Ah Hana Kim: Trusted; Run TryBots kokoro: TryBots succeeded
          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/vscode-go#609

          Change-Id: Ib2e695d847c56bd4f562d91d2938cb5c1a032764
          Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/380615
          Trust: Hyang-Ah Hana Kim <hya...@gmail.com>
          Run-TryBot: Hyang-Ah Hana Kim <hya...@gmail.com>
          TryBot-Result: kokoro <noreply...@google.com>
          Reviewed-by: Peter Weinberger <p...@google.com>

          ---
          M docs/features.md
          A docs/images/gotmpl.gif
          2 files changed, 43 insertions(+), 2 deletions(-)

          diff --git a/docs/features.md b/docs/features.md
          index 1598ad4..e658933 100644

          --- a/docs/features.md
          +++ b/docs/features.md
          @@ -15,6 +15,7 @@
          * [Find interface implementations](#find-interface-implementations)
          * [Document outline](#document-outline)
          * [Toggle between code and tests](#toggle-between-code-and-tests)
          +* [Syntax Highlighting](#syntax-highlighting)
          * [Code Editing](#code-editing)
          * [Snippets](#snippets)
          * [Format and organize imports](#format-and-organize-imports)
          @@ -103,6 +104,19 @@

          <div style="text-align: center;"><img src="images/toggletestfile.gif" alt="Toggle between reverse.go and reverse_test.go" style="width: 75%"> </div>

          +
          +## Syntax Highlighting
          +
          +The default syntax highlighting for Go files is implemented in Visual Studio Code using TextMate grammar, not by this extension.
          +
          +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 }`.

          +
          +### Go template syntax highlighting
          +
          +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.
          +
          +<div style="text-align: center;"><img src="images/gotmpl.gif" alt="Enable Go template language support by changing the language ID" style="width: 75%"> </div>

          +
          ## Code Editing

          ### [Snippets](https://code.visualstudio.com/docs/editor/userdefinedsnippets)
          @@ -115,13 +129,16 @@

          Format code and organize imports, either manually or on save.

          +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).

          +
          +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).
          +
          #### Add import

          -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.
          +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).

          <div style="text-align: center;"><img src="images/addimport.gif" alt="Add byte import to Go file" style="width: 75%"> </div>

          -
          ### [Rename symbol](https://code.visualstudio.com/docs/editor/refactoring#_rename-symbol)

          Rename all occurrences of a symbol in your workspace.
          diff --git a/docs/images/gotmpl.gif b/docs/images/gotmpl.gif
          new file mode 100644
          index 0000000..c8fdaed
          --- /dev/null
          +++ b/docs/images/gotmpl.gif
          Binary files differ

          To view, visit change 380615. To unsubscribe, or for help writing mail filters, visit settings.

          Gerrit-Project: vscode-go
          Gerrit-Branch: master
          Gerrit-Change-Id: Ib2e695d847c56bd4f562d91d2938cb5c1a032764
          Gerrit-Change-Number: 380615
          Gerrit-PatchSet: 5
          Gerrit-Owner: Hyang-Ah Hana Kim <hya...@gmail.com>
          Gerrit-Reviewer: Hyang-Ah Hana Kim <hya...@gmail.com>
          Gerrit-Reviewer: Peter Weinberger <p...@google.com>
          Gerrit-Reviewer: Suzy Mueller <suz...@golang.org>
          Gerrit-Reviewer: kokoro <noreply...@google.com>
          Gerrit-MessageType: merged
          Reply all
          Reply to author
          Forward
          0 new messages