Skip to content

Conversation

@dmnsgn
Copy link
Contributor

@dmnsgn dmnsgn commented Dec 25, 2018

Do you want to keep the cool kid syntaxes with their backticks ` ` without compromises? Missing your favourite syntax highlighting in your shaders? This PR is for you.

The idea is simple: prefix your template string with a comment specifying its syntax and there you have it.

Before:
screenshot 2018-12-24 at 23 57 29

After:
screenshot 2018-12-24 at 23 57 18

Tried and tested in both VSCode and Atom:

VSCode

You just need this extension: https://marketplace.visualstudio.com/items?itemName=bierner.comment-tagged-templates

Atom

Install the following packages:

Set your file grammar to language-babel-extension.
Go to Language Babel settings, look for JavaScript Tagged Template Literal Grammar Extensions and add /* glsl */:source.glsl.

More seriously, I understand this can look like an overhead in the codebase (although that just comments so maybe not) but that might bring back some sanity to the maintainers and contributors when they are trying to update the shader code in their text editors.

Thanks

@mrdoob
Copy link
Owner

mrdoob commented Dec 25, 2018

Nice!

@mrdoob mrdoob added this to the r100 milestone Dec 25, 2018
@mrdoob mrdoob merged commit 2ad018c into mrdoob:dev Dec 25, 2018
@mrdoob
Copy link
Owner

mrdoob commented Dec 25, 2018

Thanks!

@mrdoob
Copy link
Owner

mrdoob commented Dec 25, 2018

Do you know if Sublime Text supports this? @WestLangley will surely appreciate that 😊

@dmnsgn
Copy link
Contributor Author

dmnsgn commented Dec 25, 2018

AFAIK not yet. But probably soon using JSCustom syntax package and when the following issue is resolved: Thom1729/Sublime-JS-Custom#49

I guess by using these settings:

{
    "configurations": {
        "My Config": {
            "custom_template_tags": {
                "/* glsl */": "scope:source.glsl"
            }
        }
    }
}

@arodic
Copy link
Contributor

arodic commented Dec 26, 2018

This is excellent! Should the VSC/Atom instructions go somewhere in the documentation?

@looeee
Copy link
Collaborator

looeee commented Dec 26, 2018

Looking forward to checking this out after the holidays!

Should the VSC/Atom instructions go somewhere in the documentation?

Probably in the wiki somewhere

@looeee
Copy link
Collaborator

looeee commented Jan 3, 2019

I'd like to add this to the wiki, does anyone have a preference for where to put it? Perhaps in this page?

https://github.com/mrdoob/three.js/wiki/How-to-contribute-to-three.js

@Mugen87
Copy link
Collaborator

Mugen87 commented Jan 3, 2019

That seems to be a good place 👍

@linbingquan
Copy link
Contributor

@mrdoob How do you think, I wanna to commit this tools in three.js\docs\manual\en\introduction\Useful-links.html#Tools

like: VSCode extension syntax highlighting for glsl.js

@mrdoob
Copy link
Owner

mrdoob commented Jan 4, 2019

@linbingquan Sounds good to me 👌

@linbingquan
Copy link
Contributor

@linbingquan Sounds good to me

I made a PR #15522

Result:

  • comment-tagged-templates - VSCode extension syntax highlighting for tagged template strings, like: glsl.js.
  • @Thom1729
    Copy link

    FYI, JS Custom now supports this explicitly:

    {
        "configurations": {
            "My Config": {
                "custom_templates": {
                    "comments": {
                        "glsl": "scope:source.glsl"
                    }
                }
            }
        }
    }

    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Labels

    None yet

    Projects

    None yet

    Development

    Successfully merging this pull request may close these issues.

    7 participants