Sublime Forum

New Syntax Definition Help

#1

I’m trying to create a new syntax definition for the Ruby mote templates. They’re pretty straight forward and are really similar to ERB in that they are just Ruby code embedded in some HTML.

In a syntax definition, how do you tell Sublime to highlight a match like it’s another language? I have the following:

# [PackageDev] target_format: plist, ext: tmLanguage
---
name: Mote
scopeName: text.html.mote
fileTypes: [mote]
uuid: 0091dcd2-99e8-4211-b199-a3ffb5bcffff

patterns:
- include: text.html.basic
- comment: Ruby in {{}}
  match: \{\{(.*?)\}\}
  name: text.html.mote.inline
  captures:
      '1': { name: source.ruby }

- comment: Ruby lines that start with %
  match: ^[^\S\n]*%[^\S\n]*(.*?)(?:\n|\Z)
  name: text.html.mote.line
  captures:
    '1': { name: source.ruby }

It seems to pick up the matches correctly, but it doesn’t highlight the captured Ruby code completely.

Any help would be much appreciated, thank you!

0 Likes

#2

You’ll need to use push, pop and include like the PHP syntax does.

0 Likes

#3

Alright, thank you! Is there documentation on what all of the various commands (push, pop, and include) do? Thanks so much for your help!

0 Likes

#4

https://www.sublimetext.com/docs/3/syntax.html

0 Likes