Buffer Queries
getActiveBufferId
Get the buffer ID of the focused editor pane.The active buffer ID, or 0 if no buffer is active (rare edge case)
getBufferPath
Get the absolute file path for a buffer.Target buffer ID
Absolute file path, or empty string for unsaved buffers or virtual buffers
getBufferLength
Get the total byte length of a buffer’s content.Target buffer ID
Buffer length in bytes, or 0 if buffer doesn’t exist
isBufferModified
Check if a buffer has been modified since last save.Target buffer ID
true if buffer has unsaved changes, false otherwise. Virtual buffers are never considered modified.getBufferInfo
Get full information about a buffer.Buffer ID to query
Buffer information object, or
null if buffer doesn’t existlistBuffers
List all open buffers.Array of all open buffers
getBufferText
Get text from a buffer range.Buffer ID
Start byte offset
End byte offset
Text content from the specified range
findBufferByPath
Find a buffer ID by its file path.File path to search for
Buffer ID if found, or 0 if not found
Cursor Operations
getCursorPosition
Get the byte offset of the primary cursor.Byte offset of cursor, or 0 if no cursor. For multi-cursor, use
getAllCursors.This returns a byte offset, not a character index. Use this with
insertText and deleteRange.getCursorLine
Get the line number of the primary cursor (1-indexed).Line number starting at 1. Returns 1 if no cursor exists.
getPrimaryCursor
Get primary cursor with selection info.Cursor information including position and selection, or
null if no cursorgetAllCursors
Get all cursors (for multi-cursor support).Array of all cursors with position and selection info
getAllCursorPositions
Get byte offsets of all cursors.Array of cursor positions. Empty if no cursors. Primary cursor is typically first.
setBufferCursor
Set cursor position in a buffer (also scrolls viewport to show cursor).ID of the buffer
Byte offset position for the cursor
true if successfulBuffer Mutations
insertText
Insert text at a byte position in a buffer.Target buffer ID
Byte offset where text will be inserted (must be at char boundary)
UTF-8 text to insert
true if command was sent successfully. Operation is asynchronous.insertAtCursor
Insert text at the current cursor position in the active buffer.The text to insert
true if successfuldeleteRange
Delete a byte range from a buffer.Target buffer ID
Start byte offset (inclusive)
End byte offset (exclusive)
true if command was sent successfully. Operation is asynchronous.Buffer Display
showBuffer
Switch the current split to display a buffer.ID of the buffer to show
true if successfulcloseBuffer
Close a buffer and remove it from all splits.ID of the buffer to close
true if successfulopenFile
Open a file in the editor, optionally at a specific location.File path to open
Line number to jump to (0 for no jump)
Column number to jump to (0 for no jump)
true if successfulopenFileInSplit
Open a file in a specific split pane.The split ID to open the file in
File path to open
Line number to jump to (0 for no jump)
Column number to jump to (0 for no jump)
true if successfulConfiguration
getConfig
Get the current editor configuration.Merged configuration (user config file + compiled-in defaults). This is the runtime config that the editor is actually using.
getUserConfig
Get the user’s configuration (only explicitly set values).Configuration from the user’s config file only. Fields not present here are using default values.
getConfigDir
Get the absolute path to the user config directory.Absolute path to config directory (e.g.,
~/.config/fresh/ on Linux)reloadConfig
Reload configuration from file.Diagnostics
getAllDiagnostics
Get all LSP diagnostics across all files.Array of all LSP diagnostics
Actions
executeAction
Execute a built-in editor action by name.Action name (e.g., “move_word_right”, “move_line_end”)
true if successfulexecuteActions
Execute multiple actions in sequence, each with an optional repeat count.Array of action specifications
true if successfulClipboard
setClipboard
Copy text to the system clipboard.Text to copy to clipboard