简体   繁体   English

如何在Atom中为Twig文件设置默认语法突出显示?

[英]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. 根据此答案 ,此功能应该内置于Atom中,并且我应该能够使用customFileTypes来完成此任务。 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. 请注意,出于安全性考虑,我删除了userId值,但在实际配置中确实包含了它。

Oddly enough, if I switch the order of customFileTypes with themes , my theme breaks. 奇怪的是,如果我切换带themescustomFileTypes的顺序,我的主题就会中断。 Why is that? 这是为什么?

More importantly, how can I set all .twig files use HTML (or HTML Mustache?) syntax highlighting? 更重要的是,如何设置所有.twig文件使用HTML(或HTML Mustache?)语法突出显示?

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. 我在寻找相同的东西,以使php-twig包也适用于html文件类型,同时还允许呈现html语法。 I changed your source.twig to text.html.twig which seems to be working: 我将您的source.twig更改为text.html.twig ,它似乎正在起作用:

"*":
  core:
    customFileTypes:
      "text.html.twig": [
        "html"
      ]

安装此软件包后,我才获得Twig支持: https : //atom.io/packages/php-twig

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM