From 9ce9985f07268bb44679a64c4d5159d18e8f8fc5 Mon Sep 17 00:00:00 2001 From: Marcel Ludwig Date: Mon, 2 Nov 2020 07:52:44 +0100 Subject: [PATCH 1/2] Fix lacking support for hcl in general (variable types) Since we have no own capture groups defined we should use the hcl syntaxes as starting point. Variable highlighting is a hcl build in feature. --- package.json | 6 +- syntax/couper.json | 121 -------------------- syntaxes/hcl.json | 268 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 271 insertions(+), 124 deletions(-) delete mode 100644 syntax/couper.json create mode 100644 syntaxes/hcl.json diff --git a/package.json b/package.json index 77f6ab6..3b028e1 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "displayName": "Couper Configuration", "version": "0.0.2", "publisher": "AvengaGermanyGmbH", - "description": "Provides autocompletion, syntax/semantic validation and syntax highlighting for Couper's HCL based configuration file couper.hcl", + "description": "Provides autocompletion, syntax/semantic validation and syntax highlighting for Couper's HCL based configuration file.", "keywords": [ "couper.hcl", "couper", @@ -43,8 +43,8 @@ "grammars": [ { "language": "couper", - "scopeName": "source.couper", - "path": "./syntax/couper.json" + "scopeName": "source.hcl", + "path": "./syntaxes/hcl.json" } ] }, diff --git a/syntax/couper.json b/syntax/couper.json deleted file mode 100644 index 8fdc819..0000000 --- a/syntax/couper.json +++ /dev/null @@ -1,121 +0,0 @@ -{ - "name": "couper", - "scopeName": "source.couper", - "patterns": [ - { "include": "#comment" }, - { "include": "#string" }, - { "include": "#attribute" }, - { "include": "#block" } - ], - "repository": { - "comment": { - "patterns": [ - { - "comment": "Single line comments with number-sign", - "match": "#+.*", - "captures": { - "0": {"name": "comment.line.number-sign.couper" } - } - }, - { - "comment": "Single line comments with double-slash", - "match": "//+.*", - "captures": { - "0": { "name": "comment.line.double-slash.couper" } - } - }, - { - "comment": "Multiple line comment block", - "begin": "/\\*", - "beginCaptures": { - "0" : { "name": "comment.block.documentation.couper" } - }, - "end": "\\*/", - "endCaptures": { - "0" : { "name": "comment.block.documentation.couper" } - }, - "contentName" : "comment.block.documentation.couper" - } - ] - }, - "constant": { - "patterns": [ - { - "match": "\\b(true|false|null)\\b", - "captures": { - "0": {"name": "constant.language.couper" } - } - } - ] - }, - "variable": { - "patterns": [ - { - "match": "\\b(env|req|beresp)\\b", - "captures": { - "0": {"name": "variable.language.couper" } - } - } - ] - }, - "string": { - "name": "string.quoted.double.couper", - "begin": "\"", - "end": "\"" - }, - "heredoc" : { - "patterns" : [ - { - "begin": "<<(\\w+)", - "beginCaptures": { - "0": { "name": "entity.name.section" } - }, - "end": "^\\s*\\1$", - "endCaptures": { - "0": { "name": "entity.name.section" } - }, - "contentName": "string.unquoted.couper" - } - ] - }, - "block": { - "patterns" : [ - { - "begin": "([\\w-]+)((?:\\s*\"[^\"]*\")*)\\s*\\{", - "beginCaptures": { - "0": { "name": "meta.function.couper" }, - "1": { "name": "storage.type.couper" }, - "2": { "name": "string.quoted.double.couper" } - }, - "end": "\\}", - "patterns" : [ - { "include": "$self" }, - { "include": "#comment" }, - { "include": "#attribute" } - ] - } - ] - }, - "attribute" : { - "patterns" : [ - { - "begin": "([\\w\\.-]+)\\s*(=)\\s*", - "beginCaptures": { - "1": { "name": "variable.parameter.couper" }, - "2": { "name": "keyword.operator.couper" } - }, - "end": "(? Date: Mon, 2 Nov 2020 11:09:37 +0100 Subject: [PATCH 2/2] add more TODOs --- src/completion.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/completion.js b/src/completion.js index 90d5fd1..96b784e 100644 --- a/src/completion.js +++ b/src/completion.js @@ -158,6 +158,7 @@ const providerVariables = vscode.languages.registerCompletionItemProvider(select return undefined } + // TODO: move to schema.js const variableAttributes = { req: ['id', 'method', 'path', 'query', 'post', 'url', 'json_body'], bereq: ['method', 'path', 'query', 'post', 'url'],