{
  "$schema": "https://raw.githubusercontent.com/martinring/tmlanguage/master/tmlanguage.json",
  "name": "Zelyra",
  "scopeName": "source.zyl",
  "fileTypes": [
    "zyl"
  ],
  "patterns": [
    { "include": "#comments" },
    { "include": "#strings" },
    { "include": "#keywords" },
    { "include": "#types" },
    { "include": "#decorators" },
    { "include": "#functions" },
    { "include": "#numbers" },
    { "include": "#operators" },
    { "include": "#html_tags" }
  ],
  "repository": {
    "comments": {
      "patterns": [
        {
          "name": "comment.line.double-slash.zyl",
          "match": "//.*$"
        },
        {
          "name": "comment.block.zyl",
          "begin": "/\\*",
          "end": "\\*/"
        }
      ]
    },
    "strings": {
      "patterns": [
        {
          "name": "string.quoted.double.zyl",
          "begin": "\"",
          "end": "\"",
          "patterns": [
            {
              "name": "constant.character.escape.zyl",
              "match": "\\\\."
            },
            {
              "name": "meta.interpolation.zyl",
              "begin": "\\{",
              "end": "\\}",
              "beginCaptures": {
                "0": { "name": "punctuation.section.embedded.begin.zyl" }
              },
              "endCaptures": {
                "0": { "name": "punctuation.section.embedded.end.zyl" }
              },
              "patterns": [
                { "include": "$self" }
              ]
            }
          ]
        }
      ]
    },
    "keywords": {
      "patterns": [
        {
          "name": "keyword.control.zyl",
          "match": "\\b(if|else|match|return|for|in|while|break|continue)\\b"
        },
        {
          "name": "keyword.declaration.zyl",
          "match": "\\b(fn|page|schema|let|mut|const|type|struct|enum|impl|use|mod)\\b"
        },
        {
          "name": "keyword.other.zyl",
          "match": "\\b(html|sql|route|form)\\b"
        },
        {
          "name": "constant.language.boolean.zyl",
          "match": "\\b(true|false)\\b"
        },
        {
          "name": "constant.language.null.zyl",
          "match": "\\b(null|none|nil)\\b"
        },
        {
          "name": "support.type.result.zyl",
          "match": "\\b(Ok|Err|Some|None)\\b"
        }
      ]
    },
    "types": {
      "patterns": [
        {
          "name": "entity.name.type.builtin.zyl",
          "match": "\\b(Int|Float|Text|String|Bool|List|Map|Set|Option|Result|Email|Date|DateTime|Void)\\b"
        },
        {
          "name": "entity.name.type.custom.zyl",
          "match": "\\b[A-Z][a-zA-Z0-9_]*\\b"
        }
      ]
    },
    "decorators": {
      "patterns": [
        {
          "name": "entity.other.attribute-name.decorator.zyl",
          "match": "@[a-zA-Z_][a-zA-Z0-9_]*"
        }
      ]
    },
    "functions": {
      "patterns": [
        {
          "match": "\\b(fn)\\s+([a-zA-Z_][a-zA-Z0-9_]*)",
          "captures": {
            "1": { "name": "keyword.declaration.zyl" },
            "2": { "name": "entity.name.function.definition.zyl" }
          }
        },
        {
          "match": "\\b([a-zA-Z_][a-zA-Z0-9_]*)\\s*\\(",
          "captures": {
            "1": { "name": "entity.name.function.call.zyl" }
          }
        }
      ]
    },
    "numbers": {
      "patterns": [
        {
          "name": "constant.numeric.float.zyl",
          "match": "\\b[0-9]+\\.[0-9]+([eE][+-]?[0-9]+)?\\b"
        },
        {
          "name": "constant.numeric.integer.zyl",
          "match": "\\b[0-9]+\\b"
        }
      ]
    },
    "operators": {
      "patterns": [
        {
          "name": "keyword.operator.arrow.zyl",
          "match": "->|=>"
        },
        {
          "name": "keyword.operator.comparison.zyl",
          "match": "==|!=|<=|>="
        },
        {
          "name": "keyword.operator.logical.zyl",
          "match": "&&|\\|\\||!"
        },
        {
          "name": "keyword.operator.arithmetic.zyl",
          "match": "\\+|-|\\*|/|%"
        },
        {
          "name": "keyword.operator.assignment.zyl",
          "match": "="
        }
      ]
    },
    "html_tags": {
      "patterns": [
        {
          "name": "meta.tag.zyl",
          "match": "<(/?)([a-zA-Z0-9-]+)([^>]*)>",
          "captures": {
            "1": { "name": "punctuation.definition.tag.zyl" },
            "2": { "name": "entity.name.tag.html.zyl" },
            "3": { "name": "meta.tag.attributes.zyl" }
          }
        }
      ]
    }
  }
}
