-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Importing .tmtheme and .tmlanguage Files into Ace
ACE supports the importing of .tmtheme and .tmlanguage files for use in the editor. The task is accomplished by two simple node scripts.
- Go to the tool folder, and run
npm install
to install required dependencies. - Drop your .tmtheme file into the tmthemes folder.
- Update the tmtheme.js file to include your new theme.
- 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.
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.
- Run
npm install
at the root ace folder to install required dependencies. - Go to the tool folder.
- Drop your .tmlanguage file into the tool folder.
- Run
node tmlanguage.js <path_to_tmlanguage_file>
, such asnode 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 likestate_2
,state_10
e.t.c. - Extending modes
Many modes say something likeinclude 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 throughcreateKeywordMapper()
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.