MetaScript for Zed
Native Zed extension for the MetaScript language. Provides Tree-sitter syntax highlighting, LSP integration, auto-indent, code outline, and bracket matching.
Features
- Tree-sitter highlighting -- Full syntax highlighting via the tree-sitter-metascript grammar
- LSP integration -- Completion, hover, go-to-definition, references, rename, diagnostics, inlay hints, and semantic tokens via
msc lsp - Smart indentation -- Auto-indent for blocks, functions, classes, match arms, and JSX
- Code outline -- Symbol list for functions, classes, interfaces, enums, methods, tests
- Bracket matching -- Matching and rainbow brackets for
{},[],() - Injections -- Highlights embedded C code within
@emitstrings
Requirements
- Zed (latest stable)
- msc binary on your system PATH (for LSP features)
To install the MetaScript compiler:
git clone https://github.com/metascriptlang/metascript
cd metascript
zig build installInstallation
From Zed Extensions (when published)
Open Zed, go to Extensions (Cmd+Shift+X), search for "MetaScript", and click Install.
Development / Local Install
- Clone or locate this directory
- In Zed, open the command palette (
Cmd+Shift+P) - Run
zed: install dev extension - Select the
zed/directory
File Types
| Extension | Language |
|---|---|
.ms |
MetaScript |
Note: The
.mtsextension is excluded from this extension to avoid conflicts with TypeScript's ES module files. Use.msas the primary MetaScript file extension.
LSP Features
The MetaScript language server (msc lsp) provides:
- Completion -- Context-aware code completion with type information
- Hover -- Type signatures and documentation on hover
- Go to definition -- Jump to symbol definitions
- Find references -- Find all references to a symbol
- Rename -- Project-wide symbol rename
- Diagnostics -- Inline error and warning reporting
- Inlay hints -- Inline type annotations
- Semantic tokens -- Enhanced highlighting from the language server
Project Structure
zed/
extension.toml -- Extension metadata and grammar reference
Cargo.toml -- Minimal Rust project for LSP shim
src/
lib.rs -- LSP binary discovery (~25 lines)
languages/
metascript/
config.toml -- Language config (comments, brackets, indent)
highlights.scm -- Syntax highlighting (synced from nvim)
indents.scm -- Auto-indentation rules (synced from nvim)
injections.scm -- Embedded language highlighting (synced from nvim)
brackets.scm -- Bracket matching (Zed-specific)
outline.scm -- Code outline / symbol list (Zed-specific)
README.mdQuery Sync
Query files (highlights.scm, indents.scm, injections.scm) are synced from the canonical source in metascript.nvim/queries/metascript/ via the build script:
bun tools/editor-plugin/build.tsThe build script automatically adapts Neovim-specific predicates (#lua-match? to #match?) for Zed compatibility.
License
MIT