Files
plainleaf/website/API/command.md
T
Zef Hemel 45b767fd3c Lua widgets: html can now also be a DOM node
Encoding some more space lua priorities and documenting them
2025-03-28 17:38:32 +01:00

25 lines
722 B
Markdown

APIs related to editor commands
### command.define(commandDef)
Registers a command.
Available keys:
* `name`: Name of the command
* `run`: Callback function
* `contexts`: AST node context in which this command should be available
* `priority`: Command priority (how high it appears in the list)
* `key`: Windows/Linux key binding (and mac, if not separately defined)
* `mac`: Mac-specific key binding
* `hide`: Hide this command from the [[Command Palette]]
* `requireMode`: `rw` or `ro` — only enable this command in a particular mode (read-write, or read-only)
Example:
```lua
command.define {
name = "My custom command",
run = function()
editor.flashNotification "Triggered my custom command"
end
}
```