Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement HLSL syntax highlighting, and use HLSL grammar to highlight Cg blocks in ShaderLab files #20129

Merged
merged 2 commits into from
Feb 20, 2017

Conversation

tgjones
Copy link
Contributor

@tgjones tgjones commented Feb 7, 2017

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:

shaderlab-before

And here's what it looks like using this new ShaderLab grammar:

shaderlab-after

This is what standalone HLSL syntax highlighting looks like using the new HLSL grammar:

hlsl

This is my first contribution to VSCode - I'm very happy to make changes, just let me know what I got wrong :)

And use HLSL grammar to highlight CG blocks in ShaderLab shaders.
@msftclas
Copy link

msftclas commented Feb 7, 2017

Hi @tgjones, I'm your friendly neighborhood Microsoft Pull Request Bot (You can call me MSBOT). Thanks for your contribution!

In order for us to evaluate and accept your PR, we ask that you sign a contribution license agreement. It's all electronic and will take just minutes. I promise there's no faxing. https://cla.microsoft.com.

TTYL, MSBOT;

@msftgits
Copy link

msftgits commented Feb 7, 2017

Hi, I am closing and re-opening this PR to bump the CLA bot. Sorry for the inconvenience!

@msftgits msftgits closed this Feb 7, 2017
@msftgits msftgits reopened this Feb 7, 2017
@msftclas
Copy link

msftclas commented Feb 7, 2017

Hi @tgjones, I'm your friendly neighborhood Microsoft Pull Request Bot (You can call me MSBOT). Thanks for your contribution!
You've already signed the contribution license agreement. Thanks!
We will now validate the agreement and then real humans will evaluate your PR.

TTYL, MSBOT;

@mjbvz
Copy link
Collaborator

mjbvz commented Feb 16, 2017

@aeschli Can you please take a look at this change. It looks good to me but you know much more about the general language support

@aeschli
Copy link
Contributor

aeschli commented Feb 17, 2017

@tgjones Thanks a lot Tim for the great work. Separating HLSL and ShaderLab sounds like a good idea.
Why I'm hesitating and I wanted to talk to @egamma about it, is that this would be the first grammar that we would 'own', where the original version lives in the VSCode repository. For all other languages we import the grammars from other repositories. Having the grammar in a separate repository has the advantage that the grammar can be maintained independently by the original authors or other committers. There's no need for the VSCode team to review and merge every change. Another benefit is that the grammar can be made available to other editors as well.
https://github.com/Microsoft/TypeScript-TmLanguage is an example for such a repository.
We forward issues to that repository and, from time to time, or on request, import the latest grammar to VSCode.
I'd suggest we follow the same model here.
@tgjones What do you think?
That would mean you create your own github repository that just contains the grammar.
In order for us to use it all we need is a friendly open source licence such as MIT.

@tgjones
Copy link
Contributor Author

tgjones commented Feb 17, 2017

@aeschli that sounds very sensible to me. In fact I've already created such a repository, because GitHub's Linguist (used for syntax highlighting on github.com) requires grammars to be in a submodule, and I've got an active PR over there for adding HLSL syntax highlighting. I'll modify this PR once I get back to my computer.

@aeschli
Copy link
Contributor

aeschli commented Feb 20, 2017

Cool. What's missing to the PR is just a grammar update script plus an updated OSSREADME.
If you point me to your repository I can make that change.

@aeschli
Copy link
Contributor

aeschli commented Feb 20, 2017

Ah, I see https://github.com/tgjones/shaders-tmLanguage. I'll make the update.

@aeschli aeschli merged commit 7128e35 into microsoft:master Feb 20, 2017
@aeschli aeschli added this to the February 2017 milestone Feb 20, 2017
@aeschli aeschli added the languages-basic Basic language support issues label Feb 20, 2017
@tgjones
Copy link
Contributor Author

tgjones commented Feb 20, 2017

Great, thanks for merging!

@tgjones tgjones deleted the colorize-shaders branch February 20, 2017 22:23
@github-actions github-actions bot locked and limited conversation to collaborators Mar 27, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
languages-basic Basic language support issues
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants