michaelgmcd / vscode-language-babel

VSCode syntax highlighting for today's JavaScript
https://marketplace.visualstudio.com/items?itemName=mgmcdermott.vscode-language-babel
MIT License
131 stars 17 forks source link

Use source.js scope instead of source.js.jsx #29

Closed lehni closed 6 years ago

lehni commented 6 years ago

See https://github.com/vuejs/vetur/issues/825 for an issue I am encountering because vscode-language-babel uses the source.js.jsx identifier instead of source.js for the JavaScript scope.

What is the reason behind this difference to VSCode's own highlighter? (See https://github.com/Microsoft/vscode/blob/442e5e202a89c1f8efe642c89c0554cab1f15a9e/extensions/javascript/syntaxes/JavaScript.tmLanguage.json#L9)

Could a change to source.js be considered to make this extension compatible with Vetur?

michaelgmcd commented 6 years ago

In short, this is because this package was originally ported from the atom equivalent that uses source.js.jsx. I can take a closer look at this sometime this week, but I'm guessing that this would have some unintended side-effects with the react .jsx extension.

lehni commented 6 years ago

I'm not sure, but we can easily test this. Here's the reason I doubt it may have effects:

"name": "JavaScript (with React support)",
"scopeName": "source.js",

Emphasis on (with React support). This is from the file linked to above.

lehni commented 6 years ago

I've just tested this by manually altering the version installed in ~/.vscode/mgmcdermott.vscode-language-babel-0.0.15, restarting VSCode and then editing a JSX file.

It works without any problems, and Vetur is now also picking it up for syntax highlighting!

screen shot 2018-06-20 at 09 39 41
michaelgmcd commented 6 years ago

I've pushed out 0.0.16 with a fix for this. From my research of VSCode doing this, they only added source.js.jsx to prevent all JavaScript files from being named JavaScript React. Hopefully this doesn't have any unintended side-effects, but it seems to be working based on my testing.

lehni commented 6 years ago

That’s great! Thanks so much. I’ll test in a moment also.

lehni commented 6 years ago

I just tested and it works as expected. Thanks!