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.update
Update panel content (panel must already be open).toggle
Toggle panel visibility (open if closed, close if open).close
Close the panel.isOpen
Check if panel is currently open.Complete Example
NavigationController
Handles list navigation with selection tracking and visual highlighting. Perfect for implementing navigable result lists.Creating a Navigator
NavigationOptions
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
Use PanelManager for persistent panels
Use PanelManager for persistent panels
PanelManager handles panel lifecycle automatically, including reusing panels with the same
panelId.Combine with NavigationController
Combine with NavigationController
Consistent color schemes
Consistent color schemes
Use theme-appropriate colors for highlights. Consider using theme colors from the editor config.
Clean up resources
Clean up resources
Call
clearHighlights() when closing panels to remove visual decorations.Source Files
For full API details, see the source files inplugins/lib/:
plugins/lib/panel-manager.tsplugins/lib/navigation-controller.tsplugins/lib/virtual-buffer-factory.tsplugins/lib/types.ts