Sublime Forum

Syntax highlighting, overriding imported style

#1

Hello,
I’m working on my first “plugin” for Sublime Text 2 and I’m going though ok, expect I can’t seem to override the HTML syntax highlighting.

For some insight, I’m creating a new syntax along the lines of django template

Here is what I have(shortened for simplicity):

{ "name": "My Syntax",
  "scopeName": "source.mysyntax",
  "fileTypes": "html"],
  "patterns": 
  	{ "include": "text.html.basic"},
  	{
  		"name": "print.variable.mysyntax",
  		"begin": "(\\{\\{)",
  		"beginCaptures": {
  			"1": { "name": "keyword.mysyntax"}
  		},
  		"endCaptures": {
  			"1": { "name": "keyword.mysyntax"}
  		},
  		"patterns": 
  			{ "include": "$self" },
  			{ 
  				"name": "string.mysyntax",
  				"match": "."
		 	}
  		],
  		"end": "(\\}\\})"
  	}
  ],
  "uuid": "xxx"
}

Essentially I want it to highlight all double “{{” and “}}” however it doesn’t work when those are in a tag definition.
For example:

This works: {{ my.var }}
This doesn’t work: <div class="{{ my.var }}"> </div>

The example that doesn’t work is picking up the syntax highlighting from html and not from my definition… How can I “mesh” the two together?

Thank you in advance!
~Derek

0 Likes