Repository navigation
Editor API
All methods are called on the api object passed to every hook.
Returns the full document text as a string, or nil if no document is active.
Returns the file path as a string, or nil for untitled documents.
Returns the detected syntax language name (e.g., "Rust", "Python", "JavaScript"), or nil.
Returns true if the document has unsaved changes.
Returns the cursor byte offset in the buffer as an integer.
Returns the currently selected text as a string, or nil if nothing is selected.
Returns the text of a specific line (1-indexed), or nil if the line doesn't exist.
local first_line = api:get_line(1)Returns the file extension without the dot (e.g., "rs", "py"), or nil.
Returns the directory containing the current file, or nil for untitled documents.
Returns the project root directory, or nil if no project markers are found.
Project root is detected by walking up the directory tree looking for: .git, Cargo.toml, package.json, pyproject.toml, setup.py, .ferrispad.
Returns a string config value for the given key, or nil if unset.
local extra = api:get_config("extra_args")Returns a numeric config value, or nil if unset or not a valid number.
Returns a boolean config value. Returns false if unset.
Config keys correspond to the key field in [[config.params]] sections of plugin.toml.
FerrisPad runs a local MCP server for AI tool integration. See the MCP Server page for the full overview, available tools, and bridge mode.
Returns the MCP server TCP port (integer), or nil if the MCP server is not running.
Writes a .mcp.json configuration file to the given project root directory. Auto-appends .mcp.json to .gitignore. Skips if the file already exists.
Returns (true, "") on success or (false, error_message) on failure.
Prints a debug message to stderr. Useful for development — visible when running FerrisPad from a terminal.
api:log("Debug: processing " .. tostring(line_count) .. " lines")Returns true if the given command exists on the system PATH.
if api:command_exists("ruff") then
-- safe to run ruff
end