vscode-gcode-syntax
vscode-gcode-syntax copied to clipboard
color highlighting
Describe the bug Here is a screenshot of a few more of those highlighting anomalies reported in Issue #40.

To Reproduce Download the surfacing macro from duet3d forum here: https://forum.duet3d.com/topic/26762/surfacing-macro?loggedin=true
; Constants
var Debug = false;
var ProbeThickness = 15.5;
var CoordSystem = 20;
var StepOver = 10;
var DepthOfCut = 0.2;
var FeedRate = 8000;
var ZClearanceHeight = 25;
; Variables
var StartX = 0; ; The X starting position
var StartY = 0; ; The Y starting position
var EndX = 0; ; The X ending position
var EndY = 0; ; The Y ending position
var YDir = 0; ; The direction to go in Y
var YDist = 0; ; The distance to go in Y
var YPos = 0; ; The position in Y to move to
var YDistLeft = 0; ; How much we have left to move in Y
var ZDepth = 0; ; How far down we should be in Z
var XSorE = "End" ; Whether X should move towards the start or the end position
; If the printer hasn't been homed, home it
if !move.axes[0].homed || !move.axes[1].homed || !move.axes[2].homed
G28
; Adjust probe for low speed probing
M558 K0 P8 C"!io3.in" H20 F120 T300 ; Z probe number - Z probe switch type - probe recovery 1s probe speed and travel speed
G31 K0 P500 X0 Y0 Z0 ; Set trigger value - set offset and trigger height - Z probe number
M291 P"Insert your surfacing bit into your spindle and position it above the probe plate" R"Probing" S3 X1 Y1 Z1
; Set bit above center of probe
G91 ; relative positioning
; Probe Z component
G38.2 Z{move.axes[2].userPosition - (var.ProbeThickness + 2.25)} ; seek until the probe circuit is closed Z-axis 25 mm
G0 Z{var.ZClearanceHeight} ; rapid move Z axis 5 mm
G10 P1 L{var.CoordSystem} Z{var.ProbeThickness + var.ZClearanceHeight} ; store relative probe offset for coordinates system 1
G90 ; Absolute positioning
M291 P"Move to the starting X Y position for surfacing" R"Start Position" S3 X1 Y1 Z0
set var.StartX = move.axes[0].userPosition;
set var.StartY = move.axes[1].userPosition;
if var.Debug
M118 P0 S{"StartX = " ^ var.StartX} L2
M118 P0 S{"StartY = " ^ var.StartY} L2
M291 P"Move to the ending X Y position for surfacing" R"End Position" S3 X1 Y1 Z0
set var.EndX = move.axes[0].userPosition;
set var.EndY = move.axes[1].userPosition;
if var.Debug
M118 P0 S{"EndX = " ^ var.EndX} L2
M118 P0 S{"EndY = " ^ var.EndY} L2
M291 P"Are you ready to begin surfacing?" S3 X0 Y0 Z0
; Figure out which direction in Y we are going
if var.EndY < var.StartY
set var.YDir = -1;
elif var.EndY > var.StartY
set var.YDir = 1;
else
set var.YDir = 0;
if var.Debug
M118 P0 S{"YDir = " ^ var.YDir} L2
set var.YDist = {abs(var.StartY - var.EndY)};
if var.Debug
M118 P0 S{"YDist = " ^ var.YDist} L2
; Begin surfacing loop
while true
if var.Debug
M118 P0 S"Begin Layer Loop" L2;
set var.ZDepth = {var.ZDepth - var.DepthOfCut};
set var.YDistLeft = {var.YDist};
; go to the start X and Y position then down to Z Depth
if var.Debug
M118 P0 S{"Move to start X" ^ var.StartX ^ ",Y" ^ var.StartY} L2
G0 X{var.StartX} Y{var.StartY}
if var.Debug
M118 P0 S{"Move to start Z" ^ var.ZDepth} L2
G1 Z{var.ZDepth}
; we should be at the Start X position so move to the End X position
if var.Debug
M118 P0 S{"Move to X" ^ var.EndX} L2
G1 X{var.EndX} F{var.FeedRate}
set var.XSorE = "Start"
while var.YDistLeft > var.StepOver
if var.Debug
M118 P0 S"Begin Y Loop" L2
; move in Y by StepOver
set var.YPos = {move.axes[1].userPosition + (var.StepOver * var.YDir)}
if var.Debug
M118 P0 S{"Move to Y" ^ var.YPos} L2
G1 Y{var.YPos} F{var.FeedRate}
set var.YDistLeft = {var.YDistLeft - var.StepOver}
if var.XSorE == "Start"
; move X to the start position
if var.Debug
M118 P0 S{"Move to X" ^ var.StartX} L2
G1 X{var.StartX} F{var.FeedRate}
set var.XSorE = "End"
else
; move X to the end position
if var.Debug
M118 P0 S{"Move to X" ^ var.EndX} L2
G1 X{var.EndX} F{var.FeedRate}
set var.XSorE = "Start"
; move in Y the rest of the distance left
set var.YPos = {move.axes[1].userPosition + (var.YDistLeft * var.YDir)}
if var.Debug
M118 P0 S{"Move to Y" ^ var.YPos} L2
G1 Y{var.YPos} F{var.FeedRate}
; one last move in X
if var.XSorE == "Start"
; move X to the start position
if var.Debug
M118 P0 S{"Move to X" ^ var.StartX} L2
G1 X{var.StartX} F{var.FeedRate}
set var.XSorE = "End"
else
; move X to the end position
if var.Debug
M118 P0 S{"Move to X" ^ var.EndX} L2
G1 X{var.EndX} F{var.FeedRate}
set var.XSorE = "Start"
G0 Z{var.ZClearanceHeight} ; get out of the way
M400 ; wait for the movement buffer to catch up
M291 P"Surface another layer?" S3 X0 Y0 Z0 ; then prompt the user if they want to do another layer
Environment / Version: macOS 12.5.1 VSCode 1.69.2 Extension 0.7.4
These printer macros are going to be tough to fix the highlighting on because of the nature of them being non-standard G-Code. with functions and keywords more like programming.
It is akin to something that hasn't been run through a post-processor yet. I'm not 100% sure how to deal with this, but once we dial in the machine choices and the language server, it might make doing this easier.
This issue has been automatically marked as stale because it has not had recent activity.
I just installed v0.7.7 and I'm seeing syntax highlighting issues in a standard gcode file when there is a string of text for a command like M117 or M0:
The gcode can be found here, though it seems like the Linguist grammar used by GitHub's syntax highlighting is failing in some of the same places: https://gist.github.com/rbuckton/93060c4c628235ac5382ca477a072fa3
This issue has been automatically marked as stale because it has not had recent activity.