Plugins run Lua scripts in a sandboxed environment. Use the note global to interact with the editor. Open the command palette (Ctrl+Shift+P) to run registered commands.
Editor
- note.get_text()
- Return all editor text as a string
- note.set_text(str)
- Replace all editor text
- note.insert_text(str)
- Insert text at the cursor position
- note.get_selection()
- Return the currently selected text
- note.set_selection_text(str)
- Replace the current selection
Tabs
- note.active_tab()
- Return
{id, name} of the active tab
- note.list_tabs()
- Return an array of
{id, name} for all tabs
- note.create_tab(name, text)
- Open a new tab with the given name and content
UI
- note.notify(msg [, ms])
- Show a toast notification (default 3 s)
- note.prompt(msg [, default])
- Show an input dialog; returns string or nil
- note.add_command(name, fn)
- Register
fn in the command palette
- note.bind_key(key, fn)
- Bind a keyboard shortcut, e.g.
"ctrl+shift+k"
Events
- note.on("save", fn)
- Run
fn whenever the editor saves; returns a handle
- note.off(handle)
- Remove an event listener by its handle
Storage
- note.storage.set(key, val)
- Persist a string value across sessions
- note.storage.get(key)
- Retrieve a persisted value (or nil)
- note.storage.delete(key)
- Remove a persisted value