Skip to main content

Getting Started with Extensions

Glass extensions allow you to extend the editor with custom languages, themes, debuggers, slash commands, and more. Extensions are written in Rust, compiled to WebAssembly, and distributed through the extension registry.

What You Can Build

Extensions can provide:
  • Languages: Add support for new programming languages with syntax highlighting, language servers, and more
  • Themes: Create custom color schemes and icon themes
  • Debuggers: Integrate Debug Adapter Protocol (DAP) servers
  • Slash Commands: Add custom commands to the Assistant panel
  • MCP Servers: Expose Model Context Protocol servers

Prerequisites

Before developing extensions, you need:
1
Install Rust via rustup
2
Extensions are written in Rust and compiled to WebAssembly. Install Rust using rustup:
3
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
4
Rust must be installed via rustup. If you have Rust installed via homebrew or another method, installing dev extensions will not work.
5
Add the WASM target
6
Add the WebAssembly compilation target:
7
rustup target add wasm32-wasip1

Creating Your First Extension

1
Create the extension directory
2
Create a new directory for your extension:
3
mkdir my-extension
cd my-extension
4
Create extension.toml
5
Every extension requires an extension.toml manifest:
6
id = "my-extension"
name = "My Extension"
version = "0.0.1"
schema_version = 1
authors = ["Your Name <[email protected]>"]
description = "Example extension"
repository = "https://github.com/your-name/my-extension"
7
If you’re building a theme extension, suffix the ID with -theme (e.g., monokai-theme).
8
Create Cargo.toml
9
For extensions with custom code, create a Cargo.toml:
10
[package]
name = "my-extension"
version = "0.0.1"
edition = "2021"

[lib]
crate-type = ["cdylib"]

[dependencies]
zed_extension_api = "0.7.0"
11
Use the latest version of zed_extension_api from crates.io. Check compatibility with Glass versions.
12
Create src/lib.rs
13
Implement the Extension trait in src/lib.rs:
14
use zed_extension_api as zed;

struct MyExtension;

impl zed::Extension for MyExtension {
    fn new() -> Self {
        Self
    }
}

zed::register_extension!(MyExtension);

Extension Structure

A complete extension might look like:
my-extension/
  extension.toml          # Extension manifest
  Cargo.toml             # Rust package configuration
  LICENSE                # Required for publishing
  src/
    lib.rs               # Extension implementation
  languages/
    my-language/
      config.toml        # Language configuration
      highlights.scm     # Syntax highlighting
  themes/
    my-theme.json        # Theme definition

Installing as a Dev Extension

To test your extension locally without publishing:
1
Open Glass Extensions
2
Press Cmd+Shift+P (macOS) or Ctrl+Shift+P (Linux/Windows) and run Extensions: Install Dev Extension.
3
Select your extension directory
4
Choose the directory containing your extension.toml file.
5
Check the Extensions page
6
The published version (if any) will be replaced with your dev extension. The Extensions page will show “Overridden by dev extension”.

Debugging Extensions

# View detailed logs
open ~/Library/Logs/Glass/Glass.log

# Run Glass from terminal for verbose output
/Applications/Glass.app/Contents/MacOS/glass --foreground
The --foreground flag shows INFO-level logs including println! and dbg! output from your extension.

Extension API Reference

The Extension trait provides methods for:
  • language_server_command: Return the command to start a language server
  • language_server_initialization_options: Provide LSP initialization options
  • language_server_workspace_configuration: Provide workspace configuration
  • run_slash_command: Execute custom slash commands
  • get_dap_binary: Return debug adapter binary and configuration
  • complete_slash_command_argument: Provide completions for slash command arguments
See the zed_extension_api documentation for the complete API.

Next Steps

Language Extensions

Add support for new programming languages

Theme Extensions

Create custom color schemes

Slash Commands

Build custom Assistant commands

Debugging Extensions

Integrate debug adapters

Example Extensions

Explore these examples in the Glass repository:

Build docs developers (and LLMs) love