Datascript Language Support for VS Code
A Visual Studio Code extension that brings syntax highlighting, basic formatting, and editor-friendly defaults to the Datascript DSL.
Features
- TextMate grammar for Datascript keywords, Mongo DSL operators, comments, strings, numbers, and built-ins.
- Document formatter that normalizes indentation and block structure (
Ctrl+Alt+F or Datascript: Format Document).
- Run the currently active Datascript file via Deno (
Ctrl+Alt+X on Windows/Linux or Cmd+Alt+X on macOS, or use Datascript: Run Active File) using the bundled main.ts interpreter when no workspace entry point is configured.
- Inline configuration setting (
datascript.format.indentSize) to align formatter indentation with project style.
More language services (diagnostics, hover docs, completions) are planned.
Development
npm install
npm run watch
In another terminal launch VS Code in extension development mode, pointing to the extension folder:
code --extensionDevelopmentPath "path\to\datascript\vscode-extension"
Open a .ds file, trigger the formatter, and live edits will rebuild thanks to the watch task.
Building & Packaging
npm run build – compile TypeScript into dist/.
npm run package – create a .vsix distributable using @vscode/vsce.
To publish, ensure you have a Personal Access Token (VSCE_PAT) for the Marketplace, then run:
npx @vscode/vsce publish
Runtime Settings
datascript.runtime.entryPoint – relative or absolute path to main.ts (defaults to <workspace>/main.ts). The extension will also search parent folders, the previously selected global interpreter, and the bundled main.ts shipped with the extension, so most users never need to configure this.
datascript.runtime.denoPath – command used to invoke Deno (defaults to deno).
Testing
Formal integration tests are not wired yet. Future work will reuse @vscode/test-electron to spin up a headless VS Code and validate formatting + grammar expectations.
Repository Integration
This folder lives inside the main Datascript repo. Remember to regenerate the docs (docs/) or runtime pieces in tandem when language changes affect syntax highlighting/formatting.