A VS Code extension that shows the full type definition of a variable right inside the hover tooltip in Go files — no jump required.
The default gopls hover only shows the type's name:
var cfg AppConfig
// ^ hover: var cfg pkg.AppConfigTo see what's actually inside AppConfig, you have to jump to its definition (Go to Definition) and lose your place. Go Peek Type Hover fixes that: hover over a variable and instantly see the full struct or interface body without leaving the current line.
- 🔍 Full type definition in the hover tooltip — the body of a
struct { ... },interface { ... }, or the declaration line of an alias type. - 🧩 Complements, not replaces, the standard
goplshover — both blocks are shown together. - 🛡️ Reliable fallback — if
goplsis temporarily unavailable, a built-in brace parser kicks in.
- When a hover is requested in a Go file, the extension calls the built-in
vscode.executeTypeDefinitionProvidercommand, which usesgopls(via thegolang.goextension) to return the location of the variable's type declaration. vscode.executeDocumentSymbolProvideris then used to find the symbol enclosing that location, and its full text is extracted.- If no symbol is found (e.g.
goplsis temporarily unavailable), a fallback brace parser scans the file text directly. - The result is appended as a separate Peek type definition block — VS Code merges hovers from multiple providers, so the regular
goplshover stays in place too.
- The official Go extension (
golang.go) must be installed — it's used as thegoplsbackend, since this command relies on the same LSP provider.
Install from the VS Code Marketplace, or search for Go Peek Type Hover in the Extensions view (Cmd+Shift+X / Ctrl+Shift+X).
git clone <repository-url>
cd go-peek-type-hover
npm install
npm run compileThen in VS Code press F5 (the Run Extension configuration) to open a new Extension Development Host window, where you can open any Go project and hover over a variable.
