I am trying to create my own syntax highlighting for Sublime Text 3. The main purpose of it is to distinguish text written in Latin script from text written in Cyrillic script. I have already installed AAAPackageControl and read the tutorial, but I cannot make it work for some reason.
Here's the syntax I wrote
# [PackageDev] target_format: plist, ext: tmLanguage
---
name: ADVANCED TEXT
scopeName: text.mirkowy
fileTypes: []
uuid: 78dbe755-58eb-4cdf-b954-4438334aedb9
patterns:
- comment: Words in Latin Script
name: latin_text.text.mirkowy
match: [A-Za-z]+
- comment: Words in Cyrillic Script
name: cyrillic_text.text.mirkowy
match: [ЁЂЃЄЅІЇЈЉЊЋЌЎЏАБВГДЕЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдежзийклмнопрстуфхцчшщъыьэюяёђѓєѕіїјљњћќўџҐґ]+
- comment: Numbers
name: numbers.text.mirkowy
match: \d
...
However, when I press F7 to convert that file to plist, I keep getting and error and I don't understand why (bear in mind that I am completely new to creating one's own syntaxes and the like) — here's what it looks like:
Input type not specified, auto-detecting... YAML
No target format specified, searching in file... Property List
Parsing YAML... (C:\Users\iyoossaev\AppData\Roaming\Sublime Text 3\Packages\User\mirkowy.YAML-tmLanguage)
Error parsing YAML: while parsing a block mapping
What do I do wrong?
You almost got it, but there is a minor issue with your regexes - character classes surrounded by square brackets
[ ]
need to be within parentheses( )
. Your "Numbers" regex\d
works fine without parens. So, just change your code to the following:and you should be all set. Note that I put a blank space between each block - it's not required, but it helps you visually separate each block, which comes in very useful when you get very complicated blocks.
If you'd like some examples of more complex
.YAML-tmLanguage
syntax definitions, two places come immediately to mind. The first is theSyntax Definitions
folder in thePackageDev
package itself. The second is actually in a personal project of mine, thePython Improved
syntax definition which aims to be a much better replacement for the built-in Python syntax that ships with Sublime. You can find the source forPythonImproved.YAML-tmLanguage
on Github. Feel free to open an issue there if you have any questions on syntax design, or just ask a new question here.Good luck!