Skip to main content
The Overlays API allows you to add visual decorations to buffer text - such as syntax highlighting, error markers, search results, and more - without modifying the actual buffer content.

Overlay Operations

addOverlay

Add a visual overlay to a buffer range.
number
required
Target buffer ID
string
required
Namespace for grouping (use for batch removal)
number
required
Start byte offset
number
required
End byte offset
number
required
Foreground red (0-255)
number
required
Foreground green (0-255)
number
required
Foreground blue (0-255)
number
required
Background red (0-255, or -1 for transparent)
number
required
Background green (0-255, or -1 for transparent)
number
required
Background blue (0-255, or -1 for transparent)
boolean
required
Add underline decoration
boolean
required
Use bold text
boolean
required
Use italic text
boolean
required
Extend background to end of visual line
boolean
true if overlay was added successfully
Overlays persist until explicitly removed. Use namespaces for batch removal (e.g., “spell”, “todo”). Multiple overlays can apply to the same range; colors blend.
Example:

removeOverlay

Remove a specific overlay by its handle.
number
required
The buffer ID
string
required
The overlay handle to remove
boolean
true if overlay was removed

clearNamespace

Clear all overlays in a namespace.
number
required
The buffer ID
string
required
The namespace to clear
boolean
true if namespace was cleared
Example:

clearOverlaysInRange

Clear all overlays that overlap with a byte range.
number
required
The buffer ID
number
required
Start byte position (inclusive)
number
required
End byte position (exclusive)
boolean
true if overlays were cleared

clearAllOverlays

Remove all overlays from a buffer.
number
required
The buffer ID
boolean
true if all overlays were cleared

Virtual Text

Virtual text appears inline in the buffer without modifying the actual content. Useful for displaying inline hints, diagnostics, or git blame information.

addVirtualText

Add virtual text (inline decoration) at a position.
number
required
The buffer ID
string
required
Unique identifier for this virtual text
number
required
Byte position to insert at
string
required
The virtual text to display
number
required
Red color component (0-255)
number
required
Green color component (0-255)
number
required
Blue color component (0-255)
boolean
required
Whether to insert before (true) or after (false) the position
boolean
required
Whether to use the color as background (true) or foreground (false)
boolean
true if virtual text was added
Example:

removeVirtualText

Remove virtual text by ID.
number
required
The buffer ID
string
required
The virtual text ID to remove
boolean
true if virtual text was removed

removeVirtualTextsByPrefix

Remove all virtual texts with IDs starting with a prefix.
number
required
The buffer ID
string
required
The prefix to match virtual text IDs against
boolean
true if virtual texts were removed
Example:

clearVirtualTexts

Remove all virtual texts from a buffer.
number
required
The buffer ID
boolean
true if all virtual texts were cleared

clearVirtualTextNamespace

Clear all virtual texts in a namespace.
number
required
The buffer ID
string
required
The namespace to clear (e.g., “git-blame”)
boolean
true if namespace was cleared

Line Decorations

addVirtualLine

Add a virtual line above or below a source line.
number
required
The buffer ID
number
required
Byte position to anchor the virtual line to
string
required
The text content of the virtual line
number
required
Foreground red color component (0-255)
number
required
Foreground green color component (0-255)
number
required
Foreground blue color component (0-255)
number
required
Background red color component (0-255), -1 for transparent
number
required
Background green color component (0-255), -1 for transparent
number
required
Background blue color component (0-255), -1 for transparent
boolean
required
Whether to insert above (true) or below (false) the line
string
required
Namespace for bulk removal (e.g., “git-blame”)
number
required
Priority for ordering multiple lines at same position
boolean
true if virtual line was added

setLineIndicator

Set a line indicator in the gutter’s indicator column.
number
required
The buffer ID
number
required
Line number (0-indexed)
string
required
Namespace for grouping (e.g., “git-gutter”, “breakpoints”)
string
required
Symbol to display (e.g., ”│”, ”●”, ”★”)
number
required
Red color component (0-255)
number
required
Green color component (0-255)
number
required
Blue color component (0-255)
number
required
Priority for display when multiple indicators exist (higher wins)
boolean
true if line indicator was set
Example:

clearLineIndicators

Clear all line indicators for a specific namespace.
number
required
The buffer ID
string
required
Namespace to clear (e.g., “git-gutter”)
boolean
true if line indicators were cleared

Examples

Highlight search results

Show inline diagnostics