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:Rust must be installed via rustup. If you have Rust installed via homebrew or another method, installing dev extensions will not work.
Creating Your First Extension
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"
[package]
name = "my-extension"
version = "0.0.1"
edition = "2021"
[lib]
crate-type = ["cdylib"]
[dependencies]
zed_extension_api = "0.7.0"
Use the latest version of
zed_extension_api from crates.io. Check compatibility with Glass versions.Extension Structure
A complete extension might look like:Installing as a Dev Extension
To test your extension locally without publishing:Press
Cmd+Shift+P (macOS) or Ctrl+Shift+P (Linux/Windows) and run Extensions: Install Dev Extension.Debugging Extensions
Extension API Reference
TheExtension trait provides methods for:
language_server_command: Return the command to start a language serverlanguage_server_initialization_options: Provide LSP initialization optionslanguage_server_workspace_configuration: Provide workspace configurationrun_slash_command: Execute custom slash commandsget_dap_binary: Return debug adapter binary and configurationcomplete_slash_command_argument: Provide completions for slash command arguments
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:- HTML Extension - Language server integration
- Slash Commands Example - Custom slash commands
- Test Extension - Complete extension features