Importing .tmtheme and .tmlanguage Files into Ace

Jarrod Parkes edited this page Dec 10, 2015 · 2 revisions

ACE supports the importing of .tmtheme and .tmlanguage files for use in the editor. The task is accomplished by two simple node scripts.

Importing Textmate/Sublime Themes

  1. Go to the tool folder, and run npm install to install required dependencies.
  2. Drop your .tmtheme file into the tmthemes folder.
  3. Update the tmtheme.js file to include your new theme.
  4. Run node tmtheme.js

Your .tmtheme will be converted and placed into lib/ace/theme alongside other themes. Note that there’s one more class we’ve added that isn’t available in regular Textmate themes, and that’s for .ace_indent-guide. This class adds indentation guides for your theme, using a base64-encoded png. In general, the dark themes and light themes each have their own strings, so you can just copy the class from an equivalent theme.

Importing Textmate/Sublime Languages

If you’re interested in porting over an existing .tmlanguage file into Ace’s mode syntax highlighting, there’s a tool to accomplish that, too.

  1. Run npm install at the root ace folder to install required dependencies.
  2. Go to the tool folder.
  3. Drop your .tmlanguage file into the tool folder.
  4. Run node tmlanguage.js <path_to_tmlanguage_file>, such as node tmlanguage.js MyGreatLanguage.tmlanguage.

Your .tmlanguage file will be converted to the best of the converter’s ability. It is an understatement to say that the tool is imperfect. Probably, this will never be able to be fully autogenerated. In .tmlanguage files, for instance, one sees the use of lookbehinds/negative lookbehinds, which JavaScript regexps simply do not have. There’s a list of other non-determinable items, too:

  • Deciding which state to transition to
    While the tool does create new states correctly, it labels them with generic terms like state_2, state_10 e.t.c.
  • Extending modes
    Many modes say something like include source.c, to mean, “add all the rules in C highlighting.” That syntax does not make sense to Ace or this tool
  • Rule preference order
  • Gathering keywords
    Most likely, you’ll need to take keywords from your language file and run them through createKeywordMapper()

Two files are created and placed in lib/ace/mode: one for the language mode, and one for the set of highlight rules. You will still need to add the code into kitchen_sink.html and demo.js, as well as write any tests for the highlighting.

You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.