Defold
Defold game engine support with bundled API docs, Lua language server, and code snippets
How to install
With Forge Super installed, the button above opens the app on this extension, where you press Install. Nothing is installed until you do.
You can also open the Extensions panel in the app and search for Defold. The extension's id is defold.
Don't have Forge Super yet? Download it here.
README
From the extension's repository, written by its authors and not by Mentenaz. See the source.
Zed Defold Extension
A Defold game engine extension for the Zed editor that provides Lua language support for Defold script files.
🚀 Installation
Using Zed's Built-in Extension Installer (Recommended)
The easiest way to install this extension is to use Zed's "Install Dev Extension" feature, which handles compilation automatically:
- Clone this repository:
git clone https://github.com/whiterabbit1983/zed-defold.git
cd zed-defold
-
Open Zed and install the dev extension:
- Press
Ctrl+Shift+P(Windows/Linux) orCmd+Shift+P(macOS) - Type
zed: install dev extension - Select the command and navigate to this extension's directory
- Zed will automatically compile and install the extension
- Press
-
Done! The extension will appear in your installed extensions list.
Note: Zed will automatically install the required
wasm32-wasip1Rust target and compile the extension if needed. You can skip the manual steps below.
Manual Build and Installation (Advanced)
If you prefer to build manually or Zed's auto-compilation doesn't work:
- Install the WebAssembly target (if not already installed):
rustup target add wasm32-wasip1
- Build the extension:
cargo build --release --target wasm32-wasip1
This creates target/wasm32-wasip1/release/zed_defold.wasm
- Install using Zed:
- Press
Ctrl+Shift+P(Windows/Linux) orCmd+Shift+P(macOS) - Type
zed: install dev extension - Navigate to this extension's directory
- Zed will register the pre-built extension
- Press
Prerequisites
- Rust (latest stable version) - for manual builds
- Zed editor installed
Setup for Build Tasks
Prerequisites
- Install Defold: Download from https://defold.com/download/
- Install bob.jar: Defold's command-line build tool
- Download from: https://github.com/defold/defold/releases
- Or use the one from your Defold installation
Environment Variables
To use build tasks, add these to your shell profile (~/.bashrc, ~/.zshrc, or Windows Environment Variables):
# Path to bob.jar (required for build tasks)
export BOB_JAR="/path/to/bob.jar"
# Defold credentials (optional, needed for cloud builds)
export DEFOLD_EMAIL="your.email@example.com"
export DEFOLD_AUTH="your_auth_token"
# Android signing (optional, for Android bundles)
export ANDROID_KEYSTORE="/path/to/keystore.keystore"
export ANDROID_KEYSTORE_PASS="your_password"
export ANDROID_KEYSTORE_ALIAS="your_alias"
# iOS signing (optional, for iOS bundles)
export IOS_IDENTITY="iPhone Developer: Your Name"
export IOS_PROVISIONING="/path/to/profile.mobileprovision"
Getting Your Auth Token
- Open Defold Editor
- Go to File → Preferences
- Copy your authentication token from the General tab
Alternative: Shell Scripts
If you prefer shell scripts over Zed tasks, create these in your project:
build.sh (macOS/Linux):
#!/bin/bash
java -jar "$BOB_JAR" \
--email "$DEFOLD_EMAIL" \
--auth "$DEFOLD_AUTH" \
build
bundle.sh (macOS/Linux):
#!/bin/bash
PLATFORM=${1:-js-web}
java -jar "$BOB_JAR" \
--email "$DEFOLD_EMAIL" \
--auth "$DEFOLD_AUTH" \
--platform "$PLATFORM" \
--bundle-output build/bundle \
--variant debug \
resolve build bundle
Make them executable:
chmod +x build.sh bundle.sh
Then run from Zed's terminal:
./build.sh
./bundle.sh x86_64-win32
Available Platforms
js-web- HTML5x86_64-win32- Windows 64-bitx86_64-macos/arm64-macos- macOS Intel/Apple Siliconx86_64-linux- Linux 64-bitarm64-android/armv7-android- Androidarm64-ios/x86_64-ios- iOS
Build Tasks
While Zed extensions don't support custom commands (yet), you can use Zed's task system to run Defold build commands:
Quick Install
Use the installer script from the scripts/ folder of this repository.
Run from your Defold project root:
Windows:
# From your Defold project root
path\to\zed-defold\scripts\install-tasks.ps1
Linux/macOS:
# From your Defold project root
/path/to/zed-defold/scripts/install-tasks.sh
Manual Setup (All platforms)
- Copy
defold-tasks.jsonfrom this repository to.zed/tasks.jsonin your Defold project - Set up environment variables (see Environment Variables section above)
- Run tasks via
Ctrl+Shift+P→ "task: spawn"
Available tasks:
- Resolve Dependencies - Download project dependencies
- Clean Build - Clean the build folder
- Build - Build the project
- Bundle - Bundle for HTML5, Windows, macOS, Linux, Android, iOS
Build Tasks Troubleshooting
"Could not find or load main class"
- Check that
BOB_JARenvironment variable points to a valid bob.jar file - Download bob.jar from https://github.com/defold/defold/releases
"Authentication required"
- Set
DEFOLD_EMAILandDEFOLD_AUTHenvironment variables - Or remove
--emailand--authfrom task arguments for local builds
"Keystore not found"
- Check that keystore paths in environment variables are correct
- Or remove keystore arguments from Android bundle tasks
Code Snippets
Note: Zed extensions do NOT support bundled snippets. Install them separately using the provided script.
Quick Install Snippets
Use the installer script from the scripts/ folder of this repository:
Windows:
path\to\zed-defold\scripts\install-snippets.ps1
Linux/macOS:
/path/to/zed-defold/scripts/install-snippets.sh
Manual Installation
If you prefer to install snippets manually:
Windows:
# Create snippets directory
New-Item -ItemType Directory -Force -Path "$env:APPDATA\Zed\snippets"
# Copy the snippets file
Copy-Item defold-snippets.json "$env:APPDATA\Zed\snippets\defold.json"
macOS:
# Create snippets directory
mkdir -p "$HOME/Library/Application Support/Zed/snippets"
# Copy the snippets file
cp defold-snippets.json "$HOME/Library/Application Support/Zed/snippets/defold.json"
Linux:
# Create snippets directory
mkdir -p ~/.config/zed/snippets
# Copy the snippets file
cp defold-snippets.json ~/.config/zed/snippets/defold.json
After installation, restart Zed or run zed: reload extensions.
Available Snippets
The extension provides 26 code snippets for common Defold patterns:
Lifecycle Functions
init- Initialize scriptfinal- Finalization logicupdate- Frame updatefixed_update- Fixed timestep updateon_message- Message handlingon_input- Input handlingon_reload- Hot-reload handling
GUI Functions
gui_init- GUI initializationgui_on_message- GUI message handlinggui_on_input- GUI input handling
Common Patterns
factory_create- Create object from factorygo_animate- Animate game objectmsg_post- Post messagego_property- Define script propertytimer_delay- Create timerhttp_request- HTTP requestacquire_input- Acquire input focuscollision_response- Handle collisioncontact_point_response- Handle contact pointmodule- Lua module template
GUI Functions
gui_init- GUI initializationgui_on_message- GUI message handlinggui_on_input- GUI input handlinggui_animate- Animate GUI node
Property Annotations
property- Define script propertyclass- Annotate script classfield- Add field annotationselftype- Annotate self parameterscript_template- Complete script with properties
Usage Example
Type init and press Tab (or Enter) to insert:
function init(self)
-- Initialization logic
end
No external dependencies needed! Everything is bundled in the project.
Troubleshooting
License
Apache-2.0
Contributing
Contributions are welcome! Please feel free to submit issues and pull requests.