A syntax highlighting extension for the Magical card game configuration language in Zed editor.
- Syntax Highlighting: Full syntax highlighting for
.mgclfiles - File Association: Automatically recognizes
.mgclfiles - Bracket Matching: Auto-closes braces, brackets, parentheses, and quotes
- Comment Support: Line comments with
// - Indentation: Smart indentation with 2-space tabs
- Open Zed
- Press
Cmd+Shift+P(Mac) orCtrl+Shift+P(Linux/Windows) - Type "zed: extensions" and press Enter
- Search for "Magical"
- Click Install
-
Clone this repository:
git clone https://github.com/deadbirdi/zed-magical.git
-
Copy to your Zed extensions directory:
# macOS/Linux cp -r zed-magical ~/.config/zed/extensions/magical
-
Restart Zed
The extension highlights:
card,game,deck,zone,action,templateextends,include,mechanic,ability,ruleslet,const,var,function,if,elsetrue,false
- Strings:
"Lightning Bolt",'red' - Numbers:
3,20,1.5 - Booleans:
true,false
- Objects:
{ cost: 1, type: "instant" } - Arrays:
["red", "blue", "green"] - Comments:
// This is a comment
// Simple card definition card "Lightning Bolt" { cost: 1, type: "instant", damage: 3, text: "Lightning Bolt deals 3 damage to any target." } // Playing card card "Ace of Spades" { suit: "spades", rank: "ace", value: 1, color: "black" } // Game definition with template inheritance game "Simple Magic" extends trading_card_template { players: 2, starting_life: 20, zones: { hand: { max_size: 7 }, battlefield: { visible: true } } } // Deck definition deck "Aggro Red" { colors: ["red"], strategy: "aggressive", creatures: 24, spells: 12, lands: 24 } Add to your Zed settings.json:
{ "languages": { "Magical": { "tab_size": 4, "hard_tabs": true, "preferred_line_length": 100 } } }Add to your keymap.json:
[ { "context": "Editor && language == 'Magical'", "bindings": { "cmd-/": "editor::ToggleComments" } } ]- File Extension:
.mgcl - Comment Style:
// line comments - Indentation: 2 spaces (configurable)
- Bracket Pairs:
{},[],(),"",''
This extension uses the tree-sitter-magical grammar for parsing and syntax highlighting.
The extension is ready to use as-is. If you modify the Tree-sitter grammar:
- Update the grammar repository
- Update the
revinextension.toml - Reinstall the extension
Test the extension with these sample files:
# Clone the main language repository git clone https://github.com/deadbirdi/mgcl.git # Open test files in Zed zed mgcl/examples/simple_cards.mgcl zed mgcl/examples/deck_builder.mgclzed-magical/ ├── extension.toml # Extension manifest ├── languages/ │ └── magical/ │ ├── config.toml # Language configuration │ ├── highlights.scm # Syntax highlighting rules │ ├── brackets.scm # Bracket matching rules │ └── outline.scm # Code outline rules ├── README.md # This file └── LICENSE # MIT license -
Check installation path:
ls ~/.config/zed/extensions/magical -
Verify required files exist:
extension.tomllanguages/magical/config.toml
-
Restart Zed completely
- Check file extension is
.mgcl - Manually select language:
- Click language indicator in status bar
- Select "Magical" from dropdown
- Check Zed version (requires Zed with extension support)
If syntax highlighting seems wrong, check the Tree-sitter grammar for updates.
- Fork this repository
- Make your changes
- Test with sample
.mgclfiles - Submit a pull request
- Code folding support
- Better error highlighting
- Code completion (LSP integration)
- Improved bracket matching
- More sophisticated outline view
- Magical Language - Main language implementation
- Tree-sitter Grammar - Parsing grammar
MIT License - see LICENSE file for details.
- Issues: GitHub Issues
- Magical Documentation: Main Repository
- Zed Editor: Zed Documentation