github.com/avenga/couper@v1.12.2/docs/website/assets/hcl.tmLanguage.json (about)

     1  {
     2    "name": "HCL",
     3    "scopeName": "source.hcl",
     4    "comment": "HashiCorp Configuration Language extended with Couper specific patterns",
     5    "fileTypes": [
     6      "couper",
     7      "hcl"
     8    ],
     9    "patterns": [
    10      { "include": "#comment" },
    11      { "include": "#block" },
    12      { "include": "#attribute" },
    13      { "include": "#error" }
    14    ],
    15    "repository": {
    16      "comment": {
    17        "patterns": [
    18          {
    19            "comment": "Single line comments with number-sign",
    20            "match": "(#)+(.*)",
    21            "captures": {
    22              "0": {"name": "comment.line.number-sign.hcl" }
    23            }
    24          },
    25          {
    26            "comment": "Single line comments with double-slash",
    27            "match": "(//)+(.*)",
    28            "captures": {
    29              "0": { "name": "comment.line.double-slash.hcl" }
    30            }
    31          },
    32          {
    33            "comment": "Multiple line comment block",
    34            "begin": "/\\*",
    35            "beginCaptures": {
    36              "0": { "name": "comment.block.documentation.hcl" }
    37            },
    38            "end": "\\*/",
    39            "endCaptures": {
    40              "0": { "name": "comment.block.documentation.hcl" }
    41            },
    42            "contentName": "comment.block.documentation.hcl"
    43          }
    44        ]
    45      },
    46      "error": {
    47        "patterns": [
    48          {
    49            "match": "\\S",
    50            "captures": { "0": { "name": "invalid.illegal.hcl" } }
    51          }
    52        ]
    53      },
    54      "block": {
    55        "patterns": [
    56          {
    57            "begin": "([\\p{L}\\p{Nl}\\p{Mn}\\p{Mc}\\p{Nd}\\p{Pc}-]+)((?:\\s*\"[^\"]*\")*)\\s*({)",
    58            "beginCaptures": {
    59              "1": {
    60                "name": "storage.type.hcl" ,
    61                "patterns": [ { "include": "#identifier" } ]
    62              },
    63              "2": { "name": "string.quoted.double.hcl" },
    64              "3": { "name": "storage.type.hcl" }
    65            },
    66            "end": "}",
    67            "endCaptures": {
    68              "0": { "name": "storage.type.hcl" }
    69            },
    70            "patterns": [
    71              { "include": "$self" },
    72              { "include": "#comment" },
    73              { "include": "#attribute" },
    74              { "include": "#error" }
    75            ]
    76          }
    77        ]
    78      },
    79      "attribute": {
    80        "patterns": [
    81          {
    82            "begin": "([\\p{L}\\p{Nl}\\p{Mn}\\p{Mc}\\p{Nd}\\p{Pc}-]+)\\s*(=)\\s*",
    83            "beginCaptures": {
    84              "1": {
    85                "name": "variable.parameter.hcl",
    86                "patterns": [ { "include": "#identifier" } ]
    87              },
    88              "2": { "name": "keyword.operator.hcl" }
    89            },
    90            "end": "$",
    91            "patterns": [
    92              { "include": "#comment" },
    93              { "include": "#heredoc" },
    94              { "include": "#expression" },
    95              { "include": "#error" }
    96            ]
    97          }
    98        ]
    99      },
   100      "identifier": {
   101        "patterns": [
   102          {
   103            "match": "[\\p{L}\\p{Nl}][\\p{L}\\p{Nl}\\p{Mn}\\p{Mc}\\p{Nd}\\p{Pc}-]*"
   104          },
   105          { "include": "#error" }
   106        ]
   107      },
   108      "quoted-key-assignment": {
   109        "patterns": [
   110          {
   111            "begin": "(\"[^\"]+\")\\s*([=:])\\s*",
   112            "beginCaptures": {
   113              "1": { "name": "constant.language.hcl" },
   114              "2": { "name": "keyword.operator.hcl" }
   115            },
   116            "end": "$|(?=[,}])",
   117            "patterns": [
   118              { "include": "#comment" },
   119              { "include": "#heredoc" },
   120              { "include": "#expression" },
   121              { "include": "#error" }
   122            ]
   123          }
   124        ]
   125      },
   126      "key-assignment": {
   127        "patterns": [
   128          {
   129            "begin": "([\\p{L}\\p{Nl}\\p{Mn}\\p{Mc}\\p{Nd}\\p{Pc}-]+)\\s*([:=])\\s*",
   130            "beginCaptures": {
   131              "1": {
   132                "name": "constant.language.hcl",
   133                "patterns": [ { "include": "#identifier" } ]
   134              },
   135              "2": { "name": "keyword.operator.hcl" }
   136            },
   137            "end": "$|(?=[,}])",
   138            "patterns": [
   139              { "include": "#comment" },
   140              { "include": "#heredoc" },
   141              { "include": "#expression" },
   142              { "include": "#error" }
   143            ]
   144          }
   145        ]
   146      },
   147      "expression-key-assignment": {
   148        "patterns": [
   149          {
   150            "begin": "\\((.*?)\\)\\s*([=:])\\s*",
   151            "beginCaptures": {
   152              "1": {
   153                "patterns": [
   154                  { "include": "#comment" },
   155                  { "include": "#expression" },
   156                  { "include": "#error" }
   157                ]
   158              },
   159              "2": { "name": "keyword.operator.hcl" }
   160            },
   161            "end": "$|(?=[,}])",
   162            "patterns": [
   163              { "include": "#comment" },
   164              { "include": "#heredoc" },
   165              { "include": "#expression" },
   166              { "include": "#error" }
   167            ]
   168          }
   169        ]
   170      },
   171      "expression": {
   172        "patterns": [
   173          { "include": "#string" },
   174          { "include": "#numeric-literal" },
   175          { "include": "#constant" },
   176          { "include": "#for-expression" },
   177          { "include": "#tuple" },
   178          { "include": "#object" },
   179          { "include": "#expr-term-get-attr" },
   180          { "include": "#function-call" },
   181          { "include": "#variable" },
   182          { "include": "#operator" },
   183          { "include": "#parenthesized-expression" }
   184        ]
   185      },
   186      "operator": {
   187        "patterns": [
   188          {
   189            "match": "&&|\\|\\||==|!=|<=|>=|<=|[!?:+*/%<>-]|\\.\\.\\.",
   190            "captures": {
   191               "0": { "name": "keyword.operator.hcl" }
   192             }
   193          }
   194        ]
   195      },
   196      "parenthesized-expression": {
   197        "patterns": [
   198          {
   199            "begin": "\\(",
   200            "end": "\\)",
   201            "patterns": [
   202              { "include": "#comment" },
   203              { "include": "#expression" },
   204              { "include": "#error" }
   205            ]
   206          }
   207        ]
   208      },
   209      "variable": {
   210        "patterns": [
   211          {
   212            "match": "\\b(couper|env|request|backend_requests?|backend_responses?)\\b",
   213            "captures": {
   214              "0": { "name": "variable.language.hcl" }
   215            }
   216          }
   217        ]
   218      },
   219      "expr-term-get-attr": {
   220        "patterns": [
   221          {
   222            "match": "(\\.)\\s*([\\w-]+)(?:\\s*(\\.)\\s*([\\w-]+))?",
   223            "captures": {
   224              "1": { "name": "keyword.operator.hcl" },
   225              "2": { "name": "variable.other.hcl" },
   226              "3": { "name": "keyword.operator.hcl" },
   227              "4": { "name": "variable.language.hcl" }
   228            }
   229          }
   230        ]
   231      },
   232      "for-expression": {
   233        "patterns": [
   234          {
   235            "begin": "{for\\s+(?!=)",
   236            "beginCaptures": {
   237              "0": { "name": "keyword.control.hcl" }
   238            },
   239            "end": "}",
   240            "endCaptures": {
   241              "0": { "name": "keyword.control.hcl" }
   242            },
   243            "patterns": [
   244              { "include": "#for-operator" },
   245              { "include": "#expression" },
   246              { "include": "#for-condition" }
   247            ]
   248          },
   249          {
   250            "begin": "\\[for\\s+",
   251            "beginCaptures": {
   252              "0": { "name": "keyword.control.hcl" }
   253            },
   254            "end": "\\]",
   255            "endCaptures": {
   256              "0": { "name": "keyword.control.hcl" }
   257            },
   258            "patterns": [
   259              { "include": "#for-operator" },
   260              { "include": "#expression" },
   261              { "include": "#for-condition" }
   262            ]
   263          }
   264        ]
   265      },
   266      "for-condition": {
   267        "patterns": [
   268          {
   269            "begin": "if",
   270            "beginCaptures": {
   271               "0": { "name": "keyword.control.hcl" }
   272            },
   273            "end": "(?=[\\]}])",
   274            "patterns": [
   275              { "include": "#expression" }
   276            ]
   277          }
   278        ]
   279      },
   280      "for-operator": {
   281        "patterns": [
   282          {
   283            "match": "\\bin\\b|=>",
   284            "captures": {
   285              "0": { "name": "keyword.control.hcl" }
   286            }
   287          }
   288        ]
   289      },
   290      "template": {
   291        "patterns": [
   292          { "include": "#template-interpolation" },
   293          { "include": "#template-directive" }
   294        ]
   295      },
   296      "template-interpolation": {
   297        "patterns": [
   298          {
   299            "begin": "(?<!\\$)\\${~?",
   300            "beginCaptures": {
   301              "0": { "name": "punctuation.section.interpolation.begin.hcl" }
   302            },
   303            "end": "~?}",
   304            "endCaptures": {
   305              "0": { "name": "punctuation.section.interpolation.end.hcl" }
   306            },
   307            "patterns": [
   308              { "include": "#expression" }
   309            ]
   310          }
   311        ]
   312      },
   313      "template-directive": {
   314        "patterns": [
   315          {
   316            "begin": "(?<!%)\\%{~?\\s*(if|for)\\b",
   317            "beginCaptures": {
   318              "0": { "name": "keyword.control.hcl" }
   319            },
   320            "end": "~?}",
   321            "endCaptures": {
   322              "0": { "name": "keyword.control.hcl" }
   323            },
   324            "patterns": [
   325              { "include": "#expression" },
   326              {
   327                "match": "in",
   328                "captures": {
   329                  "0": { "name": "keyword.control.hcl" }
   330                }
   331              }
   332            ]
   333          },
   334          {
   335            "match": "(?<!%)\\%{~?\\s*(endif|endfor|else)\\s*~?}",
   336            "captures": {
   337              "0": { "name": "keyword.control.hcl" }
   338            }
   339          }
   340        ]
   341      },
   342      "function-call": {
   343        "patterns": [
   344          {
   345            "begin": "([\\w-]+)\\(",
   346            "beginCaptures": {
   347              "1": { "name": "entity.name.function.hcl" }
   348            },
   349            "end": "\\)",
   350            "patterns": [
   351              { "include": "#comment" },
   352              { "include": "#expression" }
   353            ]
   354          }
   355        ]
   356      },
   357      "tuple": {
   358        "patterns": [
   359          {
   360            "begin": "\\[(?!for\\s)",
   361            "end": "\\]",
   362            "patterns": [
   363              { "include": "#comment" },
   364              { "include": "#expression" },
   365              { "match": "(?<![,\\[\\s])\\s*," },
   366              { "include": "#error" }
   367            ]
   368          }
   369        ]
   370      },
   371      "object": {
   372        "patterns": [
   373          {
   374            "begin": "{(?!for\\s)",
   375            "end": "}",
   376            "patterns": [
   377              { "include": "#comment" },
   378              { "include": "#key-assignment" },
   379              { "include": "#quoted-key-assignment" },
   380              { "include": "#expression-key-assignment" },
   381              { "match": "(?<![,{\\s])\\s*,"},
   382              { "include": "#error" }
   383            ]
   384          }
   385        ]
   386      },
   387      "numeric-literal": {
   388        "patterns": [
   389          {
   390            "match": "\\b[0-9]+(\\.[0-9]+)?([eE][+-]?[0-9]+)?\\b",
   391            "captures": {
   392              "0": { "name": "constant.numeric.hcl" }
   393            }
   394          }
   395        ]
   396      },
   397      "constant": {
   398        "patterns": [
   399          {
   400            "match": "\\b(true|false|null)\\b",
   401            "captures": {
   402              "0": { "name": "constant.language.hcl" }
   403            }
   404          }
   405        ]
   406      },
   407      "string": {
   408        "patterns": [
   409          {
   410            "comment": "Usual string",
   411            "begin": "\"",
   412            "beginCaptures": {
   413              "0": { "name": "string.quoted.double.hcl" }
   414            },
   415            "end": "\"",
   416            "endCaptures": {
   417              "0": { "name": "string.quoted.double.hcl" }
   418            },
   419            "patterns": [
   420              { "include": "#template" },
   421              {
   422                "match": "\\\\[nrt\\\\\"]|\\\\u([a-fA-F0-9]{8}|[a-fA-F0-9]{4})",
   423                "captures": {
   424                  "0": { "name": "constant.character.escape.hcl" }
   425                }
   426              },
   427              {
   428                "match": ".",
   429                "captures": {
   430                  "0": { "name": "string.quoted.double.hcl" }
   431                }
   432              }
   433            ]
   434          }
   435        ]
   436      },
   437      "heredoc": {
   438        "patterns": [
   439          {
   440            "comment": "Heredoc string",
   441            "begin": "<<-?([\\w-]+)",
   442            "beginCaptures": {
   443              "0": { "name": "entity.name.tag.hcl" }
   444            },
   445            "end": "^\\s*\\1$",
   446            "endCaptures": {
   447              "0": { "name": "entity.name.tag.hcl" }
   448            },
   449            "contentName": "string.unquoted.here-doc.hcl"
   450          }
   451        ]
   452      }
   453    }
   454  }