{
  "scopeName": "source.env",
  "patterns": [
    {
      "comment": "Comments",
      "match": "^\\s?(#.*$)\\n",
      "captures": {
        "1": {
          "patterns": [
            {
              "include": "#reminder"
            }
          ]
        }
      }
    },
    {
      "comment": "Entries",
      "match": "^\\s?(export\\s?)*([\\w]+)\\s?(\\=)(.*)$",
      "captures": {
        "1": {
          "name": "keyword.other.env"
        },
        "2": {
          "name": "variable.other.env"
        },
        "3": {
          "name": "keyword.operator.assignment.env"
        },
        "4": {
          "patterns": [
            {
              "include": "#boolean"
            },
            {
              "include": "#numeric"
            },
            {
              "include": "#string"
            },
            {
              "include": "#interpolated"
            },
            {
              "include": "#unquoted"
            }
          ]
        }
      }
    }
  ],
  "repository": {
    "reminder": {
      "comment": "Reminder - starts with #",
      "match": "(#).*",
      "name": "comment.line.number-sign.env",
      "captures": {
        "1": {
          "name": "punctuation.definition.comment.env"
        }
      }
    },
    "boolean": {
      "comment": "Boolean Constants",
      "match": "(?i)\\b(true|false|null)\\b(.*)",
      "captures": {
        "1": {
          "name": "constant.language.env"
        },
        "2": {
          "patterns": [
            {
              "include": "#reminder"
            }
          ]
        }
      }
    },
    "numeric": {
      "comment": "Numeric",
      "match": "(?:\\+|-)?\\b((?:0(?:x|X)[0-9a-fA-F]*)|(?:(?:[0-9]+\\.?[0-9]*)|(?:\\.[0-9]+))(?:(?:e|E)(?:\\+|-)?[0-9]+)?)\\b(.*)",
      "captures": {
        "1": {
          "name": "constant.numeric.env"
        },
        "2": {
          "patterns": [
            {
              "include": "#reminder"
            }
          ]
        }
      }
    },
    "string": {
      "comment": "Strings (single)",
      "name": "string.quoted.single.env",
      "begin": "(?<!\\\\)(\\')",
      "beginCaptures": {
        "1": {
          "name": "punctuation.definition.string.begin.env"
        }
      },
      "end": "(\\')(.*)",
      "endCaptures": {
        "1": {
          "name": "punctuation.definition.string.end.env"
        },
        "2": {
          "patterns": [
            {
              "include": "#reminder"
            }
          ]
        }
      }
    },
    "interpolation": {
      "comment": "Template Syntax: \"foo ${bar} {$baz}\"",
      "begin": "(\\$\\{|\\{)",
      "beginCaptures": {
        "1": {
          "name": "string.interpolated.env keyword.other.template.begin.env"
        }
      },
      "patterns": [
        {
          "match": "(?x)(\\$+)?([a-zA-Z_\\x{7f}-\\x{ff}][a-zA-Z0-9_\\x{7f}-\\x{ff}]*?\\b)",
          "captures": {
            "1": {
              "name": "punctuation.definition.variable.env variable.other.env"
            },
            "2": {
              "name": "variable.other.env"
            }
          }
        }
      ],
      "end": "(\\})",
      "endCaptures": {
        "1": {
          "name": "string.interpolated.env keyword.other.template.end.env"
        }
      }
    },
    "variable": {
      "patterns": [
        {
          "match": "(?x)(\\$+)([a-zA-Z_\\x{7f}-\\x{ff}][a-zA-Z0-9_\\x{7f}-\\x{ff}]*?\\b)",
          "captures": {
            "1": {
              "name": "punctuation.definition.variable.env variable.other.env"
            },
            "2": {
              "name": "variable.other.env"
            }
          }
        }
      ]
    },
    "escape-characters": {
      "patterns": [
        {
          "match": "\\\\[nrt\\\\\\$\\\"\\']",
          "name": "constant.character.escape.env"
        }
      ]
    },
    "unquoted": {
      "comment": "Strings (none)",
      "name": "string.unquoted.env",
      "match": "([^#]*)(#.*)?",
      "captures": {
        "1": {
          "patterns": [
            {
              "include": "#interpolation"
            },
            {
              "include": "#variable"
            },
            {
              "include": "#escape-characters"
            }
          ]
        },
        "2": {
          "patterns": [
            {
              "include": "#reminder"
            }
          ]
        }
      }
    },
    "interpolated": {
      "comment": "Strings (double)",
      "name": "string.quoted.double.env",
      "begin": "(\\\")",
      "beginCaptures": {
        "1": {
          "name": "punctuation.definition.string.begin.env"
        }
      },
      "patterns": [
        {
          "include": "#interpolation"
        },
        {
          "include": "#variable"
        },
        {
          "include": "#escape-characters"
        }
      ],
      "end": "(\\\")(.*)",
      "endCaptures": {
        "1": {
          "name": "punctuation.definition.string.end.env"
        },
        "2": {
          "patterns": [
            {
              "include": "#reminder"
            }
          ]
        }
      }
    }
  }
}