RRF-GCode VS Code Extension
Advanced syntax highlighting and intellisense for Duet3D RepRapFirmware GCode.
Features
Syntax Highlighting
- TextMate-based grammar for .gcode and .g files
- Semantic tokens for enhanced code coloring
- Support for all RepRapFirmware G-code dialects
Intellisense & Code Completion
- G/M/T-code completion with full documentation
- Parameter completion with descriptions and valid value suggestions
- Expression completion for
{...} blocks
- Deprecated code/parameter warnings to encourage best practices
- G-code documentation on hover
- Parameter descriptions with enumerated values
- Deprecation notices for outdated codes and parameters
Signature Help
- Real-time parameter hints as you type
- Active parameter highlighting during code entry
- Full documentation in signature popups
Object Model Integration
- Machine context awareness for parameter validation
- Enum value completion based on object model definitions
- Deprecation tracking for object model changes
Installation
The extension is powered by the @duet3d/monacotokens library, which provides:
- Comprehensive G-code database with parameter information
- Object model definitions and enumerations
- Real-time machine context tracking
- Search and validation capabilities
Usage
Basic Commands
- Open any
.gcode or .g file
- Press
Ctrl+Space to trigger code completion
- Hover over any code to see documentation
- Type a space after a G/M-code to see available parameters
Examples
G1 - Linear Move
G1 X10 Y20 Z5 F1000 ; Move to position with 1000mm/min speed
- Hover over
G1 to see full documentation
- Press
Ctrl+Space after G1 to see available parameters
- All parameters have descriptions and valid value suggestions
M104 - Set Tool Temperature
M104 S200 T0 ; Set tool 0 to 200°C
- See parameter descriptions and valid temperature ranges
- Warnings for deprecated parameters
Conditional G-code
if move.axes[0].letter == "X" ; Object model field completion
G1 X100
endif
Supported Languages
gcode-rrf - RepRapFirmware G-code (default for .gcode and .g files)
gcode-fdm - FDM-specific variant
gcode-cnc - CNC-specific variant
Configuration
The extension works out of the box with no configuration required. To customize behavior, add the following to VS Code settings:
{
"editor.semanticTokenColorCustomizations": {
"enabled": true,
"[GitHub Light]": {
"rules": {
"parameter:deprecated": {
"strikethrough": true,
"foreground": "#a9a9a9"
}
}
}
}
}
Development
Building from Source
npm install # Install dependencies
npm run esbuild # Build with source maps
npm run esbuild-base -- --minify # Production build
npm run esbuild-watch # Watch mode for development
Project Structure
src/
├── extension.ts # Main extension entry point
├── providers/ # VS Code providers
│ ├── completion.ts # Completion item provider
│ ├── hover.ts # Hover provider
│ └── signature.ts # Signature help provider
└── utils/ # Utilities
MonacoTokens Data
The extension leverages MonacoTokens data structures:
gcodeData - Complete G-code reference database
findGcode() - Look up code information
getMachineContext() - Machine state context
getEnumValuesForPath() - Object model enumeration values
Requirements
- VS Code 1.118.0 or later
- Node.js 18+ (for development)
Release Notes
0.0.1
- Initial release with MonacoTokens integration
- Added completion provider for G/M/T-codes and parameters
- Added hover provider with full documentation
- Added signature help for parameter hints
- Added semantic tokens for enhanced syntax highlighting
- Support for RepRapFirmware G-code, FDM, and CNC variants
License
This extension uses @duet3d/monacotokens which is licensed under LGPL-2.1.
Contributing
For issues, feature requests, or contributions, please visit:
Resources