Convert Sublime grammar to Atom grammar


#1

The docs describe how to convert a TextMate Bundle into an Atom package:
https://atom.io/docs/latest/converting-a-text-mate-bundle

I would like to convert this Sublime Text Package for Modelica syntax highlight


into an Atom package.

Automatic conversion using

apm init --package C:\Users\myName\.atom\packages\language-modelica3 --convert https://github.com/BorisChumichev/modelicaSublimeTextPackage

did not work.

Should I convert from Sublime to TextMate first? Any other ideas?


Packages for more obscure languages?
Documentation for creating custom grammars
Language already defined
Syntax highlight for ZIMPL (package wanted)
#2

Here is a way that worked for me (on Kubuntu 14.10).

Start from any empty directory, then execute step by step:

  1. Get a copy of the TextMate-to-Sublime-Converter script (converts in both directions)
    git clone https://github.com/srbs/textmate-to-sublime-converter

  2. Delete the directory Sublime Text from the examples directory
    rm -r textmate-to-sublime-converter/examples/subl2tm/Sublime\ Text/

  3. Get a copy of the Sublime syntax package that you want to convert, in my case
    git clone https://github.com/BorisChumichev/modelicaSublimeTextPackage

  4. Copy the Sublime syntax package to a directory Sublime Text (i.e. same name as the deleted one)
    cp -r modelicaSublimeTextPackage/ textmate-to-sublime-converter/examples/subl2tm/Sublime\ Text/

  5. Change to that directory
    cd textmate-to-sublime-converter/examples/subl2tm/

  6. Call ant
    ant -f build.xml

  7. You now have a TextMate package that can be converted using the Atom Package Manager
    apm init --package ~/.atom/packages/language-modelica3 --convert TextMate/

  8. As a last step, one could share that package (or both the TextMate bundle and the Atom package), but I’ll have to figure that out in the next days


#3

Worked like a charm! Thanks for posting this!


#4

You might also want to try this script of mine, called Atomizr. It converts .sublime-completions and .sublime-snippet files into Atom CSON or JSON. In addition, you can split or merge the resulting files.

If you run into problems, you might have to define replacement filters in the header of the script. This might be necessary for certain escaped characters.

Work in progress!


#5

I have added a “pre-processor” for tmBundles, so you can put TextMate/Sublime Text packages in order before conversion. The TextMate files are still converted with apm (called by atomizr), while Sublime Text files are converted by the script itself.

Try this at home:

# Install
git clone https://github.com/idleberg/atomizr.git
cd atomizr; chmod +x atomizr

# Grab random TextMate package
git clone https://github.com/jashkenas/coffee-script-tmbundle CoffeeScript.tmBundle

# Convert, then delete
./atomizr -i CoffeeScript.tmBundle -o lang-coffeescript -X

#6

@idleberg Thanks that worked like a charm! :grinning:


#7

For basic conversion between Sublime Text completions and Atom snippets, I’ve uploaded this package earlier today. There’s also a counter-part for Sublime Text, but it’s not yet on Package Control.


#8

I get some error on step 6 in process, but I ignore it, and done next steps and all worked fine!

Apache Ant™ version 1.9.3 compiled on April 8 2014
Trying the default build file: build.xml
Buildfile: /home/alexzander/convertZIMPL/textmate-to-sublime-converter/examples/subl2tm/build.xml
Detected Java version: 1.8 in: /usr/lib/jvm/java-8-oracle/jre
Detected OS: Linux
parsing buildfile /home/alexzander/convertZIMPL/textmate-to-sublime-converter/examples/subl2tm/build.xml with URI = file:/home/alexzander/convertZIMPL/textmate-to-sublime-converter/examples/subl2tm/build.xml
Project base dir set to: /home/alexzander/convertZIMPL/textmate-to-sublime-converter/examples/subl2tm
parsing buildfile jar:file:/usr/share/ant/lib/ant.jar!/org/apache/tools/ant/antlib.xml with URI = jar:file:/usr/share/ant/lib/ant.jar!/org/apache/tools/ant/antlib.xml from a zip file
Importing file /home/alexzander/convertZIMPL/textmate-to-sublime-converter/subl2tm.xml from /home/alexzander/convertZIMPL/textmate-to-sublime-converter/examples/subl2tm/build.xml
Overriding previous definition of reference to ant.projectHelper
parsing buildfile /home/alexzander/convertZIMPL/textmate-to-sublime-converter/subl2tm.xml with URI = file:/home/alexzander/convertZIMPL/textmate-to-sublime-converter/subl2tm.xml
[macrodef] creating macro subl2tm
[macrodef] creating macro subl2tm-snippet
Overriding previous definition of reference to ant.projectHelper

BUILD FAILED
Target “build.xml” does not exist in the project “Sublime Text package to Textmate bundle transformer”.


#9

Installing Atomizr just got a little easier:

sudo gem install atomizr

It’s my first Ruby gem, please let me know if you discover any bugs!


#10

Here’s yet another version of Atomizr, this time as a Node package.

https://www.npmjs.com/package/atomizr

I’m not sure whether I’m continuing support for the Ruby gem, but I’m planning to incorporate all its features to the Node package.