CDM Language Support
Editor extension for the CDM (Contextual Data Model) language. Works with VS Code, Cursor, and other editors supporting the VS Code extension API.
Features
- ✅ Syntax highlighting - Basic syntax highlighting for CDM files
- ✅ Real-time validation - Errors and warnings appear as you type
- ✅ Error diagnostics - Inline error messages with severity indicators
- 🚧 Code completion - Autocomplete for types, keywords, and more (coming soon)
- 🚧 Go to definition - Jump to type and model definitions (coming soon)
- 🚧 Hover information - See type information on hover (coming soon)
- 🚧 Document formatting - Format files on save (coming soon)
Requirements
The extension requires the cdm CLI, which includes the language server. It will be downloaded automatically on first activation if not already installed.
Automatic Installation
When you first open a .cdm file, the extension will:
- Check if
cdm is already in your PATH
- If not found, automatically download the appropriate binary for your platform
- Store it in the extension's global storage directory
Manual Installation (Optional)
If you prefer to install the CLI manually:
# From the CDM repository root
cargo install --path crates/cdm
Or download a pre-built binary from the releases page.
Installation
From VSIX (Local Development)
Build the extension:
cd editors/cdm-extension
npm install
npm run compile
npm run package
Install the generated .vsix file:
# VS Code
code --install-extension cdm-0.1.0.vsix
# Cursor
cursor --install-extension cdm-0.1.0.vsix
From Marketplace
- VS Code: Search for "CDM Language Support" in the VS Code extensions marketplace
- Open VSX (Cursor, VSCodium, etc.): Search for "CDM Language Support" in the Open VSX Registry
Extension Settings
This extension contributes the following settings:
cdm.cli.path: Path to the cdm CLI binary (default: "cdm")
cdm.format.indentSize: Number of spaces for indentation when formatting (default: 2)
cdm.validation.checkIds: Check for missing entity IDs and show warnings (default: true)
cdm.trace.server: Trace LSP communication for debugging (default: "off")
Commands
CDM: Restart Language Server - Restart the CDM language server
CDM: Update CLI - Check for and install updates to the CDM CLI
Usage
- Open or create a
.cdm file
- Start editing - the language server will provide real-time validation
- Errors and warnings will appear inline with red/yellow squiggles
- Hover over errors to see detailed messages
Example
Create a file schema.cdm:
// Type alias with validation
Email: string {
@validation { format: "email", max_length: 320 }
} [#1](https://github.com/cdm-lang/cdm/issues/1)
// Model with fields
User {
id: string [#1](https://github.com/cdm-lang/cdm/issues/1)
email: Email [#2](https://github.com/cdm-lang/cdm/issues/2)
name: string [#3](https://github.com/cdm-lang/cdm/issues/3)
status: "active" | "pending" = "pending" [#4](https://github.com/cdm-lang/cdm/issues/4)
@sql { table: "users" }
} [#10](https://github.com/cdm-lang/cdm/issues/10)
The extension will:
- Highlight syntax
- Validate the schema in real-time
- Show errors if you reference undefined types
- Warn about missing entity IDs (if
checkIds is enabled)
Troubleshooting
Language server not starting
Verify cdm is in your PATH:
which cdm
Check the output channel:
- View → Output
- Select "CDM Language Server" from the dropdown
Try updating the CLI:
- Open Command Palette (Ctrl+Shift+P / Cmd+Shift+P)
- Run "CDM: Update CLI"
Enable verbose logging:
- Set
cdm.trace.server to "verbose" in settings
- Check the "CDM Language Server Trace" output channel
Errors not showing up
- Ensure the file has a
.cdm extension
- Check if the language mode is set to "CDM" (bottom right of the editor)
- Try restarting the language server with the command palette (Ctrl+Shift+P / Cmd+Shift+P): "CDM: Restart Language Server"
Development
Running the Extension in Development Mode
Open the extension directory in your editor:
cd editors/cdm-extension
code . # or: cursor .
Install dependencies:
npm install
Press F5 to open an Extension Development Host window
Open a .cdm file to test the extension
Building for Production
npm run compile
npm run package
This creates a .vsix file that can be installed in any compatible editor.
Publishing
Publishing is automated via GitHub Actions. To release a new version:
# From the repository root, use the just command:
just release-extension 0.2.0
This will:
- Update the version in
package.json
- Commit the version change
- Create a git tag (
cdm-extension-v0.2.0)
Then push to trigger the release workflow:
git push origin main cdm-extension-v0.2.0
The workflow automatically:
- Builds and packages the extension
- Publishes to VS Code Marketplace
- Publishes to Open VSX Registry
- Creates a GitHub Release with the
.vsix file
Required secrets: VSCE_PAT and OVSX_PAT must be configured in GitHub repository settings.
Manual Publishing
For local development or manual releases:
npm run publish:vscode # VS Code Marketplace only
npm run publish:openvsx # Open VSX Registry only
npm run publish # Both marketplaces
Known Issues
- Code completion not yet implemented
- Go-to-definition not yet implemented
- Hover information not yet implemented
- Multi-file validation (via
extends) shows errors for inherited types
See the GitHub issues for a full list.
Release Notes
0.1.0 (Initial Release)
- Basic syntax highlighting
- Real-time validation with diagnostics
- Error and warning reporting
- Language server integration
Contributing
Contributions are welcome! Please see the CDM repository for contribution guidelines.
License
MIT