title: How can I create a new syntax language definition for Sublime Text 3?
body: <p>I would like to setup a new language definition for log files with a certain format. I've been scouring the interwebs for a tutorial that actually works, and I've yet to find one. I've tried creating <code>sublime-syntax</code> files, <code>AAAPackageDev</code> files (both JSON and YAML), plus one other syntax package that I can't remember the name of -- none of them seem to work, with some of them leaving out important details, like where to save files, how to get the syntax definition to appear as an option (I suspect this is related to save location), or how the <code>keyword.other.joelog</code> scope relates to the <code>keyword.other</code> theme color (do you just drop the last bit? does the last bit have to match the scope set out in the header?). It's been very frustrating.</p>
  
  <p>At its simplest, I'd like to take the following file and highlight it:</p>
  
  <pre><code>2015-11-25 14:35:11 [LOG] Blah Blah Blah
  2015-11-25 14:35:11 [LOG] some log statement
  2015-11-25 14:35:11 [LOG] some other log statement
  2015-11-25 14:35:11 [DEBUG] some embedded filename: [[ /path/to/file ]]
  2015-11-25 14:35:11 [INFO] .............. blah blah ..............
  2015-11-25 14:35:11 [DEBUG] &lt;&lt;PASS&gt;&gt; Directory not found: [[ /some/dir/name ]]
  2015-11-25 14:35:11 [ERROR] &lt;&lt;FAIL&gt;&gt; Directory found: [[ /some/other/dir/name ]]
  2015-11-25 14:35:11 [WARNING] some strange condition occurred
  </code></pre>
  
  <p>Ultimately I'd like syntax definitions similar to the following:</p>
  
  <ul>
  <li>LOG lines should be "normal" text</li>
  <li>DEBUG lines should be treated entirely as comments</li>
  <li>ERROR lines should be treated as something else (e.g. a variable)</li>
  <li>INFO lines as normal except the word INFO should be highlighted as something (e.g. a keyword)</li>
  <li>WARNING similar to either ERROR or INFO</li>
  <li>have embedded strings in the format of <code>[[ some string ]]</code> highlighted as a string, irrespective of the type of line it's on</li>
  <li>have <code>&lt;&lt;PASS&gt;&gt;</code> and <code>&lt;&lt;FAIL&gt;&gt;</code> highlighted with different colors, irrespective of the type of line they're on</li>
  </ul>
  
  <p>I'd be happy getting any of this to work when manually selecting the mode, and especially happy if I could have the mode selected based on the full filename (it would be selected based on a prefix, rather than just a suffix, e.g. joelog-20151126-110719.log keying off of both the 'joelog' prefix and the 'log' suffix).</p>
  
  <p>Is this possible to do? I can write this in JSON, YAML, XML, Martian -- any language or style definition would be fine, if only I knew the rules.</p>
  
  <p><strong>Edit:</strong> Sorry, I meant to include the pages I've tried to follow:</p>
  
  <ul>
  <li><a href="http://docs.sublimetext.info/en/latest/extensibility/syntaxdefs.html" rel="nofollow">http://docs.sublimetext.info/en/latest/extensibility/syntaxdefs.html</a></li>
  <li><a href="http://www.sublimetext.com/docs/3/syntax.html" rel="nofollow">http://www.sublimetext.com/docs/3/syntax.html</a>
  
  <ul>
  <li><a href="http://www.sublimetext.com/docs/3/packages.html" rel="nofollow">http://www.sublimetext.com/docs/3/packages.html</a></li>
  </ul></li>
  <li><a href="https://github.com/SublimeText/AAAPackageDev" rel="nofollow">https://github.com/SublimeText/AAAPackageDev</a>
  
  <ul>
  <li><a href="https://github.com/SublimeText/AAAPackageDev/blob/master/Syntax%20Definitions/Sublime%20Text%20Syntax%20Def%20%28YAML%29.YAML-tmLanguage" rel="nofollow">https://github.com/SublimeText/AAAPackageDev/blob/master/Syntax%20Definitions/Sublime%20Text%20Syntax%20Def%20%28YAML%29.YAML-tmLanguage</a></li>
  </ul></li>
  <li><a href="https://packagecontrol.io/packages/SyntaxHighlightTools" rel="nofollow">https://packagecontrol.io/packages/SyntaxHighlightTools</a></li>
  </ul>
  
  <p>With <code>sublime-syntx</code> files I couldn't figure out how to get it to show up as an option. With <code>AAAPackageDev</code> files, I could get my new syntax definition to show up, but it never highlighted anything, even when doing nothing more than following the tutorial (abandoning all of my own desires, just trying to get something to highlight in any fashion).</p>
  
  <p>Thanks!</p>