grammars/source.terraform.json in github-linguist-7.7.0 vs grammars/source.terraform.json in github-linguist-7.8.0
- old
+ new
@@ -1,250 +1,694 @@
{
"name": "Terraform",
"scopeName": "source.terraform",
"patterns": [
{
- "name": "comment.line.number-sign.terraform",
- "begin": "#|//",
- "end": "$\\n?",
- "captures": {
+ "include": "#comments"
+ },
+ {
+ "include": "#top_level_attribute_definition"
+ },
+ {
+ "include": "#imports"
+ },
+ {
+ "include": "#block"
+ },
+ {
+ "include": "#expressions"
+ }
+ ],
+ "repository": {
+ "attribute_access": {
+ "begin": "\\.",
+ "end": "(\\b(?!null|false|true)[[:alpha:]][[:alnum:]_-]*\\b)|(\\*)|(\\d+)",
+ "beginCaptures": {
"0": {
- "name": "punctuation.definition.comment.terraform"
+ "name": "keyword.operator.accessor.terraform"
}
+ },
+ "endCaptures": {
+ "1": {
+ "name": "variable.other.member.terraform"
+ },
+ "2": {
+ "name": "keyword.operator.splat.terraform"
+ },
+ "3": {
+ "name": "constant.numeric.integer.terraform"
+ }
}
},
- {
+ "block": {
+ "name": "meta.type.terraform",
+ "begin": "(\\b(resource|provider|variable|output|locals|module|data|terraform)\\b|(\\b(?!null|false|true)[[:alpha:]][[:alnum:]_-]*\\b))(?=[\\s\\\"\\-[:word:]]*(\\{))",
+ "end": "(?=\\{)",
+ "patterns": [
+ {
+ "name": "string.quoted.double.terraform",
+ "begin": "\\\"",
+ "end": "\\\"",
+ "beginCaptures": {
+ "0": {
+ "name": "punctuation.definition.string.begin.terraform"
+ }
+ },
+ "endCaptures": {
+ "0": {
+ "name": "punctuation.definition.string.end.terraform"
+ }
+ }
+ },
+ {
+ "name": "entity.name.label.terraform",
+ "match": "\\b(?!null|false|true)[[:alpha:]][[:alnum:]_-]*\\b"
+ }
+ ],
+ "beginCaptures": {
+ "2": {
+ "name": "storage.type.terraform"
+ },
+ "3": {
+ "name": "entity.name.type.terraform"
+ }
+ }
+ },
+ "block_comments": {
"name": "comment.block.terraform",
"begin": "/\\*",
"end": "\\*/",
- "captures": {
+ "beginCaptures": {
"0": {
"name": "punctuation.definition.comment.terraform"
}
+ },
+ "endCaptures": {
+ "0": {
+ "name": "punctuation.definition.comment.terraform"
+ }
}
},
- {
- "name": "constant.language.terraform",
- "match": "\\b(true|false|yes|no|on|off)\\b"
+ "brackets": {
+ "begin": "\\[",
+ "end": "(\\*)?\\]",
+ "patterns": [
+ {
+ "include": "#comma"
+ },
+ {
+ "include": "#comments"
+ },
+ {
+ "include": "#expressions"
+ },
+ {
+ "include": "#tuple_for_expression"
+ }
+ ],
+ "beginCaptures": {
+ "0": {
+ "name": "punctuation.section.brackets.begin.terraform"
+ }
+ },
+ "endCaptures": {
+ "0": {
+ "name": "punctuation.section.brackets.end.terraform"
+ },
+ "1": {
+ "name": "keyword.operator.splat.terraform"
+ }
+ }
},
- {
- "name": "constant.numeric.terraform",
- "match": "\\b([0-9]+)([kKmMgG]b?)?\\b"
+ "comma": {
+ "name": "punctuation.separator.terraform",
+ "match": "\\,"
},
- {
- "name": "constant.numeric.terraform",
- "match": "\\b(0x[0-9A-Fa-f]+)([kKmMgG]b?)?\\b"
+ "comments": {
+ "patterns": [
+ {
+ "include": "#inline_comments"
+ },
+ {
+ "include": "#block_comments"
+ }
+ ]
},
- {
- "name": "meta.resource.terraform",
- "match": "(resource|data)\\s+(\")?(\\w+)(\")?\\s+(\")?([\\w\\-]+)(\")?\\s+({)",
- "captures": {
- "1": {
- "name": "storage.type.function.terraform"
+ "expressions": {
+ "patterns": [
+ {
+ "include": "#literal_values"
},
- "2": {
- "name": "string.terraform punctuation.definition.string.begin.terraform"
+ {
+ "include": "#operators"
},
- "3": {
- "name": "string.value.terraform"
+ {
+ "include": "#brackets"
},
- "4": {
- "name": "string.terraform punctuation.definition.string.end.terraform"
+ {
+ "include": "#objects"
},
- "5": {
- "name": "string.terraform punctuation.definition.string.begin.terraform"
+ {
+ "include": "#attribute_access"
},
- "6": {
- "name": "string.value.terraform"
+ {
+ "include": "#functions"
},
- "7": {
- "name": "string.terraform punctuation.definition.string.end.terraform"
- },
- "8": {
- "name": "punctuation.definition.tag.terraform"
+ {
+ "include": "#parens"
}
- }
+ ]
},
- {
- "match": "(provider|provisioner|variable|output|module|atlas)\\s+(\")?([\\w\\-]+)(\")?\\s+({)",
- "captures": {
- "1": {
- "name": "storage.type.function.terraform"
+ "functions": {
+ "name": "meta.function-call.terraform",
+ "begin": "((abs|ceil|floor|log|max|min|pow|signum|chomp|format|formatlist|indent|join|lower|regex|regexall|replace|split|strrev|substr|title|trimspace|upper|chunklist|coalesce|coalescelist|compact|concat|contains|distinct|element|flatten|index|keys|length|list|lookup|map|matchkeys|merge|range|reverse|setintersection|setproduct|setunion|slice|sort|transpose|values|zipmap|base64decode|base64encode|base64gzip|csvdecode|jsondecode|jsonencode|urlencode|yamldecode|yamlencode|abspath|dirname|pathexpand|basename|file|fileexists|fileset|filebase64|templatefile|formatdate|timeadd|timestamp|base64sha256|base64sha512|bcrypt|filebase64sha256|filebase64sha512|filemd5|filemd1|filesha256|filesha512|md5|rsadecrypt|sha1|sha256|sha512|uuid|uuidv5|cidrhost|cidrnetmask|cidrsubnet|tobool|tolist|tomap|tonumber|toset|tostring)|\\b((?!null|false|true)[[:alpha:]][[:alnum:]_-]*\\b))(\\()",
+ "end": "\\)",
+ "patterns": [
+ {
+ "include": "#comments"
},
+ {
+ "include": "#expressions"
+ },
+ {
+ "include": "#comma"
+ }
+ ],
+ "beginCaptures": {
"2": {
- "name": "string.terraform punctuation.definition.string.begin.terraform"
+ "name": "support.function.builtin.terraform"
},
"3": {
- "name": "string.value.terraform"
+ "name": "variable.function.terraform"
},
"4": {
- "name": "string.terraform punctuation.definition.string.end.terraform"
- },
- "5": {
- "name": "punctuation.definition.tag.terraform"
+ "name": "punctuation.section.parens.begin.terraform"
}
+ },
+ "endCaptures": {
+ "0": {
+ "name": "punctuation.section.parens.end.terraform"
+ }
}
},
- {
- "match": "([\\w_-]+)\\s*(=)\\s*",
- "captures": {
+ "heredoc": {
+ "name": "string.unquoted.heredoc.terraform",
+ "begin": "(\\\u003c\\\u003c\\-?)\\s*(\\b(?!null|false|true)[[:alpha:]][[:alnum:]_-]*\\b)\\s*$",
+ "end": "^\\s*\\2\\s*$",
+ "patterns": [
+ {
+ "include": "#string_interpolation"
+ }
+ ],
+ "beginCaptures": {
"1": {
- "name": "variable.other.assignment.terraform"
+ "name": "keyword.operator.heredoc.terraform"
},
"2": {
- "name": "keyword.operator.terraform"
+ "name": "keyword.control.heredoc.terraform"
}
+ },
+ "endCaptures": {
+ "0": {
+ "name": "keyword.control.heredoc.terraform"
+ }
}
},
- {
- "match": "(\")([\\w_-]+)(\")\\s*(=)\\s*",
- "captures": {
- "1": {
- "name": "punctuation.quote.double.terraform"
+ "imports": {
+ "begin": "\\s*(terraform)\\s*(import)\\s*",
+ "end": "$\\n?",
+ "patterns": [
+ {
+ "include": "#string_literals"
},
- "2": {
- "name": "variable.assignment.terraform"
+ {
+ "name": "entity.name.label.terraform",
+ "match": "\\b(?!null|false|true)[[:alpha:]][[:alnum:]_-]*\\b"
},
- "3": {
- "name": "punctuation.quote.double.terraform"
+ {
+ "include": "#numeric_literals"
},
- "4": {
- "name": "keyword.operator.terraform"
+ {
+ "include": "#attribute_access"
}
- }
- },
- {
- "match": "([\\w\\-_]+)\\s+({)",
- "captures": {
+ ],
+ "beginCaptures": {
"1": {
- "name": "entity.name.section.terraform"
+ "name": "support.constant.terraform"
},
"2": {
- "name": "punctuation.definition.tag.terraform"
+ "name": "keyword.control.import.terraform"
}
}
},
- {
- "include": "#strings"
- },
- {
- "name": "string.unquoted.heredoc.terraform",
- "begin": "(?\u003e\\s*\u003c\u003c(\\w+))",
- "end": "^\\s*\\1$",
+ "inline_comments": {
+ "name": "comment.line.terraform",
+ "begin": "#|//",
+ "end": "$\n?",
"beginCaptures": {
"0": {
- "name": "punctuation.definition.string.begin.terraform"
+ "name": "punctuation.definition.comment.terraform"
+ }
+ }
+ },
+ "language_constants": {
+ "name": "constant.language.terraform",
+ "match": "\\b(true|false|null)\\b"
+ },
+ "literal_values": {
+ "patterns": [
+ {
+ "include": "#numeric_literals"
},
- "1": {
- "name": "keyword.operator.heredoc.terraform"
+ {
+ "include": "#language_constants"
+ },
+ {
+ "include": "#string_literals"
+ },
+ {
+ "include": "#heredoc"
+ },
+ {
+ "include": "#type_keywords"
+ },
+ {
+ "include": "#named_value_references"
}
- },
- "endCaptures": {
+ ]
+ },
+ "main": {
+ "patterns": [
+ {
+ "include": "#comments"
+ },
+ {
+ "include": "#block"
+ },
+ {
+ "include": "#expressions"
+ }
+ ]
+ },
+ "named_value_references": {
+ "name": "support.constant.terraform",
+ "match": "\\b(var|local|module|data|path|terraform)\\b"
+ },
+ "numeric_literals": {
+ "patterns": [
+ {
+ "name": "constant.numeric.float.terraform",
+ "match": "\\b\\d+(([Ee][+-]?))\\d+\\b",
+ "captures": {
+ "1": {
+ "name": "punctuation.separator.exponent.terraform"
+ }
+ }
+ },
+ {
+ "name": "constant.numeric.float.terraform",
+ "match": "\\b\\d+(\\.)\\d+(?:(([Ee][+-]?))\\d+)?\\b",
+ "captures": {
+ "1": {
+ "name": "punctuation.separator.decimal.terraform"
+ },
+ "2": {
+ "name": "punctuation.separator.exponent.terraform"
+ }
+ }
+ },
+ {
+ "name": "constant.numeric.integer.terraform",
+ "match": "\\b\\d+\\b"
+ }
+ ]
+ },
+ "object_for_expression": {
+ "begin": "\\bfor\\b",
+ "end": "(?=\\})",
+ "patterns": [
+ {
+ "name": "storage.type.function.terraform",
+ "match": "\\=\\\u003e"
+ },
+ {
+ "name": "keyword.operator.word.terraform",
+ "match": "\\bin\\b"
+ },
+ {
+ "name": "keyword.control.conditional.terraform",
+ "match": "\\bif\\b"
+ },
+ {
+ "name": "keyword.operator.terraform",
+ "match": "\\:"
+ },
+ {
+ "include": "#expressions"
+ },
+ {
+ "include": "#comments"
+ },
+ {
+ "include": "#comma"
+ },
+ {
+ "name": "variable.other.readwrite.terraform",
+ "match": "\\b(?!null|false|true)[[:alpha:]][[:alnum:]_-]*\\b"
+ }
+ ],
+ "beginCaptures": {
"0": {
- "name": "punctuation.definition.string.end.terraform keyword.operator.heredoc.terraform"
+ "name": "keyword.control.terraform"
}
}
- }
- ],
- "repository": {
- "string_interpolation": {
+ },
+ "object_key_values": {
"patterns": [
{
- "name": "source.terraform.embedded.source",
- "begin": "\\$\\{",
- "end": "\\}",
+ "include": "#comments"
+ },
+ {
+ "include": "#expressions"
+ }
+ ]
+ },
+ "objects": {
+ "name": "meta.braces.terraform",
+ "begin": "\\{",
+ "end": "\\}",
+ "patterns": [
+ {
+ "include": "#object_for_expression"
+ },
+ {
+ "include": "#comments"
+ },
+ {
+ "begin": "\\s*(\\b(?!null|false|true)[[:alpha:]][[:alnum:]_-]*\\b)\\s*(\\=)\\s*",
+ "end": "((\\,)|($\\n?)|(?=\\}))",
"patterns": [
{
- "include": "$self"
+ "include": "#object_key_values"
+ }
+ ],
+ "beginCaptures": {
+ "1": {
+ "name": "meta.mapping.key.terraform string.unquoted.terraform"
},
- {
- "include": "#string_interpolation_functions"
+ "2": {
+ "name": "keyword.operator.terraform"
+ }
+ },
+ "endCaptures": {
+ "1": {
+ "name": "punctuation.separator.terraform"
},
+ "3": {
+ "name": "punctuation.section.braces.end.terraform"
+ }
+ }
+ },
+ {
+ "begin": "((\\\").*(\\\"))\\s*(\\=)\\s*",
+ "end": "((\\,)|($\\n?)|(?=\\}))",
+ "patterns": [
{
- "include": "#string_interpolation_keywords"
+ "include": "#object_key_values"
+ }
+ ],
+ "beginCaptures": {
+ "1": {
+ "name": "meta.mapping.key.terraform string.quoted.double.terraform"
},
- {
- "match": "(\\.)",
- "captures": {
- "0": {
- "name": "keyword.control.period.terraform"
- }
- }
+ "2": {
+ "name": "punctuation.definition.string.begin.terraform"
},
+ "3": {
+ "name": "punctuation.definition.string.end.terraform"
+ },
+ "4": {
+ "name": "keyword.operator.terraform"
+ }
+ },
+ "endCaptures": {
+ "1": {
+ "name": "punctuation.separator.terraform"
+ },
+ "3": {
+ "name": "punctuation.section.braces.end.terraform"
+ }
+ }
+ },
+ {
+ "name": "meta.mapping.key.terraform",
+ "begin": "\\(",
+ "end": "(\\))\\s*(\\=)\\s*",
+ "patterns": [
{
- "include": "#strings"
+ "include": "#expressions"
}
],
"beginCaptures": {
"0": {
- "name": "entity.tag.embedded.start.terraform"
+ "name": "punctuation.section.parens.begin.terraform"
}
},
"endCaptures": {
- "0": {
- "name": "entity.tag.embedded.end.terraform"
+ "1": {
+ "name": "punctuation.section.parens.end.terraform"
+ },
+ "2": {
+ "name": "keyword.operator.terraform"
}
}
+ },
+ {
+ "patterns": [
+ {
+ "include": "#main"
+ }
+ ]
}
- ]
+ ],
+ "beginCaptures": {
+ "0": {
+ "name": "punctuation.section.braces.begin.terraform"
+ }
+ },
+ "endCaptures": {
+ "0": {
+ "name": "punctuation.section.braces.end.terraform"
+ }
+ }
},
- "string_interpolation_functions": {
- "begin": "(base64decode|base64encode|base64gzip|base64sha256|base64sha512|basename|bcrypt|ceil|chomp|cidrhost|cidrnetmask|cidrsubnet|coalesce|coalescelist|compact|concat|contains|dirname|distinct|element|file|flatten|floor|format|formatlist|index|join|jsonencode|keys|length|list|log|lookup|lower|map|matchkeys|max|md5|merge|min|pathexpand|pow|replace|sha1|sha256|sha512|signum|slice|sort|split|substr|timestamp|title|trimspace|upper|urlencode|uuid|values|zipmap)(\\()",
- "end": "(\\))",
+ "operators": {
"patterns": [
{
- "include": "#string_interpolation_functions"
+ "name": "keyword.operator.terraform",
+ "match": "\\\u003e\\="
},
{
- "include": "#string_interpolation_keywords"
+ "name": "keyword.operator.terraform",
+ "match": "\\\u003c\\="
},
{
- "include": "#strings"
+ "name": "keyword.operator.terraform",
+ "match": "\\=\\="
+ },
+ {
+ "name": "keyword.operator.terraform",
+ "match": "\\!\\="
+ },
+ {
+ "name": "keyword.operator.arithmetic.terraform",
+ "match": "\\+"
+ },
+ {
+ "name": "keyword.operator.arithmetic.terraform",
+ "match": "\\-"
+ },
+ {
+ "name": "keyword.operator.arithmetic.terraform",
+ "match": "\\*"
+ },
+ {
+ "name": "keyword.operator.arithmetic.terraform",
+ "match": "\\/"
+ },
+ {
+ "name": "keyword.operator.arithmetic.terraform",
+ "match": "\\%"
+ },
+ {
+ "name": "keyword.operator.logical.terraform",
+ "match": "\\\u0026\\\u0026"
+ },
+ {
+ "name": "keyword.operator.logical.terraform",
+ "match": "\\|\\|"
+ },
+ {
+ "name": "keyword.operator.logical.terraform",
+ "match": "\\!"
+ },
+ {
+ "name": "keyword.operator.terraform",
+ "match": "\\\u003e"
+ },
+ {
+ "name": "keyword.operator.terraform",
+ "match": "\\\u003c"
+ },
+ {
+ "name": "keyword.operator.terraform",
+ "match": "\\?"
+ },
+ {
+ "name": "keyword.operator.terraform",
+ "match": "\\.\\.\\."
+ },
+ {
+ "name": "keyword.operator.terraform",
+ "match": "\\:"
}
+ ]
+ },
+ "parens": {
+ "begin": "\\(",
+ "end": "\\)",
+ "patterns": [
+ {
+ "include": "#expressions"
+ },
+ {
+ "name": "variable.other.readwrite.terraform",
+ "match": "\\b(?!null|false|true)[[:alpha:]][[:alnum:]_-]*\\b"
+ }
],
"beginCaptures": {
- "1": {
- "name": "keyword.other.function.inline.terraform"
- },
- "2": {
- "name": "keyword.other.section.begin.terraform"
+ "0": {
+ "name": "punctuation.section.parens.begin.terraform"
}
},
"endCaptures": {
- "1": {
- "name": "keyword.other.section.end.terraform"
+ "0": {
+ "name": "punctuation.section.parens.end.terraform"
}
}
},
- "string_interpolation_keywords": {
- "match": "(terraform|var|self|count|module|path|data|local)(\\.[\\w\\*]+)+",
- "captures": {
+ "string_interpolation": {
+ "name": "meta.interpolation.terraform",
+ "begin": "(\\$|\\%)\\{",
+ "end": "\\}",
+ "patterns": [
+ {
+ "name": "keyword.operator.template.left.trim.terraform",
+ "match": "\\~\\s"
+ },
+ {
+ "name": "keyword.operator.template.right.trim.terraform",
+ "match": "\\s\\~"
+ },
+ {
+ "name": "keyword.control.terraform",
+ "match": "\\b(if|else|endif|for|in|endfor)\\b"
+ },
+ {
+ "include": "#expressions"
+ }
+ ],
+ "beginCaptures": {
"0": {
- "name": "entity.other.attribute-name.terraform"
+ "name": "keyword.other.interpolation.begin.terraform"
}
+ },
+ "endCaptures": {
+ "0": {
+ "name": "keyword.other.interpolation.end.terraform"
+ }
}
},
- "strings": {
- "begin": "\\\"",
- "end": "\\\"",
+ "string_literals": {
+ "name": "string.quoted.double.terraform",
+ "begin": "\"",
+ "end": "\"",
"patterns": [
{
"include": "#string_interpolation"
},
{
- "name": "string.quoted.double.terraform",
- "match": "([\\w\\-\\/\\._\\\\%\\(\\)]+)"
+ "name": "constant.character.escape.terraform",
+ "match": "\\\\[nrt\"\\\\]|\\\\u([[:xdigit:]]{8}|[[:xdigit:]]{4})"
}
],
"beginCaptures": {
"0": {
- "name": "string.terraform punctuation.definition.string.begin.terraform"
+ "name": "punctuation.definition.string.begin.terraform"
}
},
"endCaptures": {
"0": {
- "name": "string.terraform punctuation.definition.string.end.terraform"
+ "name": "punctuation.definition.string.end.terraform"
}
}
+ },
+ "top_level_attribute_definition": {
+ "name": "variable.declaration.terraform",
+ "match": "(\\()?(\\b(?!null|false|true)[[:alpha:]][[:alnum:]_-]*\\b)(\\))?\\s*(\\=[^\\=|\\\u003e])\\s*",
+ "captures": {
+ "1": {
+ "name": "punctuation.section.parens.begin.terraform"
+ },
+ "2": {
+ "name": "variable.other.readwrite.terraform"
+ },
+ "3": {
+ "name": "punctuation.section.parens.end.terraform"
+ },
+ "4": {
+ "name": "keyword.operator.assignment.terraform"
+ }
+ }
+ },
+ "tuple_for_expression": {
+ "begin": "\\bfor\\b",
+ "end": "(?=\\])",
+ "patterns": [
+ {
+ "name": "keyword.operator.word.terraform",
+ "match": "\\bin\\b"
+ },
+ {
+ "name": "keyword.control.conditional.terraform",
+ "match": "\\bif\\b"
+ },
+ {
+ "name": "keyword.operator.terraform",
+ "match": "\\:"
+ },
+ {
+ "include": "#expressions"
+ },
+ {
+ "include": "#comments"
+ },
+ {
+ "include": "#comma"
+ },
+ {
+ "name": "variable.other.readwrite.terraform",
+ "match": "\\b(?!null|false|true)[[:alpha:]][[:alnum:]_-]*\\b"
+ }
+ ],
+ "beginCaptures": {
+ "0": {
+ "name": "keyword.control.terraform"
+ }
+ }
+ },
+ "type_keywords": {
+ "name": "storage.type.terraform",
+ "match": "\\b(any|string|number|bool)\\b"
}
}
}