diff --git a/resources/ts/highlight-terraform.ts b/resources/ts/highlight-terraform.ts index 48b18843..980f90a7 100644 --- a/resources/ts/highlight-terraform.ts +++ b/resources/ts/highlight-terraform.ts @@ -10,7 +10,7 @@ export default function (hljs: HLJSApi) { 'locals', 'module', 'data', - 'terraform|10', + 'terraform', 'for', 'in', 'if', @@ -38,21 +38,27 @@ export default function (hljs: HLJSApi) { scope: 'variable', begin: /\${/, end: /}/, - relevance: 9, }, ], + relevance: 10, }; - const PARAMETER = { - scope: 'variable', + const ATTRIBUTE = { + scope: 'attr', match: /\n\s*[a-zA-Z0-9_]+\s*(?==)/, }; - const BLOCK_PARAMETER = { + const BLOCK_ATTRIBUTE = { scope: 'keyword', match: /\n\s*[a-zA-Z0-9_]+\s*(?={)/, }; + const PARAMETER = { + scope: 'params', + begin: /(?<==\s)(?!true\b|false\b|null\b)(\[.*?]|[\w.]+)/, + relevance: 10, + }; + const FUNCTION = { scope: 'title.function', match: /[a-zA-Z0-9_]+(?=\()/, @@ -91,8 +97,9 @@ export default function (hljs: HLJSApi) { hljs.COMMENT(/#/, /$/), NUMBERS, STRINGS, + ATTRIBUTE, + BLOCK_ATTRIBUTE, PARAMETER, - BLOCK_PARAMETER, FUNCTION, EQUALS, LEFT_BRACE,