DWScript for VS Code

DWScript language support for Visual Studio Code, powered by Tree-sitter for accurate and fast syntax highlighting.
Features
- Syntax Highlighting: Rich highlighting for DWScript files (.dws, .pas) using Tree-sitter parsing.
- Semantic Tokens: Enhanced code understanding with semantic token support for keywords, types, functions, and more.
- Incremental Parsing: Efficient updates on document changes for smooth editing experience.
Requirements
- Visual Studio Code ^1.92.0
- Node.js (for development)
Installation
From Marketplace
- Open VS Code.
- Go to Extensions (Ctrl+Shift+X).
- Search for "DWScript" and install.
From Source
- Clone this repository.
- Run
npm install .
- Run
npm run build .
- Run
npm run package to create a .vsix file.
- Install the
.vsix in VS Code via Extensions > Install from VSIX.
Usage
- Open a
.dws or .pas file in VS Code.
- The extension activates automatically and provides syntax highlighting.
How It Works
- Parser Loading: Loads the DWScript Tree-sitter grammar from
@cwbudde/tree-sitter-dwscript .
- Query Execution: Applies
queries/highlights.scm to extract syntax captures from the AST.
- Token Mapping: Maps Tree-sitter captures (e.g.,
@keyword ) to VS Code semantic token types for highlighting.
Development
Prerequisites
Setup
npm install
Build
npm run build # Bundles to out/extension.js
Watch Mode
npm run watch # Rebuilds on changes
Package
npm run package # Creates .vsix file
Testing
Manually verify highlighting by opening .dws or .pas files and checking syntax colors.
Contributing
Contributions are welcome! Please open issues or submit pull requests on GitHub.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Acknowledgments
| |