Skip to main content
The Fresh editor provides a plugin utilities library (plugins/lib/) with reusable components that abstract common plugin patterns. These utilities help you build plugins faster with less boilerplate.

Installation

Import utilities from the @plugins/lib module:

PanelManager

Manages the lifecycle of result panels (open, close, update, toggle). Simplifies creating persistent panels that can be shown, hidden, and updated.

Creating a Panel

PanelOptions

Methods

open

Open the panel with initial content.
Example:

update

Update panel content (panel must already be open).
Example:

toggle

Toggle panel visibility (open if closed, close if open).

close

Close the panel.

isOpen

Check if panel is currently open.

Complete Example

Handles list navigation with selection tracking and visual highlighting. Perfect for implementing navigable result lists.

Creating a Navigator

Methods

moveUp

Move selection up one line.

moveDown

Move selection down one line.

moveToTop

Move selection to first line.

moveToBottom

Move selection to last line.

getSelectedIndex

Get current selection index (0-based).

getSelectedLocation

Get text properties at current selection.

clearHighlights

Clear all navigation highlights.

Complete Example

VirtualBufferFactory

Simplified creation of virtual buffers with less boilerplate.

Creating a Virtual Buffer

VirtualBufferOptions

Type Definitions

The library exports common types for use in your plugins:

RGB

Location

Complete Plugin Example

Here’s a complete plugin using all three utilities:

Best Practices

PanelManager handles panel lifecycle automatically, including reusing panels with the same panelId.
For navigable result lists, use PanelManager to manage the panel and NavigationController for selection highlighting.
Use theme-appropriate colors for highlights. Consider using theme colors from the editor config.
Call clearHighlights() when closing panels to remove visual decorations.

Source Files

For full API details, see the source files in plugins/lib/:
  • plugins/lib/panel-manager.ts
  • plugins/lib/navigation-controller.ts
  • plugins/lib/virtual-buffer-factory.ts
  • plugins/lib/types.ts