Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Doc: improve documentation for working with template files #3655

Open
bigon opened this issue Jan 8, 2025 · 7 comments
Open

Doc: improve documentation for working with template files #3655

bigon opened this issue Jan 8, 2025 · 7 comments

Comments

@bigon
Copy link

bigon commented Jan 8, 2025

What version of Go, VS Code & VS Code Go extension are you using?

Version Information
  • Run go version to get version of Go from the VS Code integrated terminal.
    • go version go1.23.4 linux/amd64
  • Run gopls -v version to get version of Gopls from the VS Code integrated terminal.
    • v0.17.1
  • Run code -v or code-insiders -v to get version of VS Code or VS Code Insiders.
    • 1.96.2
  • Check your installed extensions to get the version of the VS Code Go extension
    • 0.44.0
  • Run Ctrl+Shift+P (Cmd+Shift+P on Mac OS) > Go: Locate Configured Go Tools command.
    • Tools Configuration

Environment

GOBIN: undefined
toolsGopath:
gopath: /home/bigon/go
GOROOT: /usr/lib/go-1.23
PATH: /home/bigon/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games

Tools

go:	/usr/bin/go: go version go1.23.4 linux/amd64

gopls:	/home/bigon/go/bin/gopls	(version: v0.17.1 built with go: go1.23.4)
gotests:	not installed
gomodifytags:	not installed
impl:	not installed
goplay:	not installed
dlv:	/usr/bin/dlv	(version: undefined built with go: go1.23.4)
staticcheck:	/home/bigon/go/bin/staticcheck	(version: v0.5.1 built with go: go1.23.4)

Go env

Workspace Folder (thanos-receivers): /home/bigon/Boulot//code/thanos-receivers

GO111MODULE=''
GOARCH='amd64'
GOBIN=''
GOCACHE='/home/bigon/.cache/go-build'
GOENV='/home/bigon/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='amd64'
GOHOSTOS='linux'
GOINSECURE=''
GOMODCACHE='/home/bigon/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='linux'
GOPATH='/home/bigon/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/usr/lib/go-1.23'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/usr/lib/go-1.23/pkg/tool/linux_amd64'
GOVCS=''
GOVERSION='go1.23.4'
GODEBUG=''
GOTELEMETRY='local'
GOTELEMETRYDIR='/home/bigon/.config/go/telemetry'
GCCGO='gccgo'
GOAMD64='v1'
AR='ar'
CC='gcc'
CXX='g++'
CGO_ENABLED='1'
GOMOD='/dev/null'
GOWORK=''
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'
GOGCCFLAGS='-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build2302377950=/tmp/go-build -gno-record-gcc-switches'

Share the Go related settings you have added/edited

Default config

Describe the bug

No syntax highlighting for gotmpl

I'm expecting to have some colors and highlighting

Steps to reproduce the behavior:

  1. Install the vscode-go extension
  2. Open a gotmpl file
  3. No syntax highlighting for gotmpl

Screenshots or recordings

If applicable, add screenshots or recordings to help explain your problem.

@gopherbot gopherbot added this to the Untriaged milestone Jan 8, 2025
@bigon
Copy link
Author

bigon commented Jan 8, 2025

I also see the following error in the gopls server output:

[Error - 16:49:00] Request textDocument/documentSymbol failed.
Error: name must not be falsy
    at Function.validate (file:///usr/share/code/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:109:33647)
    at new Gd (file:///usr/share/code/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:109:33936)
    at asDocumentSymbol (/home/bigon/.vscode/extensions/golang.go-0.44.0/dist/goMain.js:14573:22)
    at convertBatch (/home/bigon/.vscode/extensions/golang.go-0.44.0/dist/goMain.js:12968:23)
    at Object.map (/home/bigon/.vscode/extensions/golang.go-0.44.0/dist/goMain.js:12976:19)
    at Object.asDocumentSymbols (/home/bigon/.vscode/extensions/golang.go-0.44.0/dist/goMain.js:14570:22)
    at _provideDocumentSymbols (/home/bigon/.vscode/extensions/golang.go-0.44.0/dist/goMain.js:18861:64)
    at uI.provideDocumentSymbols (file:///usr/share/code/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:138:126457)

@findleyr
Copy link
Member

Hi, are you setting the "templateExtensions" gopls setting?
https://github.com/golang/tools/blob/master/gopls/doc/settings.md#templateextensions-string

Without this set, VS Code will not recognize go template files.

@bigon
Copy link
Author

bigon commented Jan 15, 2025

Hello,

For what I can see, the file with .gotmpl are already recognized as a go template

Image

For I added the following and it's the same issue

    "gopls": {

        "templateExtensions": [
            "gotmpl",
        ]
    }

@findleyr
Copy link
Member

Thanks @bigon: are you still not seeing syntax highlighting after that change?

You may also need to add: "semanticTokens": true.

@bigon
Copy link
Author

bigon commented Jan 15, 2025

"semanticTokens": true to true is showing some color, yes

@findleyr findleyr changed the title No syntax highlighting for gotmpl Doc: improve documentation for working with template files Jan 16, 2025
@findleyr
Copy link
Member

Thank you. Reclassifying this as a documentation bug, to improve our (nearly nonexistent) documentation for working with template files.

@findleyr findleyr modified the milestones: Untriaged, vscode-go/backlog Jan 16, 2025
@bigon
Copy link
Author

bigon commented Jan 17, 2025

Shouldn't semanticTokens be set to true by default?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants