Sublime Forum

Converting a JSON .tmLanguage

#1

How can I use a tmLanguage.json syntax definition in Sublime Text?

I have read this post about it. However, I have not been able to get Sublime Text to recognize a coverted file.

This is the file that I am starting with: https://github.com/infosec-intern/vscode-yara/blob/main/yara/syntaxes/yara.tmLanguage.json

Here is the file that it converted to with a couple fixes in the header:

I removed smartTypingPairs and highlightPairs because it seems that is handled outside of the syntax in Sublime, but let me kow if this is wrong.

I have tried naming the file with these extensions: .YAML-tmLanguage and .tmLanguage

I am putting the file in the following directory:
~/Library/Application Support/Sublime Text/Packages/User

Any help would be great.

0 Likes

#2

PackageDev comes along with some functionalities to compile .YAML-tmLanguage or .JSON-tmLanguage to plaint tmLanguage files.

Please note it may fail for json like tmPreference files of VS Code as those use TextMate2 features not supported by ST.

0 Likes

#3

Just so I understand what I am going to need to do:

Sublime Text cannot use .tmLanguage.json and cannot use .YAML-tmLanguage.

However, I can use a function in PackageDev to take the tmLanguage.json file that I have and compile it to .tmLanguage format (which is plist / XML).

.tmLanguage plist/XML is the only format that Sublime Text can use outside of its native .sublime-syntax format.

Do I have everything above correct, or is some of it wrong?

0 Likes

#4

Absolutely correct.

Those .YAML-tmLanguage and .tmLanguage.json file formates have been created by community to make syntax development easier before *.sublime-syntax format was supported.

VS Code continued to use those file formats but updated them to support newer TextMate syntax features, which may not not all be supported by ST’s tmLanguage parser.

0 Likes