Set default syntax highlight (JS / Babel ES6)

Hi there!

After ~2 hours of researching I still haven’t figured out how to set a specific syntax highlight for a file-ending.

I work with JS and use ES6 syntax / React. I don’t want all my files to rename to .jsx or something similar to have “Babel ES6 JavaScript” syntax-highlighting per default. Instead I want this SH for every .js file as default and not “JavaScript”.

Maybe someone has a hint for me how to achieve this?

Regards

Here’s the part of the documentation that covers custom language recognition.

I already did that but it didn’t work:

core:
    customFileTypes:
      "source.js": [
        "language-babel"
      ]

I also tried “languagebabel”.
The SH is delivered by https://atom.io/packages/language-babel

It was set as default once but switched back to .js -> JavaScript higlighting after an atom update

Try saving a file as test.language-babel, and you’ll see that it does work.

In the example above, source.coffee is the language’s scope name (see Finding a Language’s Scope Name for more information) and foo is the file extension to match without the period.

What you actually want to write is this:

core:
    customFileTypes:
      "source.js.jsx": [
        "js"
      ]
1 Like

AH! I’ve understood the doc totaly wrong. Thank you, that worked! :slight_smile: