Zed
The BAML extension for Zed provides syntax highlighting and language server support for editing BAML files.
Installation
- Open Zed
- Open the Extensions panel: Zed → Extensions (or press
Cmd+Shift+Xon macOS) - Search for “baml”
- Click Install
The extension will automatically download and configure the BAML language server.
Features
Opening the BAML Playground
The BAML Playground runs as a local server and can be accessed via your browser:
- Open the Command Palette with
Cmd+Shift+P(macOS) orCtrl+Shift+P(Linux) - Search for “open language server logs” and select dev: open language server logs
- In the LSP Logs panel, search for “Starting Playground server on”
- Copy the URL shown (e.g.,
127.0.0.1:3704) - Open that URL in your browser to access the playground
The playground server starts automatically when the BAML language server initializes. If you don’t see the message, try restarting the language server.
Why can’t I just click “Open Playground” like in VS Code?
In VS Code, Cursor, and JetBrains, you’ll see an “Open Playground” button above each BAML function. Unfortunately, Zed doesn’t yet support the LSP features needed to make this work:
- Code Lens — the inline buttons above functions
- workspace/executeCommand — executing editor commands from LSP
Once Zed adds these features, the playground will be accessible with a single click. Until then, the LSP logs workaround above is the way to go. You can follow the linked GitHub issues to track progress.
How It Works
The Zed extension includes:
- Tree-sitter grammar: Provides accurate syntax highlighting based on the BAML tree-sitter grammar
- Language Server: Connects to the BAML Language Server for features like jump-to-definition, diagnostics, and more
Setting Environment Variables
You can set environment variables (like API keys) in the BAML Playground via your browser. Click on the Settings button in the playground to configure them.
Alternatively, you can set environment variables in your shell or through a .env file in your project root. The BAML language server will pick up variables from your environment.
Environment variables set in the playground are stored locally and persist between sessions.
Troubleshooting
Extension not appearing
Make sure you’re running a recent version of Zed. The BAML extension requires Zed’s extension system.
Language Server not starting
If the language server fails to start:
- Check the Zed logs for errors
- Make sure you have an internet connection (the extension downloads the language server on first use)
- Try reinstalling the extension
Syntax highlighting not working
Ensure your files have the .baml extension. The extension only activates for files with this extension.
Source Code
The Zed extension is developed as part of the BAML monorepo:
- Extension source: github.com/BoundaryML/baml
- Tree-sitter grammar: github.com/BoundaryML/tree-sitter-baml
Feedback
If you encounter any issues or have feature requests, please: