Language capabilities
Every language goes through the same contract, whether built in or contributed by an extension. Nothing in the editor is specific to Rust or TypeScript.
Identification
The LanguageRegistry maps exact file names and extensions to a LanguageDefinition:
| Field | Meaning |
|---|---|
id, name | e.g. rust, "Rust" |
extensions, file_names | e.g. rs; Cargo.lock |
grammar | Built-in Tree-sitter grammar, if any |
server | Language server command, if any |
source | Built-in or the contributing extension |
Detection looks only at the path, never at contents, and falls back to plain text. Registrations that would steal an existing extension or id are rejected, so an extension cannot silently take over .rs.
Built in: Rust (rs), TypeScript (ts, mts, cts), TypeScript JSX (tsx), JavaScript (js, mjs, cjs, jsx) and plain text.
The capability contract
enum Capability { SyntaxHighlighting, Diagnostics, Completion, Hover, Definition,
References, Rename, Formatting, CodeActions }
enum ProviderKind { Syntax, Semantic }
DocumentCapabilities lists what a document can do right now, split by provider kind. Syntax providers are in process and fast; semantic providers are language servers, gated by trust and profile. When both offer a capability, the semantic provider wins. The status bar shows both separately.
| Capability | MVP status |
|---|---|
| Syntax highlighting | Implemented (Tree-sitter) |
| Diagnostics | Implemented (LSP) |
| Go to definition | Implemented (LSP) |
| Completion, hover, references, rename, formatting, code actions | Reported when a server advertises them; no UI yet |
Syntax analysis
- Grammars are compiled into the binary. A grammar's highlight query is compiled the first time a file of that language opens, then cached.
- Each document owns a syntax tree. Edits are applied with
Tree::editand the document is re-parsed incrementally, reading straight from the rope. - Highlights are queried only for the byte range being drawn and reduced to non-overlapping spans of theme-independent classes (
keyword,function,type,string, …). Themes map classes to colours. - Limits protect responsiveness and memory; see lazy loading and resources.
Adding a language
- Declaratively (no code): an extension can map file extensions to a new language id and reuse a built-in grammar. See extensions.
- With a new grammar: add the grammar crate to
ide-languages, aGrammarIdvariant and a registry entry. Grammars are C code; review licence and maintenance first. - With a language server: set
serverin the definition and, if needed, allow it in a profile.