AutoHotkey v1 for Zed
Full AutoHotkey v1 support for Zed: syntax highlighting, LSP, and debugging.
Note: Requires Windows (AutoHotkey is Windows-only).
Features
Syntax Highlighting
- Full syntax highlighting for
.ahkfiles - Auto-indentation and bracket matching
Language Server (LSP)
- Go-to-definition - Navigate to function/class definitions
- Hover documentation - View function signatures and documentation
- Code completions - IntelliSense for AutoHotkey keywords, functions, and variables
- Diagnostics - Real-time error and warning detection
- Document outline - Jump to functions, classes, and labels
- Symbol search - Find symbols across your project
Running Scripts
To enable the "Run" button in the gutter, add a task to your Zed config:
Open Command Palette → "zed: open tasks"
Add a task with the
ahk-scripttag:[ { "label": "Run AutoHotkey Script", "command": "& 'C:\\Program Files\\AutoHotkey\\AutoHotkey.exe'", "args": ["$ZED_FILE"], "tags": ["ahk-script"] } ]Note: The
& '...'syntax is required for PowerShell when the path contains spaces. Adjust the path to your AutoHotkey installation.Click the run button in the gutter or use Command Palette → "task: spawn" (if you don't see the button, try reopening the IDE).
Debugging
Debug AutoHotkey v1 scripts with breakpoints, stepping, and variable inspection.
Features:
- Set breakpoints (click gutter or
F9) - Step over (
F10), step into (F11), step out (Shift+F11) - Inspect local and global variables
- View call stack
- Watch expressions
Setup:
Create
.zed/debug.jsonin your project root:[ { "label": "Debug Current Script", "adapter": "autohotkey", "request": "launch", "program": "$ZED_FILE", "stopOnEntry": true } ]Open a
.ahkfile and pressF5or use Command Palette → "debugger: start"
Configuration options:
| Option | Type | Default | Description |
|---|---|---|---|
program |
string | required | Path to the .ahk script ($ZED_FILE for current file) |
stopOnEntry |
boolean | true |
Break on the first line |
args |
array | [] |
Command-line arguments for the script |
port |
integer | 9005 |
DBGp debugger port |
Note: The debug adapter includes a bundled AutoHotkey runtime. No separate installation required for debugging.
Supported Syntax
Comprehensive AutoHotkey v1 syntax support including:
- Comments, strings, numbers, arrays, and operators
- Control flow (
if,while,loop,for,switch,try/catch) - Functions, classes, objects, and hotkeys/hotstrings
- Built-in commands, variables, and directives
For full AutoHotkey v1 syntax reference, see the official documentation.
Installation
From Zed Extensions (Recommended)
- Open Zed
- Open Command Palette (
Ctrl+Shift+P) - Run "zed: extensions"
- Search for "AutoHotkey"
- Click Install
From Source (Development)
- Clone this repository
- Open Command Palette → "Extensions: Install Dev Extension"
- Select the cloned folder
Development
Prerequisites
- Node.js 18+
- npm
Commands
npm install # Install dependencies
npm run generate # Generate parser from grammar.js
npm run test # Run test suite
npm run parse <file> # Parse a file and show ASTMaking Changes
After modifying grammar.js or query files:
- Run
npm run generate - Run
npm run testto verify changes - Commit and push to GitHub
- Update
revinextension.tomlto the new commit hash - Delete the
grammars/folder (Zed's cache) - Reinstall the dev extension in Zed
See TREE_SITTER_NOTES.md for technical details, debugging tips, and technical lessons learned.
Contributing
Contributions are welcome! Please:
- Check existing issues or open a new one
- Fork the repository
- Create a branch for your changes
- Add tests in
test/corpus/for new syntax - Submit a pull request
Credits
The debug adapter is based on alfredomtx/autohotkey-debug-adapter, a fork of helsmy/autohotkey-debug-adapter with DAP protocol fixes for Zed compatibility.
License
MIT License - see LICENSE for details.