Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I set default syntax highlighting in Atom for Twig files?

According to this answer, this functionality should be built into Atom, and I should be able to use customFileTypes to accomplish this. This is what my config looks like:

"*":
    "exception-reporting":
      userId: ""
    welcome:
      showOnStartup: false
   core:
     themes: [
        "atom-light-ui"
        "atom-light-syntax"
     ]
     customFileTypes:
       "source.twig": [
         "html"
     ]
   editor:
     invisibles: {}
     tabLength: 4
     showIndentGuide: true
     showInvisibles: true

Note that I've removed my userId value for security, but I do have it in my actual config.

Oddly enough, if I switch the order of customFileTypes with themes, my theme breaks. Why is that?

More importantly, how can I set all .twig files use HTML (or HTML Mustache?) syntax highlighting?

like image 993
Michael Lynch Avatar asked Jan 21 '16 18:01

Michael Lynch


1 Answers

I was looking for the same thing, to enable the php-twig package to also work for html filetypes while also allowing the html syntax to be rendered. I changed your source.twig to text.html.twig which seems to be working:

"*":
  core:
    customFileTypes:
      "text.html.twig": [
        "html"
      ]
like image 76
Yani Avatar answered Sep 21 '22 23:09

Yani