Skip to content

Getting Started

Federico Conticello edited this page Mar 24, 2026 · 2 revisions

Getting Started

Create your first FerrisPad plugin in 5 minutes.

Plugin Structure

A plugin is a directory with at least two files:

my-plugin/
  init.lua       # Plugin logic
  plugin.toml    # Metadata and configuration

Step 1: Create the Manifest

Create plugin.toml:

name = "Hello World"
version = "0.1.0"
description = "A simple example plugin"

Step 2: Write the Plugin

Create init.lua:

local M = {}

function M:init(api)
    api:log("Hello World plugin loaded!")
end

function M:on_document_open(api, path)
    if path then
        api:log("Opened: " .. path)
    end
end

function M:on_document_save(api, path, content)
    local line_count = 0
    for _ in content:gmatch("[^\n]*\n") do
        line_count = line_count + 1
    end
    return {
        status_message = {
            level = "info",
            text = "Saved " .. line_count .. " lines"
        }
    }
end

return M

Step 3: Install

Copy the plugin directory to the plugins folder:

cp -r my-plugin/ ~/.config/ferrispad/plugins/

Restart FerrisPad or go to Plugins > Reload All.

Step 4: Test

Open any file — you should see "Hello World plugin loaded!" in stderr (if running from terminal). Save a file and you'll see a toast notification with the line count.

What's Next

Plugin Lifecycle

  1. FerrisPad discovers plugins in ~/.config/ferrispad/plugins/
  2. Each directory containing init.lua is loaded
  3. plugin.toml is parsed for metadata, permissions, menu items, and config
  4. The Lua file is executed in a sandboxed environment
  5. init(api) is called once
  6. Event hooks are called as the user interacts with the editor
  7. shutdown(api) is called when FerrisPad exits

Clone this wiki locally