Full MQL5 (MetaQuotes Language 5) language support for the Zed code editor — syntax highlighting, native language server, and smart editing features.
- Custom tree-sitter grammar extending C++ with MQL5 keywords (
input,sinput,datetime,color,uchar,ushort,uint,ulong) - 400+ built-in functions highlighted by category (Trading, Indicators, Array, Chart, Object, String, Math, File, etc.)
- MQL5 constants (
PERIOD_H1,OBJ_LABEL,clrRed, etc.), built-in variables (_Symbol,_Point,_Digits), types (MqlTick,ENUM_*), and event handlers (OnInit,OnTick,OnChartEvent) #propertyand#importdirectives, SQL injection highlighting inDatabasePrepare()calls
- Autocomplete — context-aware: after
.shows class members, after::shows enum values/static members, general shows all builtins + workspace symbols - Go-to-definition — cross-file navigation for functions, classes, enums, variables, macros, and
#includepaths - Find all references (
Shift+F12) — scope-aware usage search across the workspace - Rename (
F2) — scope-aware cross-file rename (prevents renaming builtins) - Hover info — type signatures, documentation, field lists for structs
- Signature help — parameter hints while typing function arguments
- Diagnostics — unresolved includes, duplicate definitions, undeclared function calls, wrong argument count
- Color swatches — inline color preview for
C'r,g,b'literals, named colors (clrRed,clrBlue, etc.), and0xRRGGBBhex colors - Auto-import —
#includeadded automatically when completing symbols from other files - Code formatting —
Shift+Alt+Fto format MQL5 code - Inlay hints — parameter names shown inline at function call sites
- Semantic highlighting — builtins visually distinct from user-defined symbols
- Document outline — symbol navigation in sidebar
- Workspace symbols — fuzzy search across all indexed files
- Include resolution — handles MQL5 backslash paths (
Trade\Trade.mqh), transitive include scanning - MQL5 stdlib indexed on startup — scans
MQL5/Include/for standard library symbols
- Auto-indentation, code folding, bracket matching
- Vim text objects (
vafselect function,vacselect class,vibselect in braces) - Comment toggling (
//and/* */)
- Open Zed
Cmd+Shift+P-> "zed: extensions"- Search for "MQL5"
- Click Install
git clone https://github.com/MichalBPL/zed-mql5.git
cd zed-mql5
# In Zed: Cmd+Shift+P -> "zed: install dev extension" -> select this directoryThe extension uses mql5-language-server, a native MQL5 language server built in Rust with tower-lsp and tree-sitter.
Automatic: The extension downloads the binary automatically on first use.
Manual: Build from source:
git clone https://github.com/MichalBPL/mql5-language-server.git
cd mql5-language-server
cargo build --releaseThen configure in Zed settings (Cmd+,):
{
"lsp": {
"mql5-lsp": {
"binary": {
"path": "/path/to/mql5-language-server/target/release/mql5-lsp"
}
}
}
}- 397+ built-in functions with signatures and documentation
- 72 enum types with all values
- 9 struct types with fields (MqlTick, MqlRates, MqlTradeRequest, etc.)
- 172 named constants
- 12 predefined global variables
- 140+ named color constants
Custom tree-sitter grammar extending tree-sitter-cpp with:
inputandsinputasstorage_class_specifiernodesdatetime,color,string,uchar,ushort,uint,ulongasprimitive_typenodes
zed-mql5/
├── extension.toml # Extension metadata, grammar + LSP config
├── Cargo.toml # Rust extension build config
├── src/
│ └── mql5.rs # Extension entry point (LSP launcher)
├── languages/mql5/
│ ├── config.toml # Language config (brackets, comments, file types)
│ ├── highlights.scm # Syntax highlighting queries
│ ├── indents.scm # Auto-indentation rules
│ ├── folds.scm # Code folding regions
│ ├── textobjects.scm # Vim text objects
│ ├── outline.scm # Symbol outline for navigation
│ ├── injections.scm # SQL injection in DatabasePrepare()
│ └── redactions.scm # Content redaction
├── stubs/ # MQL5 header stubs (for clangd users)
└── grammars/mql5/ # Tree-sitter grammar source
Add these to your ~/.config/zed/settings.json for the best experience:
{
"languages": {
"MQL5": {
"inlay_hints": {
"enabled": true,
"show_parameter_hints": true,
"show_type_hints": true
}
}
},
"show_signature_help_after_edits": true,
"experimental.theme_overrides": {
"syntax": {
"function.special": {
"color": "#eed49f"
}
}
}
}| Setting | What it does |
|---|---|
inlay_hints.enabled |
Shows parameter names inline at function call sites |
show_signature_help_after_edits |
Auto-shows function signature when you type ( |
function.special theme override |
Gives MQL5 builtin functions (e.g. OrderSend, iRSI) a distinct warm color vs. user-defined functions |
For users who prefer clangd, the stubs/ directory provides C++ header stubs for MQL5 built-in APIs. See clangd-config-template.yaml for configuration. Note that clangd cannot fully parse MQL5 and many diagnostics must be suppressed.
- Tree-sitter syntax errors: The grammar is C++-based, so some valid MQL5 constructs (color literals
C'r,g,b',type& arr[]reference arrays, dot on pointers) produce parse errors. These are suppressed by the LSP. - Type resolution: Dot-completion type resolution uses AST analysis but complex expression chains may not resolve.
- Scope-aware rename: Works for most cases but cannot distinguish same-named variables in different unrelated scopes.
- Fork the repository
- Make changes
- Test with MQL5 code samples (see
example.mq5) - Submit a pull request
MIT