Advanced syntax highlighting and intellisense for Duet3D RepRapFirmware GCode.
- TextMate-based grammar for .gcode and .g files
- Semantic tokens for enhanced code coloring
- Support for all RepRapFirmware G-code dialects
- 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
- Real-time parameter hints as you type
- Active parameter highlighting during code entry
- Full documentation in signature popups
- Machine context awareness for parameter validation
- Enum value completion based on object model definitions
- Deprecation tracking for object model changes
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
- Open any
.gcodeor.gfile - Press
Ctrl+Spaceto trigger code completion - Hover over any code to see documentation
- Type a space after a G/M-code to see available parameters
G1 - Linear Move
G1 X10 Y20 Z5 F1000 ; Move to position with 1000mm/min speed- Hover over
G1to see full documentation - Press
Ctrl+SpaceafterG1to 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
endifgcode-rrf- RepRapFirmware G-code (default for .gcode and .g files)gcode-fdm- FDM-specific variantgcode-cnc- CNC-specific variant
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"
}
}
}
}
}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 developmentsrc/
├── 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
The extension leverages MonacoTokens data structures:
gcodeData- Complete G-code reference databasefindGcode()- Look up code informationgetMachineContext()- Machine state contextgetEnumValuesForPath()- Object model enumeration values
- VS Code 1.118.0 or later
- Node.js 18+ (for development)
- 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
This extension uses @duet3d/monacotokens which is licensed under LGPL-2.1.
For issues, feature requests, or contributions, please visit:
- Extension: GitHub Repository
- MonacoTokens: GitHub Repository