Skip to content

Syntax Highlighting

NinjaPewPew edited this page Jul 14, 2019 · 1 revision

The Quick Diff View will apply syntax highlighting to source code. You can find the default syntax configuration files in .\Resources\Syntax\. The easiest way to add new ones is to simply copy an existing one, rename the file and update its content appropriately.

Configuration File Structure

The configuration file is a JSON with the following keys.

  • lang: Name of the language that is described (e.g. "HTML").
  • extensions: String array of extensions (withough leading dot) that these syntax rules apply to.
  • scopes: Array of scope elements.
    • name: Name of the scope. This is just for better readability.
    • color: Hexadecimal color that is applied to the text.
    • patterns: String array of regex patterns that the scope is applied to. Only text that is part of a capture groups gets highlighted. See default files for example.

Example

{
    "lang":"html",
    "extensions": ["html", "htm"],
    "scopes": [
        {
            "name":"keywords",
            "color":"#07C",
            "patterns":
            [
                "(<[\/]{0,1}(html|body|head|title|h2))[^>]*(>)",
                "(<[\/]{0,1}(div|h1|h3|h4))[^>]*(>)"
            ]   
        },
        {
            "name":"strings",
            "color":"#e0a060",
            "patterns":
            [
                "(\".*?\")"
            ]   
        }
    ]    
}

Clone this wiki locally