Implement HLSL syntax highlighting, and use HLSL grammar to highlight Cg blocks in ShaderLab files #20129
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Implements #20128.
In contrast to the existing ShaderLab grammar, this new ShaderLab grammar delegates highlighting of Cg blocks to the separate HLSL grammar (which has the advantage that standalone HLSL files can now be highlighted).
I created both the HLSL and ShaderLab grammars by reading the relevant language documentation, so they should both be up-to-date with available types / keywords / etc.
I also looked at the latest
csharp.tmLanguage
so that my choice of scope names roughly matches what has been done there.Because
.cginc
files are basically HLSL files, and not ShaderLab files, I've removed that file extension from the ShaderLab extension and included it in the HLSL extension.For comparison, here's what ShaderLab syntax highlighting looks like in VSCode 1.9:
And here's what it looks like using this new ShaderLab grammar:
This is what standalone HLSL syntax highlighting looks like using the new HLSL grammar:
This is my first contribution to VSCode - I'm very happy to make changes, just let me know what I got wrong :)