Skip to main content

Module virtual_text

Module virtual_text 

Source
Expand description

Virtual text rendering infrastructure

Provides a system for rendering virtual text that doesn’t exist in the buffer. Used for inlay hints (type annotations, parameter names), git blame headers, etc.

Two types of virtual text are supported:

  • Inline: Text inserted before/after a character (e.g., : i32 type hints)
  • Line: Full lines inserted above/below a position (e.g., git blame headers)

Virtual text is rendered during the render phase by reading from VirtualTextManager. The buffer content remains unchanged - we just inject extra styled text during rendering.

§Architecture

This follows an Emacs-like model where:

  1. Plugins add virtual text in response to buffer changes (async, fire-and-forget)
  2. Virtual text is stored persistently with marker-based position tracking
  3. Render loop reads virtual text synchronously from memory (no async waiting)

This ensures frame coherence: render always sees a consistent snapshot of virtual text.

Structs§

VirtualText
A piece of virtual text to render at a specific position
VirtualTextId
Unique identifier for a virtual text entry
VirtualTextManager
Manages virtual text entries for a buffer
VirtualTextNamespace
Namespace for grouping virtual texts (for efficient bulk removal). Similar to OverlayNamespace - plugins create a namespace once and use it for all their virtual texts.

Enums§

VirtualTextPosition
Position relative to the character at the marker position