The applets have file extensions like.wxml,.wxss, and.wxs, but the Atom editor doesn’t automatically recognize these types of files by default.

An elegant solution would be to modify Atom’s configuration so that Atom treats.wxml as.html,.wxss as.css, and.wxs as.js. You’ll see colored code when you open these types of files.

steps

1. Open theconfig.csonThe configuration file

At the same time, press Command + Shift + P to invoke the Command panel, type Application: Open Your Config, and hit Enter to Open the file config.cson

2, modify,config.csonThe configuration file

Add it under core

customFileTypes:
  'text.html.basic': [
    'wxml'
  ]
  'source.css': [
    'wxss'
  ]
  'source.js': [
    'wxs'
  ]
Copy the code

General document structure

"*":
  core:
    customFileTypes:
      'text.html.basic': [
        'wxml'
      ]
      'source.css': [
        'wxss'
      ]
      'source.js': [
        'wxs'
      ]
Copy the code

There may be many other attributes in this file, as some plug-ins automatically add configuration to this file

Configuration complete! Re-open the.wxml,.wxss, WXS files and you will see colored code.

The principle of

Instead of recognizing a WXML file as an HTML file, Atom uses the same syntax rules as AN HTML file to highlight the code in a WXML file. Text.html. basic, source.css, source.js are the corresponding syntax rule names, which can be found in packages built into Atom such as language-xxx or in third parties.

Reference:

Flight – manual. Atom. IO/using – atom /…

Flight – manual. Atom. IO/using – atom /…