Sublime Forum

Trying to convert .tmLanguage syntax to .sublime-syntax

#1

I am trying to convert a .tmLanguage file to .sublime-syntax format, using Sublime text. This is to use the file in another program (https://github.com/sharkdp/bat).

These are the instructions that I have to do this:

If the Sublime Text syntax is only available as a .tmLanguage file, open the file in Sublime Text and convert it to a .sublime-syntax file via Tools -> Developer -> New Syntax from XXX.tmLanguage… . Save the new file in the assets/syntaxes folder.

I have pasted the .tmLanguage file in SB and saved it as a .tmLanguage file, but then I see no option Tools -> Developer -> New Syntax from XXX.tmLanguage….

What do I do so that I can convert this file?

0 Likes

Mcnp code syntaxing
#2

sounds like you’re running into https://github.com/sublimehq/sublime_text/issues/2388
try opening a new tab and setting the syntax of that tab to the one you want to convert, then that menu entry should appear

2 Likes

#3

Thanks. I want to convert the file from .tmLanguage to sublime-syntax, and I see neither of those syntaxes in the list when I click on the right end of the status bar at the bottom.

I am not familiar with Sublime Text.

0 Likes

#4

You need to save it in the Packages folder hierarchy for ST to pick it up - you can try Tools -> Developer - New Syntax, paste in the tmLanguage and save it in the folder ST recommends (Packages/User) as EggBeanSyntax.tmLanguage, then Tools -> Developer -> New Syntax From EggBeanSyntax.tmLanguage.

I’m guessing this is in reference to https://github.com/sharkdp/bat/issues/1149 ? Looks like it is slightly invalid:

no such context .literal-constants of Packages/User/Mikrotek.tmLanguage
Exception: no entry in repository for literal-constants

Well, technically valid but with a warning which the syntax converter doesn’t correctly handle. To fix, comment out or delete:


Then try the New Syntax From… it worked for me, so if you still have trouble I can paste it here I guess

0 Likes

#5

After I removed those lines and followed the rest of your instructions, I get this result:

http://sprunge.us/NYvb7P

Is that identical to your file? I get a segmentation fault when I try using the resultant file in bat, so I will ask about that on github.

Thanks a lot for your help.

0 Likes

#6

yep

interesting. I’m one of the maintainers of syntect - the syntax highlighting library bat uses, so I’ll investigate if/when I get time
EDIT: the syncat example seems to work okay with the following text, so maybe a bat-specific problem?

{
   :local a 3;
   {
      :local b 4;
      :put ($a+$b);
   }
#line below will show variable b in light red color since it is not defined in scope
   :put ($a+$b);
}
0 Likes