VS Code Extensions
Go Peek Type Hover

Go Peek Type Hover

by artsmolin

Shows the full type definition of a variable right inside the hover tooltip in Go files.

Downloads

7

Rating

5.0 / 5 (1)

Version

0.0.3

Last updated

Jul 07, 2026

English · Русский

A VS Code extension that shows the full type definition of a variable right inside the hover tooltip in Go files — no jump required.


Why

The default gopls hover only shows the type's name:

var cfg AppConfig
//       ^ hover: var cfg pkg.AppConfig

To 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.

Features

  • 🔍 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 gopls hover — both blocks are shown together.
  • 🛡️ Reliable fallback — if gopls is temporarily unavailable, a built-in brace parser kicks in.

How it works

  1. When a hover is requested in a Go file, the extension calls the built-in vscode.executeTypeDefinitionProvider command, which uses gopls (via the golang.go extension) to return the location of the variable's type declaration.
  2. vscode.executeDocumentSymbolProvider is then used to find the symbol enclosing that location, and its full text is extracted.
  3. If no symbol is found (e.g. gopls is temporarily unavailable), a fallback brace parser scans the file text directly.
  4. The result is appended as a separate Peek type definition block — VS Code merges hovers from multiple providers, so the regular gopls hover stays in place too.

Requirements

  • The official Go extension (golang.go) must be installed — it's used as the gopls backend, since this command relies on the same LSP provider.

Installation

From .vsix

code --install-extension go-peek-type-hover-0.0.1.vsix

From source (development mode)

git clone <repository-url>
cd go-peek-type-hover
npm install
npm run compile

Then 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.

License

MIT

Related extensions