From 96448605b6930af38bf9a8039d007ac05cf2e910 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 10 Jan 2022 09:26:27 +0100 Subject: [PATCH 01/16] Bump lint-staged from 12.1.5 to 12.1.7 (#1840) --- package-lock.json | 28 +++++++++++++++++----------- package.json | 2 +- 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/package-lock.json b/package-lock.json index 91b5f7e1e2..a995146024 100644 --- a/package-lock.json +++ b/package-lock.json @@ -880,13 +880,13 @@ } }, "string-width": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-5.0.1.tgz", - "integrity": "sha512-5ohWO/M4//8lErlUUtrFy3b11GtNOuMOU0ysKCDXFcfXuuvUXu95akgj/i8ofmaGdN0hCqyl6uu9i8dS/mQp5g==", + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-5.1.0.tgz", + "integrity": "sha512-7x54QnN21P+XL/v8SuNKvfgsUre6PXpN7mc77N3HlZv+f1SBRGmjxtOud2Z6FZ8DmdkD/IdjCaf9XXbnqmTZGQ==", "dev": true, "requires": { + "eastasianwidth": "^0.2.0", "emoji-regex": "^9.2.2", - "is-fullwidth-code-point": "^4.0.0", "strip-ansi": "^7.0.1" } }, @@ -1056,6 +1056,12 @@ "esutils": "^2.0.2" } }, + "eastasianwidth": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/eastasianwidth/-/eastasianwidth-0.2.0.tgz", + "integrity": "sha512-I88TYZWc9XiYHRQ4/3c5rjjfgkjhLyW2luGIheGERbNQ6OY7yTybanSpDXZa8y7VUP9YmDcYa+eyq4ca7iLqWA==", + "dev": true + }, "emoji-regex": { "version": "8.0.0", "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", @@ -2488,9 +2494,9 @@ "dev": true }, "lint-staged": { - "version": "12.1.5", - "resolved": "https://registry.npmjs.org/lint-staged/-/lint-staged-12.1.5.tgz", - "integrity": "sha512-WyKb+0sNKDTd1LwwAfTBPp0XmdaKkAOEbg4oHE4Kq2+oQVchg/VAcjVQtSqZih1izNsTURjc2EkhG/syRQUXdA==", + "version": "12.1.7", + "resolved": "https://registry.npmjs.org/lint-staged/-/lint-staged-12.1.7.tgz", + "integrity": "sha512-bltv/ejiLWtowExpjU+s5z8j1Byjg9AlmaAjMmqNbIicY69u6sYIwXGg0dCn0TlkrrY2CphtHIXAkbZ+1VoWQQ==", "dev": true, "requires": { "cli-truncate": "^3.1.0", @@ -2554,9 +2560,9 @@ } }, "listr2": { - "version": "3.13.5", - "resolved": "https://registry.npmjs.org/listr2/-/listr2-3.13.5.tgz", - "integrity": "sha512-3n8heFQDSk+NcwBn3CgxEibZGaRzx+pC64n3YjpMD1qguV4nWus3Al+Oo3KooqFKTQEJ1v7MmnbnyyNspgx3NA==", + "version": "3.14.0", + "resolved": "https://registry.npmjs.org/listr2/-/listr2-3.14.0.tgz", + "integrity": "sha512-TyWI8G99GX9GjE54cJ+RrNMcIFBfwMPxc3XTFiAYGN4s10hWROGtOg7+O6u6LE3mNkyld7RSLE6nrKBvTfcs3g==", "dev": true, "requires": { "cli-truncate": "^2.1.0", @@ -2564,7 +2570,7 @@ "log-update": "^4.0.0", "p-map": "^4.0.0", "rfdc": "^1.3.0", - "rxjs": "^7.4.0", + "rxjs": "^7.5.1", "through": "^2.3.8", "wrap-ansi": "^7.0.0" }, diff --git a/package.json b/package.json index df8951bd27..b31b36f1f9 100644 --- a/package.json +++ b/package.json @@ -336,7 +336,7 @@ "eslint-plugin-react-hooks": "4.3.0", "eslint-plugin-wc": "^1.3.2", "husky": "^7.0.4", - "lint-staged": "^12.1.5", + "lint-staged": "^12.1.7", "prettier": "^2.5.1", "rimraf": "3.0.2", "ts-loader": "^8.0.10", From 0908fe23b34f915f344d1981ee5adfe32db66706 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 12 Jan 2022 08:40:12 +0100 Subject: [PATCH 02/16] Bump vscode-extension-telemetry from 0.4.4 to 0.4.5 (#1842) Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- package-lock.json | 6 +++--- package.json | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/package-lock.json b/package-lock.json index a995146024..5097915b8f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3894,9 +3894,9 @@ "dev": true }, "vscode-extension-telemetry": { - "version": "0.4.4", - "resolved": "https://registry.npmjs.org/vscode-extension-telemetry/-/vscode-extension-telemetry-0.4.4.tgz", - "integrity": "sha512-LzirNf2GnykXCAqqWrvj+snYqgkPVyjwM72tYOHgcZiG/ZRuNjmqlgvs+SomEJdmD8cutduitPmhoyIuzOrVfA==" + "version": "0.4.5", + "resolved": "https://registry.npmjs.org/vscode-extension-telemetry/-/vscode-extension-telemetry-0.4.5.tgz", + "integrity": "sha512-YhPiPcelqM5xyYWmD46jIcsxLYWkPZhAxlBkzqmpa218fMtTT17ERdOZVCXcs1S5AjvDHlq43yCgi8TaVQjjEg==" }, "vscode-json-languageservice": { "version": "3.9.1", diff --git a/package.json b/package.json index b31b36f1f9..2130219a20 100644 --- a/package.json +++ b/package.json @@ -349,7 +349,7 @@ "bufferutil": "^4.0.6", "home-assistant-js-websocket": "^6.0.1", "utf-8-validate": "^5.0.8", - "vscode-extension-telemetry": "0.4.4", + "vscode-extension-telemetry": "0.4.5", "vscode-json-languageservice": "^3.9.1", "vscode-languageclient": "6.1.3", "vscode-languageserver": "6.1.1", From 6ff6bfcaf26afcf367b2848e6cef6479e02621cd Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 14 Jan 2022 08:28:13 +0100 Subject: [PATCH 03/16] Bump ws from 8.4.0 to 8.4.1 (#1846) Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- package-lock.json | 6 +++--- package.json | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/package-lock.json b/package-lock.json index 5097915b8f..377e52d04a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -4057,9 +4057,9 @@ "dev": true }, "ws": { - "version": "8.4.0", - "resolved": "https://registry.npmjs.org/ws/-/ws-8.4.0.tgz", - "integrity": "sha512-IHVsKe2pjajSUIl4KYMQOdlyliovpEPquKkqbwswulszzI7r0SfQrxnXdWAEqOlDCLrVSJzo+O1hAwdog2sKSQ==" + "version": "8.4.1", + "resolved": "https://registry.npmjs.org/ws/-/ws-8.4.1.tgz", + "integrity": "sha512-6eqQ4yN2y2xv8b+BgbkUzPPyfo/PDl3VOWb06ZE0jIFYwuHMsMQN6F7o84yxJYCblfCRAxzpU59We4Rr4w0Luw==" }, "y18n": { "version": "5.0.8", diff --git a/package.json b/package.json index 2130219a20..4c709815de 100644 --- a/package.json +++ b/package.json @@ -356,7 +356,7 @@ "vscode-languageserver-protocol": "3.15.3", "vscode-languageserver-textdocument": "^1.0.2", "vscode-uri": "3.0.3", - "ws": "8.4.0", + "ws": "8.4.1", "yaml": "1.10.2", "yaml-language-server": "0.12.0" } From ada946d56c490bcf44c022a595d636e75bb275e8 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 14 Jan 2022 08:28:38 +0100 Subject: [PATCH 04/16] Bump ws from 8.4.0 to 8.4.1 in /src/language-service (#1847) Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- src/language-service/package-lock.json | 6 +++--- src/language-service/package.json | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/language-service/package-lock.json b/src/language-service/package-lock.json index 2bcaa73795..1fe7f4514e 100644 --- a/src/language-service/package-lock.json +++ b/src/language-service/package-lock.json @@ -3595,9 +3595,9 @@ "dev": true }, "ws": { - "version": "8.4.0", - "resolved": "https://registry.npmjs.org/ws/-/ws-8.4.0.tgz", - "integrity": "sha512-IHVsKe2pjajSUIl4KYMQOdlyliovpEPquKkqbwswulszzI7r0SfQrxnXdWAEqOlDCLrVSJzo+O1hAwdog2sKSQ==" + "version": "8.4.1", + "resolved": "https://registry.npmjs.org/ws/-/ws-8.4.1.tgz", + "integrity": "sha512-6eqQ4yN2y2xv8b+BgbkUzPPyfo/PDl3VOWb06ZE0jIFYwuHMsMQN6F7o84yxJYCblfCRAxzpU59We4Rr4w0Luw==" }, "y18n": { "version": "5.0.8", diff --git a/src/language-service/package.json b/src/language-service/package.json index 290824003d..dacfebbe8a 100644 --- a/src/language-service/package.json +++ b/src/language-service/package.json @@ -70,7 +70,7 @@ "vscode-json-languageservice": "3.9.1", "vscode-languageserver-protocol": "3.15.3", "vscode-uri": "3.0.3", - "ws": "8.4.0", + "ws": "8.4.1", "yaml": "1.10.2", "yaml-language-server": "0.12.0" }, From b8ae7acb3c778668d1d1878283b1d5483bae0568 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 14 Jan 2022 08:36:59 +0100 Subject: [PATCH 05/16] Bump follow-redirects from 1.14.5 to 1.14.7 (#1849) Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- package-lock.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 377e52d04a..89a5f4810d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1861,9 +1861,9 @@ "dev": true }, "follow-redirects": { - "version": "1.14.5", - "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.14.5.tgz", - "integrity": "sha512-wtphSXy7d4/OR+MvIFbCVBDzZ5520qV8XfPklSN5QtxuMUJZ+b0Wnst1e1lCDocfzuCkHqj8k0FpZqO+UIaKNA==" + "version": "1.14.7", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.14.7.tgz", + "integrity": "sha512-+hbxoLbFMbRKDwohX8GkTataGqO6Jb7jGwpAlwgy2bIz25XtRm7KEzJM76R1WiNT5SwZkX4Y75SwBolkpmE7iQ==" }, "form-data": { "version": "2.5.1", From c261db688fa75f3fd6f5839a213f729f2eced5d5 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 14 Jan 2022 08:37:11 +0100 Subject: [PATCH 06/16] Bump follow-redirects from 1.14.5 to 1.14.7 in /src/language-service (#1848) Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- src/language-service/package-lock.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/language-service/package-lock.json b/src/language-service/package-lock.json index 1fe7f4514e..296d885787 100644 --- a/src/language-service/package-lock.json +++ b/src/language-service/package-lock.json @@ -1740,9 +1740,9 @@ "dev": true }, "follow-redirects": { - "version": "1.14.5", - "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.14.5.tgz", - "integrity": "sha512-wtphSXy7d4/OR+MvIFbCVBDzZ5520qV8XfPklSN5QtxuMUJZ+b0Wnst1e1lCDocfzuCkHqj8k0FpZqO+UIaKNA==" + "version": "1.14.7", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.14.7.tgz", + "integrity": "sha512-+hbxoLbFMbRKDwohX8GkTataGqO6Jb7jGwpAlwgy2bIz25XtRm7KEzJM76R1WiNT5SwZkX4Y75SwBolkpmE7iQ==" }, "fs.realpath": { "version": "1.0.0", From e18eadd6ab33b572694cf825f12280f06d4d0d68 Mon Sep 17 00:00:00 2001 From: Kuba Wolanin Date: Fri, 14 Jan 2022 08:43:23 +0100 Subject: [PATCH 07/16] Add Jinja2 inside yaml files support #78 (#1845) --- package.json | 111 +- syntaxes/external/YAML.tmLanguage | 1151 +++++++++++++++++ syntaxes/external/jinja.tmLanguage.json | 349 +++++ .../generated/jinja-braces-block.tmLanguage | 58 + .../generated/jinja-braces.tmLanguage | 58 + .../generated/jinja-conditionals.tmLanguage | 619 +++++++++ .../jinja-double-quote-escape.tmLanguage | 56 + .../generated/jinja-extras.tmLanguage | 63 + .../generated/jinja-keywords.tmLanguage | 46 + .../jinja-single-quote-escape.tmLanguage | 56 + syntaxes/jinja-language-configuration.json | 32 + .../yaml-language-configuration.json | 0 yaml-language/yaml.tmLanguage.json | 621 --------- 13 files changed, 2594 insertions(+), 626 deletions(-) create mode 100644 syntaxes/external/YAML.tmLanguage create mode 100644 syntaxes/external/jinja.tmLanguage.json create mode 100644 syntaxes/home-assistant/generated/jinja-braces-block.tmLanguage create mode 100644 syntaxes/home-assistant/generated/jinja-braces.tmLanguage create mode 100644 syntaxes/home-assistant/generated/jinja-conditionals.tmLanguage create mode 100644 syntaxes/home-assistant/generated/jinja-double-quote-escape.tmLanguage create mode 100644 syntaxes/home-assistant/generated/jinja-extras.tmLanguage create mode 100644 syntaxes/home-assistant/generated/jinja-keywords.tmLanguage create mode 100644 syntaxes/home-assistant/generated/jinja-single-quote-escape.tmLanguage create mode 100644 syntaxes/jinja-language-configuration.json rename yaml-language/language-configuration.json => syntaxes/yaml-language-configuration.json (100%) delete mode 100644 yaml-language/yaml.tmLanguage.json diff --git a/package.json b/package.json index 4c709815de..5a50e9081d 100644 --- a/package.json +++ b/package.json @@ -80,21 +80,122 @@ "languages": [ { "id": "home-assistant", - "configuration": "./yaml-language/language-configuration.json", + "configuration": "./syntaxes/yaml-language-configuration.json", "extensions": [ ".yml", ".yaml" ], "aliases": [ - "Home Assistant" + "Home Assistant", + "homeassistant", + "home-assistant" ] + }, + { + "comments": "unfortunately this dummy entry is necessary for embedding to work", + "id": "home-assistant-jinja", + "configuration": "./jinja-language-configuration.json" } ], "grammars": [ { + "comments": [ + "YAML syntax as base for Home Assistant", + "scopeName changed so that we can use it as base for injections" + ], "language": "home-assistant", - "scopeName": "source.yaml", - "path": "./yaml-language/yaml.tmLanguage.json" + "scopeName": "source.home-assistant", + "path": "./syntaxes/external/YAML.tmLanguage" + }, + { + "comments": [ + "Jinja syntax as injection into Home Assistant YAML", + "This is so that we do not need to rely on the Jinja extension being installed" + ], + "language": "home-assistant-jinja", + "scopeName": "source.home-assistant-jinja", + "path": "./syntaxes/external/jinja.tmLanguage.json" + }, + { + "comments": [ + "Highlighting of Home Assistant keywords in Jinja" + ], + "path": "./syntaxes/home-assistant/generated/jinja-keywords.tmLanguage", + "scopeName": "injection.homeassistant.jinja-keywords", + "injectTo": [ + "source.home-assistant-jinja" + ] + }, + { + "comments": [ + "Additional Jinja grammars" + ], + "path": "./syntaxes/home-assistant/generated/jinja-extras.tmLanguage", + "scopeName": "injection.homeassistant.jinja-extras", + "injectTo": [ + "source.home-assistant" + ] + }, + { + "comments": [ + "Support for Jinja in double curly braces" + ], + "path": "./syntaxes/home-assistant/generated/jinja-braces.tmLanguage", + "scopeName": "injection.homeassistant.jinja-braces", + "embeddedLanguages": { + "meta.embedded.inline.jinja": "home-assistant-jinja" + }, + "injectTo": [ + "source.home-assistant" + ] + }, + { + "comments": [ + "Support for Jinja in single curly braces with percentage symbol" + ], + "path": "./syntaxes/home-assistant/generated/jinja-braces-block.tmLanguage", + "scopeName": "injection.homeassistant.jinja-braces-block", + "embeddedLanguages": { + "meta.embedded.block.jinja": "home-assistant-jinja" + }, + "injectTo": [ + "source.home-assistant" + ] + }, + { + "comments": [ + "Support for Jinja in conditionals" + ], + "path": "./syntaxes/home-assistant/generated/jinja-conditionals.tmLanguage", + "scopeName": "injection.homeassistant.jinja-conditionals", + "embeddedLanguages": { + "meta.embedded.inline.jinja": "home-assistant-jinja" + }, + "injectTo": [ + "source.home-assistant" + ] + }, + { + "comments": [ + "The quote escapes implemented in the conditionals injection do not work inside brackets etc.", + "Support for single quote escapes in Jinja" + ], + "path": "./syntaxes/home-assistant/generated/jinja-single-quote-escape.tmLanguage", + "scopeName": "injection.homeassistant.jinja-single-quote-escape", + "injectTo": [ + "source.home-assistant" + ] + }, + { + "comments": [ + "The quote escapes implemented in the conditionals injection do not work inside brackets etc.", + "Support for double quote escapes in Jinja" + ], + "path": "./syntaxes/home-assistant/generated/jinja-double-quote-escape.tmLanguage", + "scopeName": "injection.homeassistant.jinja-double-quote-escape", + "injectTo": [ + "source.home-assistant" + ] } ], "commands": [ @@ -360,4 +461,4 @@ "yaml": "1.10.2", "yaml-language-server": "0.12.0" } -} +} \ No newline at end of file diff --git a/syntaxes/external/YAML.tmLanguage b/syntaxes/external/YAML.tmLanguage new file mode 100644 index 0000000000..a88fd47961 --- /dev/null +++ b/syntaxes/external/YAML.tmLanguage @@ -0,0 +1,1151 @@ + + + + + comment + + Imported from: + https://github.com/textmate/yaml.tmbundle/blob/e54ceae3b719506dba7e481a77cea4a8b576ae46/Syntaxes/YAML.tmLanguage + Applied fix for entity.name.tag, which was split on the first letter + Replaced all `.yaml` scopes with `.homeassistant` to avoid replacing syntax for regular YAML files. + Injected `jinja-conditionals` + + fileTypes + + yaml + yml + rviz + reek + clang-format + yaml-tmlanguage + syntax + sublime-syntax + + firstLineMatch + ^%YAML( ?1.\d+)? + keyEquivalent + ^~Y + name + YAML + patterns + + + include + injection.homeassistant.jinja-conditionals + + + include + #comment + + + include + #property + + + include + #directive + + + match + ^--- + name + entity.other.document.begin.homeassistant + + + match + ^\.{3} + name + entity.other.document.end.homeassistant + + + include + #node + + + repository + + block-collection + + patterns + + + include + #block-sequence + + + include + #block-mapping + + + + block-mapping + + patterns + + + include + #block-pair + + + + block-node + + patterns + + + include + #prototype + + + include + #block-scalar + + + include + #block-collection + + + include + #flow-scalar-plain-out + + + include + #flow-node + + + + block-pair + + patterns + + + begin + \? + beginCaptures + + 1 + + name + punctuation.definition.key-value.begin.homeassistant + + + end + (?=\?)|^ *(:)|(:) + endCaptures + + 1 + + name + punctuation.separator.key-value.mapping.homeassistant + + 2 + + name + invalid.illegal.expected-newline.homeassistant + + + name + meta.block-mapping.homeassistant + patterns + + + include + #block-node + + + + + begin + (?x) (?= + (?x: + [^\s[-?:,\[\]{}#&*!|>'"%@`]] + | [?:-] \S + ) + ( + [^\s:] + | : \S + | \s+ (?![#\s]) + )* + \s* + : + (\s|$) + ) + + end + (?x) (?= + \s* $ + | \s+ \# + | \s* : (\s|$) + ) + + patterns + + + include + #flow-scalar-plain-out-implicit-type + + + begin + (?x) (?= + [^\s[-?:,\[\]{}#&*!|>'"%@`]] + | [?:-] \S + ) + + contentName + entity.name.tag.homeassistant + end + (?x) (?= + \s* $ + | \s+ \# + | \s* : (\s|$) + ) + + name + string.unquoted.plain.out.homeassistant + + + + + match + :(?=\s|$) + name + punctuation.separator.key-value.mapping.homeassistant + + + + block-scalar + + begin + (?:(\|)|(>))([1-9])?([-+])?(.*\n?) + beginCaptures + + 1 + + name + keyword.control.flow.block-scalar.literal.homeassistant + + 2 + + name + keyword.control.flow.block-scalar.folded.homeassistant + + 3 + + name + constant.numeric.indentation-indicator.homeassistant + + 4 + + name + storage.modifier.chomping-indicator.homeassistant + + 5 + + patterns + + + include + #comment + + + match + .+ + name + invalid.illegal.expected-comment-or-newline.homeassistant + + + + + end + ^(?=\S)|(?!\G) + patterns + + + begin + ^([ ]+)(?! ) + end + ^(?!\1|\s*$) + name + string.unquoted.block.homeassistant + + + + block-sequence + + match + (-)(?!\S) + name + punctuation.definition.block.sequence.item.homeassistant + + comment + + begin + (?:(^[ \t]*)|[ \t]+)(?=#\p{Print}*$) + beginCaptures + + 1 + + name + punctuation.whitespace.comment.leading.homeassistant + + + end + (?!\G) + patterns + + + begin + # + beginCaptures + + 0 + + name + punctuation.definition.comment.homeassistant + + + end + \n + name + comment.line.number-sign.homeassistant + + + + directive + + begin + ^% + beginCaptures + + 0 + + name + punctuation.definition.directive.begin.homeassistant + + + end + (?=$|[ \t]+($|#)) + name + meta.directive.homeassistant + patterns + + + captures + + 1 + + name + keyword.other.directive.yaml.homeassistant + + 2 + + name + constant.numeric.yaml-version.homeassistant + + + match + \G(YAML)[ \t]+(\d+\.\d+) + + + captures + + 1 + + name + keyword.other.directive.tag.homeassistant + + 2 + + name + storage.type.tag-handle.homeassistant + + 3 + + name + support.type.tag-prefix.homeassistant + + + match + (?x) + \G + (TAG) + (?:[ \t]+ + ((?:!(?:[0-9A-Za-z\-]*!)?)) + (?:[ \t]+ ( + ! (?x: %[0-9A-Fa-f]{2} | [0-9A-Za-z\-#;/?:@&=+$,_.!~*'()\[\]] )* + | (?![,!\[\]{}]) (?x: %[0-9A-Fa-f]{2} | [0-9A-Za-z\-#;/?:@&=+$,_.!~*'()\[\]] )+ + ) + )? + )? + + + + captures + + 1 + + name + support.other.directive.reserved.homeassistant + + 2 + + name + string.unquoted.directive-name.homeassistant + + 3 + + name + string.unquoted.directive-parameter.homeassistant + + + match + (?x) \G (\w+) (?:[ \t]+ (\w+) (?:[ \t]+ (\w+))? )? + + + match + \S+ + name + invalid.illegal.unrecognized.homeassistant + + + + flow-alias + + captures + + 1 + + name + keyword.control.flow.alias.homeassistant + + 2 + + name + punctuation.definition.alias.homeassistant + + 3 + + name + variable.other.alias.homeassistant + + 4 + + name + invalid.illegal.character.anchor.homeassistant + + + match + ((\*))([^\s\[\]/{/},]+)([^\s\]},]\S*)? + + flow-collection + + patterns + + + include + #flow-sequence + + + include + #flow-mapping + + + + flow-mapping + + begin + \{ + beginCaptures + + 0 + + name + punctuation.definition.mapping.begin.homeassistant + + + end + \} + endCaptures + + 0 + + name + punctuation.definition.mapping.end.homeassistant + + + name + meta.flow-mapping.homeassistant + patterns + + + include + #prototype + + + match + , + name + punctuation.separator.mapping.homeassistant + + + include + #flow-pair + + + + flow-node + + patterns + + + include + #prototype + + + include + #flow-alias + + + include + #flow-collection + + + include + #flow-scalar + + + + flow-pair + + patterns + + + begin + \? + beginCaptures + + 0 + + name + punctuation.definition.key-value.begin.homeassistant + + + end + (?=[},\]]) + name + meta.flow-pair.explicit.homeassistant + patterns + + + include + #prototype + + + include + #flow-pair + + + include + #flow-node + + + begin + :(?=\s|$|[\[\]{},]) + beginCaptures + + 0 + + name + punctuation.separator.key-value.mapping.homeassistant + + + end + (?=[},\]]) + patterns + + + include + #flow-value + + + + + + + begin + (?x) (?= + (?: + [^\s[-?:,\[\]{}#&*!|>'"%@`]] + | [?:-] [^\s[\[\]{},]] + ) + ( + [^\s:[\[\]{},]] + | : [^\s[\[\]{},]] + | \s+ (?![#\s]) + )* + \s* + : + (\s|$) + ) + + end + (?x) (?= + \s* $ + | \s+ \# + | \s* : (\s|$) + | \s* : [\[\]{},] + | \s* [\[\]{},] + ) + + name + meta.flow-pair.key.homeassistant + patterns + + + include + #flow-scalar-plain-in-implicit-type + + + begin + (?x) (?= + [^\s[-?:,\[\]{}#&*!|>'"%@`]] + | [?:-] [^\s[\[\]{},]] + ) + + contentName + entity.name.tag.homeassistant + end + (?x) (?= + \s* $ + | \s+ \# + | \s* : (\s|$) + | \s* : [\[\]{},] + | \s* [\[\]{},] + ) + + name + string.unquoted.plain.in.homeassistant + + + + + include + #flow-node + + + begin + :(?=\s|$|[\[\]{},]) + captures + + 0 + + name + punctuation.separator.key-value.mapping.homeassistant + + + end + (?=[},\]]) + name + meta.flow-pair.homeassistant + patterns + + + include + #flow-value + + + + + + flow-scalar + + patterns + + + include + #flow-scalar-double-quoted + + + include + #flow-scalar-single-quoted + + + include + #flow-scalar-plain-in + + + + flow-scalar-double-quoted + + begin + " + beginCaptures + + 0 + + name + punctuation.definition.string.begin.homeassistant + + + end + " + endCaptures + + 0 + + name + punctuation.definition.string.end.homeassistant + + + name + string.quoted.double.homeassistant + patterns + + + match + \\([0abtnvfre "/\\N_Lp]|x\d\d|u\d{4}|U\d{8}) + name + constant.character.escape.homeassistant + + + match + \\\n + name + constant.character.escape.double-quoted.newline.homeassistant + + + + flow-scalar-plain-in + + patterns + + + include + #flow-scalar-plain-in-implicit-type + + + begin + (?x) + [^\s[-?:,\[\]{}#&*!|>'"%@`]] + | [?:-] [^\s[\[\]{},]] + + end + (?x) (?= + \s* $ + | \s+ \# + | \s* : (\s|$) + | \s* : [\[\]{},] + | \s* [\[\]{},] + ) + + name + string.unquoted.plain.in.homeassistant + + + + flow-scalar-plain-in-implicit-type + + patterns + + + captures + + 1 + + name + constant.language.null.homeassistant + + 2 + + name + constant.language.boolean.homeassistant + + 3 + + name + constant.numeric.integer.homeassistant + + 4 + + name + constant.numeric.float.homeassistant + + 5 + + name + constant.other.timestamp.homeassistant + + 6 + + name + constant.language.value.homeassistant + + 7 + + name + constant.language.merge.homeassistant + + + match + (?x) + (?x: + (null|Null|NULL|~) + | (y|Y|yes|Yes|YES|n|N|no|No|NO|true|True|TRUE|false|False|FALSE|on|On|ON|off|Off|OFF) + | ( + (?: + [-+]? 0b [0-1_]+ # (base 2) + | [-+]? 0 [0-7_]+ # (base 8) + | [-+]? (?: 0|[1-9][0-9_]*) # (base 10) + | [-+]? 0x [0-9a-fA-F_]+ # (base 16) + | [-+]? [1-9] [0-9_]* (?: :[0-5]?[0-9])+ # (base 60) + ) + ) + | ( + (?x: + [-+]? (?: [0-9] [0-9_]*)? \. [0-9.]* (?: [eE] [-+] [0-9]+)? # (base 10) + | [-+]? [0-9] [0-9_]* (?: :[0-5]?[0-9])+ \. [0-9_]* # (base 60) + | [-+]? \. (?: inf|Inf|INF) # (infinity) + | \. (?: nan|NaN|NAN) # (not a number) + ) + ) + | ( + (?x: + \d{4} - \d{2} - \d{2} # (y-m-d) + | \d{4} # (year) + - \d{1,2} # (month) + - \d{1,2} # (day) + (?: [Tt] | [ \t]+) \d{1,2} # (hour) + : \d{2} # (minute) + : \d{2} # (second) + (?: \.\d*)? # (fraction) + (?: + (?:[ \t]*) Z + | [-+] \d{1,2} (?: :\d{1,2})? + )? # (time zone) + ) + ) + | (=) + | (<<) + ) + (?: (?= + \s* $ + | \s+ \# + | \s* : (\s|$) + | \s* : [\[\]{},] + | \s* [\[\]{},] + ) + ) + + + + + flow-scalar-plain-out + + patterns + + + include + #flow-scalar-plain-out-implicit-type + + + begin + (?x) + [^\s[-?:,\[\]{}#&*!|>'"%@`]] + | [?:-] \S + + end + (?x) (?= + \s* $ + | \s+ \# + | \s* : (\s|$) + ) + + name + string.unquoted.plain.out.homeassistant + + + + flow-scalar-plain-out-implicit-type + + patterns + + + captures + + 1 + + name + constant.language.null.homeassistant + + 2 + + name + constant.language.boolean.homeassistant + + 3 + + name + constant.numeric.integer.homeassistant + + 4 + + name + constant.numeric.float.homeassistant + + 5 + + name + constant.other.timestamp.homeassistant + + 6 + + name + constant.language.value.homeassistant + + 7 + + name + constant.language.merge.homeassistant + + + match + (?x) + (?x: + (null|Null|NULL|~) + | (y|Y|yes|Yes|YES|n|N|no|No|NO|true|True|TRUE|false|False|FALSE|on|On|ON|off|Off|OFF) + | ( + (?: + [-+]? 0b [0-1_]+ # (base 2) + | [-+]? 0 [0-7_]+ # (base 8) + | [-+]? (?: 0|[1-9][0-9_]*) # (base 10) + | [-+]? 0x [0-9a-fA-F_]+ # (base 16) + | [-+]? [1-9] [0-9_]* (?: :[0-5]?[0-9])+ # (base 60) + ) + ) + | ( + (?x: + [-+]? (?: [0-9] [0-9_]*)? \. [0-9.]* (?: [eE] [-+] [0-9]+)? # (base 10) + | [-+]? [0-9] [0-9_]* (?: :[0-5]?[0-9])+ \. [0-9_]* # (base 60) + | [-+]? \. (?: inf|Inf|INF) # (infinity) + | \. (?: nan|NaN|NAN) # (not a number) + ) + ) + | ( + (?x: + \d{4} - \d{2} - \d{2} # (y-m-d) + | \d{4} # (year) + - \d{1,2} # (month) + - \d{1,2} # (day) + (?: [Tt] | [ \t]+) \d{1,2} # (hour) + : \d{2} # (minute) + : \d{2} # (second) + (?: \.\d*)? # (fraction) + (?: + (?:[ \t]*) Z + | [-+] \d{1,2} (?: :\d{1,2})? + )? # (time zone) + ) + ) + | (=) + | (<<) + ) + (?x: (?= + \s* $ + | \s+ \# + | \s* : (\s|$) + ) + ) + + + + + flow-scalar-single-quoted + + begin + ' + beginCaptures + + 0 + + name + punctuation.definition.string.begin.homeassistant + + + end + '(?!') + endCaptures + + 0 + + name + punctuation.definition.string.end.homeassistant + + + name + string.quoted.single.homeassistant + patterns + + + match + '' + name + constant.character.escape.single-quoted.homeassistant + + + + flow-sequence + + begin + \[ + beginCaptures + + 0 + + name + punctuation.definition.sequence.begin.homeassistant + + + end + \] + endCaptures + + 0 + + name + punctuation.definition.sequence.end.homeassistant + + + name + meta.flow-sequence.homeassistant + patterns + + + include + #prototype + + + match + , + name + punctuation.separator.sequence.homeassistant + + + include + #flow-pair + + + include + #flow-node + + + + flow-value + + patterns + + + begin + \G(?![},\]]) + end + (?=[},\]]) + name + meta.flow-pair.value.homeassistant + patterns + + + include + #flow-node + + + + + + node + + patterns + + + include + #block-node + + + + property + + begin + (?=!|&) + end + (?!\G) + name + meta.property.homeassistant + patterns + + + captures + + 1 + + name + keyword.control.property.anchor.homeassistant + + 2 + + name + punctuation.definition.anchor.homeassistant + + 3 + + name + entity.name.type.anchor.homeassistant + + 4 + + name + invalid.illegal.character.anchor.homeassistant + + + match + \G((&))([^\s\[\]/{/},]+)(\S+)? + + + match + (?x) + \G + (?: + ! < (?: %[0-9A-Fa-f]{2} | [0-9A-Za-z\-#;/?:@&=+$,_.!~*'()\[\]] )+ > + | (?:!(?:[0-9A-Za-z\-]*!)?) (?: %[0-9A-Fa-f]{2} | [0-9A-Za-z\-#;/?:@&=+$_.~*'()] )+ + | ! + ) (?=\ |\t|$) + + name + storage.type.tag-handle.homeassistant + + + match + \S+ + name + invalid.illegal.tag-handle.homeassistant + + + + prototype + + patterns + + + include + #comment + + + include + #property + + + + + scopeName + source.home-assistant + uuid + F7CD338E-F316-57A5-89ED-71CED70A819E + + \ No newline at end of file diff --git a/syntaxes/external/jinja.tmLanguage.json b/syntaxes/external/jinja.tmLanguage.json new file mode 100644 index 0000000000..b181dd3b16 --- /dev/null +++ b/syntaxes/external/jinja.tmLanguage.json @@ -0,0 +1,349 @@ +{ + "name": "home-assistant-jinja", + "scopeName": "source.home-assistant-jinja", + "comment": [ + "Jinja Templates", + "Imported from:", + "https://github.com/samuelcolvin/jinjahtml-vscode/blob/b8fe444cbd838afb4962bb2446e67c85e0443675/syntaxes/jinja.tmLanguage.js5on" + ], + "foldingStartMarker": "({%\\s*(block|filter|for|if|macro|raw))", + "foldingStopMarker": "({%\\s*(endblock|endfilter|endfor|endif|endmacro|endraw)\\s*%})", + "patterns": [ + { + "begin": "({%)\\s*(raw)\\s*(%})", + "captures": { + "1": { + "name": "entity.other.jinja.delimiter.tag" + }, + "2": { + "name": "keyword.control.jinja" + }, + "3": { + "name": "entity.other.jinja.delimiter.tag" + } + }, + "end": "({%)\\s*(endraw)\\s*(%})", + "name": "comment.block.jinja.raw" + }, + { + "include": "#comments" + }, + { + "begin": "{{-?", + "captures": [ + { + "name": "entity.other.jinja.delimiter.variable" + } + ], + "end": "-?}}", + "name": "meta.scope.jinja.variable", + "patterns": [ + { + "include": "#expression" + } + ] + }, + { + "begin": "{%-?", + "captures": [ + { + "name": "entity.other.jinja.delimiter.tag" + } + ], + "end": "-?%}", + "name": "meta.scope.jinja.tag", + "patterns": [ + { + "include": "#expression" + } + ] + } + ], + "repository": { + "comments": { + "begin": "{#-?", + "captures": [ + { + "name": "entity.other.jinja.delimiter.comment" + } + ], + "end": "-?#}", + "name": "comment.block.jinja", + "patterns": [ + { + "include": "#comments" + } + ] + }, + "escaped_char": { + "match": "\\\\x[0-9A-F]{2}", + "name": "constant.character.escape.hex.jinja" + }, + "escaped_unicode_char": { + "captures": { + "1": { + "name": "constant.character.escape.unicode.16-bit-hex.jinja" + }, + "2": { + "name": "constant.character.escape.unicode.32-bit-hex.jinja" + }, + "3": { + "name": "constant.character.escape.unicode.name.jinja" + } + }, + "match": "(\\\\U[0-9A-Fa-f]{8})|(\\\\u[0-9A-Fa-f]{4})|(\\\\N\\{[a-zA-Z ]+\\})" + }, + "expression": { + "patterns": [ + { + "captures": { + "1": { + "name": "keyword.control.jinja" + }, + "2": { + "name": "variable.other.jinja.block" + } + }, + "match": "\\s*\\b(block)\\s+([a-zA-Z_][a-zA-Z0-9_]*)\\b" + }, + { + "captures": { + "1": { + "name": "keyword.control.jinja" + }, + "2": { + "name": "variable.other.jinja.filter" + } + }, + "match": "\\s*\\b(filter)\\s+([a-zA-Z_][a-zA-Z0-9_]*)\\b" + }, + { + "captures": { + "1": { + "name": "keyword.control.jinja" + }, + "2": { + "name": "variable.other.jinja.test" + } + }, + "match": "\\s*\\b(is)\\s+([a-zA-Z_][a-zA-Z0-9_]*)\\b" + }, + { + "captures": { + "1": { + "name": "keyword.control.jinja" + } + }, + "match": "(?<=\\{\\%-|\\{\\%)\\s*\\b([a-zA-Z_][a-zA-Z0-9_]*)\\b(?!\\s*[,=])" + }, + { + "match": "\\b(and|else|if|in|import|not|or|recursive|with(out)?\\s+context)\\b", + "name": "keyword.control.jinja" + }, + { + "match": "\\b(true|false|none)\\b", + "name": "constant.language.jinja" + }, + { + "match": "\\b(loop|super|self|varargs|kwargs)\\b", + "name": "variable.language.jinja" + }, + { + "match": "[a-zA-Z_][a-zA-Z0-9_]*", + "name": "variable.other.jinja" + }, + { + "match": "(\\+|\\-|\\*\\*|\\*|\/\/|\/|%)", + "name": "keyword.operator.arithmetic.jinja" + }, + { + "captures": { + "1": { + "name": "punctuation.other.jinja" + }, + "2": { + "name": "variable.other.jinja.filter" + } + }, + "match": "(\\|)([a-zA-Z_][a-zA-Z0-9_]*)" + }, + { + "captures": { + "1": { + "name": "punctuation.other.jinja" + }, + "2": { + "name": "variable.other.jinja.attribute" + } + }, + "match": "(\\.)([a-zA-Z_][a-zA-Z0-9_]*)" + }, + { + "begin": "\\[", + "captures": [ + { + "name": "punctuation.other.jinja" + } + ], + "end": "\\]", + "patterns": [ + { + "include": "#expression" + } + ] + }, + { + "begin": "\\(", + "captures": [ + { + "name": "punctuation.other.jinja" + } + ], + "end": "\\)", + "patterns": [ + { + "include": "#expression" + } + ] + }, + { + "begin": "\\{", + "captures": [ + { + "name": "punctuation.other.jinja" + } + ], + "end": "\\}", + "patterns": [ + { + "include": "#expression" + } + ] + }, + { + "match": "(\\.|:|\\||,)", + "name": "punctuation.other.jinja" + }, + { + "match": "(==|<=|=>|<|>|!=)", + "name": "keyword.operator.comparison.jinja" + }, + { + "match": "=", + "name": "keyword.operator.assignment.jinja" + }, + { + "begin": "\"", + "beginCaptures": [ + { + "name": "punctuation.definition.string.begin.jinja" + } + ], + "end": "\"", + "endCaptures": [ + { + "name": "punctuation.definition.string.end.jinja" + } + ], + "name": "string.quoted.double.jinja", + "patterns": [ + { + "include": "#string" + } + ] + }, + { + "begin": "'", + "beginCaptures": [ + { + "name": "punctuation.definition.string.begin.jinja" + } + ], + "end": "'", + "endCaptures": [ + { + "name": "punctuation.definition.string.end.jinja" + } + ], + "name": "string.quoted.single.jinja", + "patterns": [ + { + "include": "#string" + } + ] + }, + { + "begin": "@\/", + "beginCaptures": [ + { + "name": "punctuation.definition.regexp.begin.jinja" + } + ], + "end": "\/", + "endCaptures": [ + { + "name": "punctuation.definition.regexp.end.jinja" + } + ], + "name": "string.regexp.jinja", + "patterns": [ + { + "include": "#simple_escapes" + } + ] + } + ] + }, + "simple_escapes": { + "captures": { + "1": { + "name": "constant.character.escape.newline.jinja" + }, + "10": { + "name": "constant.character.escape.tab.jinja" + }, + "11": { + "name": "constant.character.escape.vertical-tab.jinja" + }, + "2": { + "name": "constant.character.escape.backlash.jinja" + }, + "3": { + "name": "constant.character.escape.double-quote.jinja" + }, + "4": { + "name": "constant.character.escape.single-quote.jinja" + }, + "5": { + "name": "constant.character.escape.bell.jinja" + }, + "6": { + "name": "constant.character.escape.backspace.jinja" + }, + "7": { + "name": "constant.character.escape.formfeed.jinja" + }, + "8": { + "name": "constant.character.escape.linefeed.jinja" + }, + "9": { + "name": "constant.character.escape.return.jinja" + } + }, + "match": "(\\\\\\n)|(\\\\\\\\)|(\\\\\\\")|(\\\\')|(\\\\a)|(\\\\b)|(\\\\f)|(\\\\n)|(\\\\r)|(\\\\t)|(\\\\v)" + }, + "string": { + "patterns": [ + { + "include": "#simple_escapes" + }, + { + "include": "#escaped_char" + }, + { + "include": "#escaped_unicode_char" + } + ] + } + } +} \ No newline at end of file diff --git a/syntaxes/home-assistant/generated/jinja-braces-block.tmLanguage b/syntaxes/home-assistant/generated/jinja-braces-block.tmLanguage new file mode 100644 index 0000000000..dec203f9fb --- /dev/null +++ b/syntaxes/home-assistant/generated/jinja-braces-block.tmLanguage @@ -0,0 +1,58 @@ + + + + + scopeName + injection.homeassistant.jinja-braces-block + injectionSelector + L:string -meta.embedded.block.jinja + name + Grammar for Jinja2 expressions surrounded by curly braces and percentage symbol + patterns + + + include + #jinja-expression + + + repository + + jinja-expression + + comment + The 'name' is used to undo highlighting as string + name + keyword.operator.homeassistant + begin + \{% + end + %\} + beginCaptures + + 0 + + name + constant.character.escape.homeassistant + + + endCaptures + + 0 + + name + constant.character.escape.homeassistant + + + contentName + meta.embedded.block.jinja + patterns + + + include + source.home-assistant-jinja#expression + + + + + + \ No newline at end of file diff --git a/syntaxes/home-assistant/generated/jinja-braces.tmLanguage b/syntaxes/home-assistant/generated/jinja-braces.tmLanguage new file mode 100644 index 0000000000..48be41b521 --- /dev/null +++ b/syntaxes/home-assistant/generated/jinja-braces.tmLanguage @@ -0,0 +1,58 @@ + + + + + scopeName + injection.homeassistant.jinja-braces + injectionSelector + L:string -meta.embedded.inline.jinja + name + Grammar for Jinja2 expressions surrounded by double curly braces + patterns + + + include + #jinja-expression + + + repository + + jinja-expression + + comment + The 'name' is used to undo highlighting as string + name + keyword.operator.homeassistant + begin + \{\{ + end + \}\} + beginCaptures + + 0 + + name + constant.character.escape.homeassistant + + + endCaptures + + 0 + + name + constant.character.escape.homeassistant + + + contentName + meta.embedded.inline.jinja + patterns + + + include + source.home-assistant-jinja#expression + + + + + + \ No newline at end of file diff --git a/syntaxes/home-assistant/generated/jinja-conditionals.tmLanguage b/syntaxes/home-assistant/generated/jinja-conditionals.tmLanguage new file mode 100644 index 0000000000..009b9ea17f --- /dev/null +++ b/syntaxes/home-assistant/generated/jinja-conditionals.tmLanguage @@ -0,0 +1,619 @@ + + + + + scopeName + injection.homeassistant.jinja-conditionals + name + Grammar for Jinja2 expressions in homeassistant conditionals + patterns + + + include + #homeassistant-condition + + + comment + + Flow style collections are not supported (yet) + + repository + + homeassistant-condition + + patterns + + + name + meta.flow-unquoted.homeassistant.condition + begin + (?x) + ^(\s*) # 1 + (?:(-)(\s+))? # 2, 3; in case it is first key of a list item + \b( # 4 + changed_when + | failed_when + | when + | check_mode + )\b + \s* (:) # 5 (?=\s) (?!\s*[|>'"]|\s*$|\s*\#.*$) # starting an unquoted flow + + beginCaptures + + 2 + + name + punctuation.definition.block.sequence.item.homeassistant + + 4 + + name + keyword.other.special-method.homeassistant + + 5 + + name + punctuation.separator.key-value.mapping.homeassistant + + + end + (?x) + ^(?!\1\3\3\s+) # if the indentation is too small; HACK: \3 is used twice to match at least 2 spaces if group 2 matches + + patterns + + + include + source.homeassistant#comment + + + include + #yaml-unquoted-string + + + + + name + meta.flow.homeassistant.condition + begin + (?x) + ^(\s*) # 1 + (?:(-)(\s+))? # 2, 3; in case it is first key of a list item + \b( # 4 + changed_when + | failed_when + | when + | check_mode + )\b + \s* (:) # 5 (?=\s) (?!\s*[|>]|\s*$|\s*\#.*$) # not starting a block (scalar or other) + + beginCaptures + + 2 + + name + punctuation.definition.block.sequence.item.homeassistant + + 4 + + name + keyword.other.special-method.homeassistant + + 5 + + name + punctuation.separator.key-value.mapping.homeassistant + + + end + (?x) + ^(?!\1\3\3\s+) # if the indentation is too small; HACK: \3 is used twice to match at least 2 spaces if group 2 matches + + patterns + + + include + source.homeassistant#comment + + + include + #yaml-double-quoted-string + + + include + #yaml-single-quoted-string + + + include + #yaml-unquoted-string + + + + + name + meta.block-scalar.homeassistant.condition + begin + (?x) + ^(\s*) # 1 + (?:(-)(\s+))? # 2, 3; in case it is first key of a list item + \b( # 4 + changed_when + | failed_when + | when + | check_mode + )\b + \s* (:) # 5 + \s+ (?: (\|) | (>) ) ([1-9])? ([-+])? # 6,7,8,9; starting a scalar block + (.*$) # comment or illegal + + beginCaptures + + 2 + + name + punctuation.definition.block.sequence.item.homeassistant + + 4 + + name + keyword.other.special-method.homeassistant + + 5 + + name + punctuation.separator.key-value.mapping.homeassistant + + 6 + + name + keyword.control.flow.block-scalar.literal.homeassistant + + 7 + + name + keyword.control.flow.block-scalar.folded.homeassistant + + 8 + + name + constant.numeric.indentation-indicator.homeassistant + + 9 + + name + storage.modifier.chomping-indicator.homeassistant + + 10 + + patterns + + + include + source.homeassistant#comment + + + match + .+ + name + invalid.illegal.expected-comment-or-newline.homeassistant + + + + + end + (?x) + ^(?!\1\3\3\s+) # if the indentation is too small; HACK: \3 is used twice to match at least 2 spaces if group 2 matches + + patterns + + + include + #yaml-scalar-block + + + + + name + meta.block.homeassistant.condition + begin + (?x) + ^(\s*) # 1 + (?:(-)(\s+))? # 2, 3; in case it is first key of a list item + \b( # 4 + changed_when + | failed_when + | when + | check_mode + )\b + \s* (:) # 5 + (.*$) # comment or illegal + + beginCaptures + + 2 + + name + punctuation.definition.block.sequence.item.homeassistant + + 4 + + name + keyword.other.special-method.homeassistant + + 5 + + name + punctuation.separator.key-value.mapping.homeassistant + + 6 + + patterns + + + include + source.homeassistant#comment + + + match + .+ + name + invalid.illegal.expected-comment-or-newline.homeassistant + + + + + end + (?x) + ^(?!\1\3\3\s+) # if the indentation is too small; HACK: \3 is used twice to match at least 2 spaces if group 2 matches + + patterns + + + include + #yaml-block + + + + + + yaml-block + + patterns + + + name + meta.yaml-block.homeassistant.condition + comment + + Well-indented block + + begin + (?x) ^(?=(\s+)) # 1 + + end + (?x) + (?!\G) # otherwise match is found immediately + ^(?!\1\s+) # if the indentation is too small + + patterns + + + include + source.homeassistant#comment + + + include + #yaml-block-list-item + + + include + #yaml-double-quoted-string + + + include + #yaml-single-quoted-string + + + include + #yaml-unquoted-string-block + + + include + #yaml-unquoted-string + + + + + + yaml-block-list-item + + patterns + + + name + meta.yaml-block-list-item.homeassistant.condition + comment + + Well-indented list item block + + begin + (?x) + ^(\s*) # 1 + (-)(\s) # 2, 3 + + beginCaptures + + 2 + + name + punctuation.definition.block.sequence.item.homeassistant + + + end + (?x) + ^(?!\1\3\s+) # if the indentation is too small + + patterns + + + include + source.homeassistant#comment + + + include + #yaml-double-quoted-string + + + include + #yaml-single-quoted-string + + + include + #yaml-unquoted-string + + + + + + yaml-scalar-block + + patterns + + + name + meta.yaml-scalar-block.homeassistant.condition + comment + + Well-indented scalar block (for `>` and `|`) + + begin + (?x) + ^(\s*) # 1 + + end + (?x) + ^(?!\1\s+) # if the indentation is too small + + contentName + keyword.operator.homeassistant meta.embedded.inline.jinja + patterns + + + include + #yaml-unquoted-string + + + + + + yaml-single-quoted-string + + patterns + + + name + string.quoted.single.homeassistant.meta + begin + (?<=:\s|-\s|^)\s*' + beginCaptures + + 0 + + name + punctuation.definition.string.begin.homeassistant + + + end + (?x) + ('(?!')) # 1; match the starting quote + (?: (?=\s+\#) | (.*$) ) # 2; unless it is a comment anything trailing here is illegal + + endCaptures + + 1 + + name + punctuation.definition.string.end.homeassistant + + 2 + + name + invalid.illegal.expected-comment-or-newline.homeassistant + + + contentName + keyword.operator.homeassistant meta.embedded.inline.jinja + patterns + + + begin + '' + beginCaptures + + 0 + + name + constant.character.escape.single-quoted.homeassistant + + + end + '' + endCaptures + + 0 + + name + constant.character.escape.single-quoted.homeassistant + + + contentName + string.quoted.single.jinja + patterns + + + include + source.home-assistant-jinja#string + + + + + include + source.home-assistant-jinja#expression + + + + + + yaml-double-quoted-string + + patterns + + + name + string.quoted.double.homeassistant.meta + begin + (?<=:\s|-\s|^)\s*" + beginCaptures + + 0 + + name + punctuation.definition.string.begin.homeassistant + + + end + (?x) + (") # 1; match the starting quote + (?: (?=\s+\#) | (.*$) ) # 2; unless it is a comment anything trailing here is illegal + + endCaptures + + 1 + + name + punctuation.definition.string.end.homeassistant + + 2 + + name + invalid.illegal.expected-comment-or-newline.homeassistant + + + contentName + keyword.operator.homeassistant meta.embedded.inline.jinja + patterns + + + begin + \\" + beginCaptures + + 0 + + name + constant.character.escape.double-quoted.homeassistant + + + end + \\" + endCaptures + + 0 + + name + constant.character.escape.double-quoted.homeassistant + + + contentName + string.quoted.double.jinja + patterns + + + include + source.home-assistant-jinja#string + + + + + include + source.home-assistant-jinja#expression + + + + + + yaml-unquoted-string + + patterns + + + comment + Capture any non-whitespace and end as fast as possible (when inner pattern ends) + name + string.unquoted.homeassistant + begin + (?=\S) + end + (?!\G) + contentName + keyword.operator.homeassistant meta.embedded.inline.jinja + patterns + + + include + source.home-assistant-jinja#expression + + + + + + yaml-unquoted-string-block + + patterns + + + comment + Capture any non-whitespace at the beginning of a block + name + string.unquoted-block.homeassistant + begin + (?x) + ^(\s*) # 1 (?=\S) + end + (?x) + ^(?!\1\s*) # if the indentation is too small + contentName + keyword.operator.homeassistant meta.embedded.inline.jinja + patterns + + + include + source.home-assistant-jinja#expression + + + + + + + + \ No newline at end of file diff --git a/syntaxes/home-assistant/generated/jinja-double-quote-escape.tmLanguage b/syntaxes/home-assistant/generated/jinja-double-quote-escape.tmLanguage new file mode 100644 index 0000000000..7372668c7b --- /dev/null +++ b/syntaxes/home-assistant/generated/jinja-double-quote-escape.tmLanguage @@ -0,0 +1,56 @@ + + + + + scopeName + injection.homeassistant.jinja-double-quote-escape + injectionSelector + L:string.quoted.double meta.embedded.inline.jinja + name + Injection grammar for supproting double quote escapes in Jinja2 expressions + patterns + + + name + string.quoted.double.jinja + match + (\\")(.*?)(\\") + captures + + 1 + + name + constant.character.escape.double-quoted.homeassistant + + 2 + + patterns + + + include + source.home-assistant-jinja#string + + + + 3 + + name + constant.character.escape.double-quoted.homeassistant + + + + + name + invalid.illegal.expected-escaped-double-quote.homeassistant + comment + + This technique will remind the user to use quote escaping + + match + (?x) + "(?! \s+ (?=\#|$)) # we accept the quote only if the line ends or ends with a comment + + + + + \ No newline at end of file diff --git a/syntaxes/home-assistant/generated/jinja-extras.tmLanguage b/syntaxes/home-assistant/generated/jinja-extras.tmLanguage new file mode 100644 index 0000000000..1a4ecb5f34 --- /dev/null +++ b/syntaxes/home-assistant/generated/jinja-extras.tmLanguage @@ -0,0 +1,63 @@ + + + + + scopeName + injection.homeassistant.jinja-extras + injectionSelector + L:meta.embedded.inline.jinja -string.quoted.double.jinja -string.quoted.single.jinja + name + Grammar for Jinja2 syntax highlighting that is not provided out-of-the-box + patterns + + + include + #literals + + + repository + + literals + + match + (?x) + (none|None) + | (true|True|false|False) + | ( + [-+]? 0b [0-1_]+ # (base 2) + | [-+]? 0x [0-9a-fA-F_]+ # (base 16) + | [-+]? 0 [0-7_]+ # (base 8) + | [-+]? (?: 0|[1-9][0-9_]*) # (base 10) + | [-+]? [1-9] [0-9_]* (?: :[0-5]?[0-9])+ # (base 60) + ) + | ( + [-+]? (?: [0-9] [0-9_]*)? \. [0-9.]* (?: [eE] [-+] [0-9]+)? # (base 10) + | [-+]? [0-9] [0-9_]* (?: :[0-5]?[0-9])+ \. [0-9_]* # (base 60) + ) + captures + + 1 + + name + constant.language.none.homeassistant + + 2 + + name + constant.language.boolean.homeassistant + + 3 + + name + constant.numeric.integer.homeassistant + + 4 + + name + constant.numeric.float.homeassistant + + + + + + \ No newline at end of file diff --git a/syntaxes/home-assistant/generated/jinja-keywords.tmLanguage b/syntaxes/home-assistant/generated/jinja-keywords.tmLanguage new file mode 100644 index 0000000000..1fa01e12c0 --- /dev/null +++ b/syntaxes/home-assistant/generated/jinja-keywords.tmLanguage @@ -0,0 +1,46 @@ + + + + + scopeName + injection.homeassistant.jinja-keywords + injectionSelector + L:variable.other.jinja + name + Grammar for detecting Home Assistant keywords + comment + + Extracted from: + https://github.com/home-assistant/core/blob/dev/homeassistant/helpers/template.py + + patterns + + + include + #keyword + + + repository + + keyword + + name + keyword.other.ninja + match + (?x) + \b( + acos | area_devices | area_entities | area_id | area_name | as_datetime | as_local | as_timestamp + | asin | atan | atan2 | average | base64_decode | base64_encode | bitwise_and | bitwise_or + | closest | cos | device_attr | device_entities | device_id | distance | expand | float + | from_json | int | integration_entities | is_defined | is_device_attr | is_number | is_state + | is_state_attr | log | match | max | min | multiply | now | ord | ordinal | pack | pi | random + | regex_findall | regex_findall_index | regex_match | regex_replace | regex_search | relative_time + | round | search | sin | sqrt | state_attr | states | strptime | tan | tau | timedelta + | timestamp_custom | timestamp_local | timestamp_utc | to_json | today_at | unpack | urlencode + | utcnow | value | value_json + )\b + + + + + \ No newline at end of file diff --git a/syntaxes/home-assistant/generated/jinja-single-quote-escape.tmLanguage b/syntaxes/home-assistant/generated/jinja-single-quote-escape.tmLanguage new file mode 100644 index 0000000000..5a341c314f --- /dev/null +++ b/syntaxes/home-assistant/generated/jinja-single-quote-escape.tmLanguage @@ -0,0 +1,56 @@ + + + + + scopeName + injection.homeassistant.jinja-single-quote-escape + injectionSelector + L:string.quoted.single meta.embedded.inline.jinja + name + Injection grammar for supproting single quote escapes in Jinja2 expressions + patterns + + + name + string.quoted.single.jinja + match + ('')(.*?)('') + captures + + 1 + + name + constant.character.escape.single-quoted.homeassistant + + 2 + + patterns + + + include + source.home-assistant-jinja#string + + + + 3 + + name + constant.character.escape.single-quoted.homeassistant + + + + + name + invalid.illegal.expected-escaped-single-quote.homeassistant + comment + + This technique will remind the user to use quote escaping + + match + (?x) + '(?! \s+ (?=\#|$)) # we accept the quote only if the line ends or ends with a comment + + + + + \ No newline at end of file diff --git a/syntaxes/jinja-language-configuration.json b/syntaxes/jinja-language-configuration.json new file mode 100644 index 0000000000..027840618e --- /dev/null +++ b/syntaxes/jinja-language-configuration.json @@ -0,0 +1,32 @@ +// Imported from: +// https://github.com/samuelcolvin/jinjahtml-vscode/blob/b8fe444cbd838afb4962bb2446e67c85e0443675/language-configuration.json +{ + "comments": { + // symbols used for start and end a block comment. Remove this entry if your language does not support block comments + "blockComment": [ "{#", "#}" ] + }, + // symbols used as brackets + "brackets": [ + ["{", "}"], + ["[", "]"], + ["(", ")"] + ], + // symbols that are auto closed when typing + "autoClosingPairs": [ + ["[", "]"], + ["(", ")"], + ["\"", "\""], + ["'", "'"], + ["{#", "#}"], + ["{{", "}}"], + ["{%", "%}"] + ], + // symbols that that can be used to surround a selection + "surroundingPairs": [ + ["{", "}"], + ["[", "]"], + ["(", ")"], + ["\"", "\""], + ["'", "'"] + ] +} \ No newline at end of file diff --git a/yaml-language/language-configuration.json b/syntaxes/yaml-language-configuration.json similarity index 100% rename from yaml-language/language-configuration.json rename to syntaxes/yaml-language-configuration.json diff --git a/yaml-language/yaml.tmLanguage.json b/yaml-language/yaml.tmLanguage.json deleted file mode 100644 index 90f562a3ef..0000000000 --- a/yaml-language/yaml.tmLanguage.json +++ /dev/null @@ -1,621 +0,0 @@ -{ - "information_for_contributors": [ - "This file has been converted from https://github.com/textmate/yaml.tmbundle/blob/master/Syntaxes/YAML.tmLanguage", - "If you want to provide a fix or improvement, please create a pull request against the original repository.", - "Once accepted there, we are happy to receive an update request." - ], - "version": "https://github.com/textmate/yaml.tmbundle/commit/e54ceae3b719506dba7e481a77cea4a8b576ae46", - "name": "YAML", - "scopeName": "source.yaml", - "patterns": [ - { - "include": "#comment" - }, - { - "include": "#property" - }, - { - "include": "#directive" - }, - { - "match": "^---", - "name": "entity.other.document.begin.yaml" - }, - { - "match": "^\\.{3}", - "name": "entity.other.document.end.yaml" - }, - { - "include": "#node" - } - ], - "repository": { - "block-collection": { - "patterns": [ - { - "include": "#block-sequence" - }, - { - "include": "#block-mapping" - } - ] - }, - "block-mapping": { - "patterns": [ - { - "include": "#block-pair" - } - ] - }, - "block-node": { - "patterns": [ - { - "include": "#prototype" - }, - { - "include": "#block-scalar" - }, - { - "include": "#block-collection" - }, - { - "include": "#flow-scalar-plain-out" - }, - { - "include": "#flow-node" - } - ] - }, - "block-pair": { - "patterns": [ - { - "begin": "\\?", - "beginCaptures": { - "1": { - "name": "punctuation.definition.key-value.begin.yaml" - } - }, - "end": "(?=\\?)|^ *(:)|(:)", - "endCaptures": { - "1": { - "name": "punctuation.separator.key-value.mapping.yaml" - }, - "2": { - "name": "invalid.illegal.expected-newline.yaml" - } - }, - "name": "meta.block-mapping.yaml", - "patterns": [ - { - "include": "#block-node" - } - ] - }, - { - "begin": "(?x)\n (?=\n (?x:\n [^\\s[-?:,\\[\\]{}#&*!|>'\"%@`]]\n | [?:-] \\S\n )\n (\n [^\\s:]\n | : \\S\n | \\s+ (?![#\\s])\n )*\n \\s*\n :\n\t\t\t\t\t\t\t(\\s|$)\n )\n ", - "end": "(?x)\n (?=\n \\s* $\n | \\s+ \\#\n | \\s* : (\\s|$)\n )\n ", - "patterns": [ - { - "include": "#flow-scalar-plain-out-implicit-type" - }, - { - "begin": "(?x)\n [^\\s[-?:,\\[\\]{}#&*!|>'\"%@`]]\n | [?:-] \\S\n ", - "beginCaptures": { - "0": { - "name": "entity.name.tag.yaml" - } - }, - "contentName": "entity.name.tag.yaml", - "end": "(?x)\n (?=\n \\s* $\n | \\s+ \\#\n | \\s* : (\\s|$)\n )\n ", - "name": "string.unquoted.plain.out.yaml" - } - ] - }, - { - "match": ":(?=\\s|$)", - "name": "punctuation.separator.key-value.mapping.yaml" - } - ] - }, - "block-scalar": { - "begin": "(?:(\\|)|(>))([1-9])?([-+])?(.*\\n?)", - "beginCaptures": { - "1": { - "name": "keyword.control.flow.block-scalar.literal.yaml" - }, - "2": { - "name": "keyword.control.flow.block-scalar.folded.yaml" - }, - "3": { - "name": "constant.numeric.indentation-indicator.yaml" - }, - "4": { - "name": "storage.modifier.chomping-indicator.yaml" - }, - "5": { - "patterns": [ - { - "include": "#comment" - }, - { - "match": ".+", - "name": "invalid.illegal.expected-comment-or-newline.yaml" - } - ] - } - }, - "end": "^(?=\\S)|(?!\\G)", - "patterns": [ - { - "begin": "^([ ]+)(?! )", - "end": "^(?!\\1|\\s*$)", - "name": "string.unquoted.block.yaml" - } - ] - }, - "block-sequence": { - "match": "(-)(?!\\S)", - "name": "punctuation.definition.block.sequence.item.yaml" - }, - "comment": { - "begin": "(?:(^[ \\t]*)|[ \\t]+)(?=#\\p{Print}*$)", - "beginCaptures": { - "1": { - "name": "punctuation.whitespace.comment.leading.yaml" - } - }, - "end": "(?!\\G)", - "patterns": [ - { - "begin": "#", - "beginCaptures": { - "0": { - "name": "punctuation.definition.comment.yaml" - } - }, - "end": "\\n", - "name": "comment.line.number-sign.yaml" - } - ] - }, - "directive": { - "begin": "^%", - "beginCaptures": { - "0": { - "name": "punctuation.definition.directive.begin.yaml" - } - }, - "end": "(?=$|[ \\t]+($|#))", - "name": "meta.directive.yaml", - "patterns": [ - { - "captures": { - "1": { - "name": "keyword.other.directive.yaml.yaml" - }, - "2": { - "name": "constant.numeric.yaml-version.yaml" - } - }, - "match": "\\G(YAML)[ \\t]+(\\d+\\.\\d+)" - }, - { - "captures": { - "1": { - "name": "keyword.other.directive.tag.yaml" - }, - "2": { - "name": "storage.type.tag-handle.yaml" - }, - "3": { - "name": "support.type.tag-prefix.yaml" - } - }, - "match": "(?x)\n \\G\n (TAG)\n (?:[ \\t]+\n ((?:!(?:[0-9A-Za-z\\-]*!)?))\n (?:[ \\t]+ (\n ! (?x: %[0-9A-Fa-f]{2} | [0-9A-Za-z\\-#;\/?:@&=+$,_.!~*'()\\[\\]] )*\n | (?![,!\\[\\]{}]) (?x: %[0-9A-Fa-f]{2} | [0-9A-Za-z\\-#;\/?:@&=+$,_.!~*'()\\[\\]] )+\n )\n )?\n )?\n " - }, - { - "captures": { - "1": { - "name": "support.other.directive.reserved.yaml" - }, - "2": { - "name": "string.unquoted.directive-name.yaml" - }, - "3": { - "name": "string.unquoted.directive-parameter.yaml" - } - }, - "match": "(?x) \\G (\\w+) (?:[ \\t]+ (\\w+) (?:[ \\t]+ (\\w+))? )?" - }, - { - "match": "\\S+", - "name": "invalid.illegal.unrecognized.yaml" - } - ] - }, - "flow-alias": { - "captures": { - "1": { - "name": "keyword.control.flow.alias.yaml" - }, - "2": { - "name": "punctuation.definition.alias.yaml" - }, - "3": { - "name": "variable.other.alias.yaml" - }, - "4": { - "name": "invalid.illegal.character.anchor.yaml" - } - }, - "match": "((\\*))([^\\s\\[\\]\/{\/},]+)([^\\s\\]},]\\S*)?" - }, - "flow-collection": { - "patterns": [ - { - "include": "#flow-sequence" - }, - { - "include": "#flow-mapping" - } - ] - }, - "flow-mapping": { - "begin": "\\{", - "beginCaptures": { - "0": { - "name": "punctuation.definition.mapping.begin.yaml" - } - }, - "end": "\\}", - "endCaptures": { - "0": { - "name": "punctuation.definition.mapping.end.yaml" - } - }, - "name": "meta.flow-mapping.yaml", - "patterns": [ - { - "include": "#prototype" - }, - { - "match": ",", - "name": "punctuation.separator.mapping.yaml" - }, - { - "include": "#flow-pair" - } - ] - }, - "flow-node": { - "patterns": [ - { - "include": "#prototype" - }, - { - "include": "#flow-alias" - }, - { - "include": "#flow-collection" - }, - { - "include": "#flow-scalar" - } - ] - }, - "flow-pair": { - "patterns": [ - { - "begin": "\\?", - "beginCaptures": { - "0": { - "name": "punctuation.definition.key-value.begin.yaml" - } - }, - "end": "(?=[},\\]])", - "name": "meta.flow-pair.explicit.yaml", - "patterns": [ - { - "include": "#prototype" - }, - { - "include": "#flow-pair" - }, - { - "include": "#flow-node" - }, - { - "begin": ":(?=\\s|$|[\\[\\]{},])", - "beginCaptures": { - "0": { - "name": "punctuation.separator.key-value.mapping.yaml" - } - }, - "end": "(?=[},\\]])", - "patterns": [ - { - "include": "#flow-value" - } - ] - } - ] - }, - { - "begin": "(?x)\n (?=\n (?:\n [^\\s[-?:,\\[\\]{}#&*!|>'\"%@`]]\n | [?:-] [^\\s[\\[\\]{},]]\n )\n (\n [^\\s:[\\[\\]{},]]\n | : [^\\s[\\[\\]{},]]\n | \\s+ (?![#\\s])\n )*\n \\s*\n :\n\t\t\t\t\t\t\t(\\s|$)\n )\n ", - "end": "(?x)\n (?=\n \\s* $\n | \\s+ \\#\n | \\s* : (\\s|$)\n | \\s* : [\\[\\]{},]\n | \\s* [\\[\\]{},]\n )\n ", - "name": "meta.flow-pair.key.yaml", - "patterns": [ - { - "include": "#flow-scalar-plain-in-implicit-type" - }, - { - "begin": "(?x)\n [^\\s[-?:,\\[\\]{}#&*!|>'\"%@`]]\n | [?:-] [^\\s[\\[\\]{},]]\n ", - "beginCaptures": { - "0": { - "name": "entity.name.tag.yaml" - } - }, - "contentName": "entity.name.tag.yaml", - "end": "(?x)\n (?=\n \\s* $\n | \\s+ \\#\n | \\s* : (\\s|$)\n | \\s* : [\\[\\]{},]\n | \\s* [\\[\\]{},]\n )\n ", - "name": "string.unquoted.plain.in.yaml" - } - ] - }, - { - "include": "#flow-node" - }, - { - "begin": ":(?=\\s|$|[\\[\\]{},])", - "captures": { - "0": { - "name": "punctuation.separator.key-value.mapping.yaml" - } - }, - "end": "(?=[},\\]])", - "name": "meta.flow-pair.yaml", - "patterns": [ - { - "include": "#flow-value" - } - ] - } - ] - }, - "flow-scalar": { - "patterns": [ - { - "include": "#flow-scalar-double-quoted" - }, - { - "include": "#flow-scalar-single-quoted" - }, - { - "include": "#flow-scalar-plain-in" - } - ] - }, - "flow-scalar-double-quoted": { - "begin": "\"", - "beginCaptures": { - "0": { - "name": "punctuation.definition.string.begin.yaml" - } - }, - "end": "\"", - "endCaptures": { - "0": { - "name": "punctuation.definition.string.end.yaml" - } - }, - "name": "string.quoted.double.yaml", - "patterns": [ - { - "match": "\\\\([0abtnvfre \"\/\\\\N_Lp]|x\\d\\d|u\\d{4}|U\\d{8})", - "name": "constant.character.escape.yaml" - }, - { - "match": "\\\\\\n", - "name": "constant.character.escape.double-quoted.newline.yaml" - } - ] - }, - "flow-scalar-plain-in": { - "patterns": [ - { - "include": "#flow-scalar-plain-in-implicit-type" - }, - { - "begin": "(?x)\n [^\\s[-?:,\\[\\]{}#&*!|>'\"%@`]]\n | [?:-] [^\\s[\\[\\]{},]]\n ", - "end": "(?x)\n (?=\n \\s* $\n | \\s+ \\#\n | \\s* : (\\s|$)\n | \\s* : [\\[\\]{},]\n | \\s* [\\[\\]{},]\n )\n ", - "name": "string.unquoted.plain.in.yaml" - } - ] - }, - "flow-scalar-plain-in-implicit-type": { - "patterns": [ - { - "captures": { - "1": { - "name": "constant.language.null.yaml" - }, - "2": { - "name": "constant.language.boolean.yaml" - }, - "3": { - "name": "constant.numeric.integer.yaml" - }, - "4": { - "name": "constant.numeric.float.yaml" - }, - "5": { - "name": "constant.other.timestamp.yaml" - }, - "6": { - "name": "constant.language.value.yaml" - }, - "7": { - "name": "constant.language.merge.yaml" - } - }, - "match": "(?x)\n (?x:\n (null|Null|NULL|~)\n | (y|Y|yes|Yes|YES|n|N|no|No|NO|true|True|TRUE|false|False|FALSE|on|On|ON|off|Off|OFF)\n | (\n (?:\n [-+]? 0b [0-1_]+ # (base 2)\n | [-+]? 0 [0-7_]+ # (base 8)\n | [-+]? (?: 0|[1-9][0-9_]*) # (base 10)\n | [-+]? 0x [0-9a-fA-F_]+ # (base 16)\n | [-+]? [1-9] [0-9_]* (?: :[0-5]?[0-9])+ # (base 60)\n )\n )\n | (\n (?x:\n [-+]? (?: [0-9] [0-9_]*)? \\. [0-9.]* (?: [eE] [-+] [0-9]+)? # (base 10)\n | [-+]? [0-9] [0-9_]* (?: :[0-5]?[0-9])+ \\. [0-9_]* # (base 60)\n | [-+]? \\. (?: inf|Inf|INF) # (infinity)\n | \\. (?: nan|NaN|NAN) # (not a number)\n )\n )\n | (\n (?x:\n \\d{4} - \\d{2} - \\d{2} # (y-m-d)\n | \\d{4} # (year)\n - \\d{1,2} # (month)\n - \\d{1,2} # (day)\n (?: [Tt] | [ \\t]+) \\d{1,2} # (hour)\n : \\d{2} # (minute)\n : \\d{2} # (second)\n (?: \\.\\d*)? # (fraction)\n (?:\n (?:[ \\t]*) Z\n | [-+] \\d{1,2} (?: :\\d{1,2})?\n )? # (time zone)\n )\n )\n | (=)\n | (<<)\n )\n (?:\n (?=\n \\s* $\n | \\s+ \\#\n | \\s* : (\\s|$)\n | \\s* : [\\[\\]{},]\n | \\s* [\\[\\]{},]\n )\n )\n " - } - ] - }, - "flow-scalar-plain-out": { - "patterns": [ - { - "include": "#flow-scalar-plain-out-implicit-type" - }, - { - "begin": "(?x)\n [^\\s[-?:,\\[\\]{}#&*!|>'\"%@`]]\n | [?:-] \\S\n ", - "end": "(?x)\n (?=\n \\s* $\n | \\s+ \\#\n | \\s* : (\\s|$)\n )\n ", - "name": "string.unquoted.plain.out.yaml" - } - ] - }, - "flow-scalar-plain-out-implicit-type": { - "patterns": [ - { - "captures": { - "1": { - "name": "constant.language.null.yaml" - }, - "2": { - "name": "constant.language.boolean.yaml" - }, - "3": { - "name": "constant.numeric.integer.yaml" - }, - "4": { - "name": "constant.numeric.float.yaml" - }, - "5": { - "name": "constant.other.timestamp.yaml" - }, - "6": { - "name": "constant.language.value.yaml" - }, - "7": { - "name": "constant.language.merge.yaml" - } - }, - "match": "(?x)\n (?x:\n (null|Null|NULL|~)\n | (y|Y|yes|Yes|YES|n|N|no|No|NO|true|True|TRUE|false|False|FALSE|on|On|ON|off|Off|OFF)\n | (\n (?:\n [-+]? 0b [0-1_]+ # (base 2)\n | [-+]? 0 [0-7_]+ # (base 8)\n | [-+]? (?: 0|[1-9][0-9_]*) # (base 10)\n | [-+]? 0x [0-9a-fA-F_]+ # (base 16)\n | [-+]? [1-9] [0-9_]* (?: :[0-5]?[0-9])+ # (base 60)\n )\n )\n | (\n (?x:\n [-+]? (?: [0-9] [0-9_]*)? \\. [0-9.]* (?: [eE] [-+] [0-9]+)? # (base 10)\n | [-+]? [0-9] [0-9_]* (?: :[0-5]?[0-9])+ \\. [0-9_]* # (base 60)\n | [-+]? \\. (?: inf|Inf|INF) # (infinity)\n | \\. (?: nan|NaN|NAN) # (not a number)\n )\n )\n | (\n (?x:\n \\d{4} - \\d{2} - \\d{2} # (y-m-d)\n | \\d{4} # (year)\n - \\d{1,2} # (month)\n - \\d{1,2} # (day)\n (?: [Tt] | [ \\t]+) \\d{1,2} # (hour)\n : \\d{2} # (minute)\n : \\d{2} # (second)\n (?: \\.\\d*)? # (fraction)\n (?:\n (?:[ \\t]*) Z\n | [-+] \\d{1,2} (?: :\\d{1,2})?\n )? # (time zone)\n )\n )\n | (=)\n | (<<)\n )\n (?x:\n (?=\n \\s* $\n | \\s+ \\#\n | \\s* : (\\s|$)\n )\n )\n " - } - ] - }, - "flow-scalar-single-quoted": { - "begin": "'", - "beginCaptures": { - "0": { - "name": "punctuation.definition.string.begin.yaml" - } - }, - "end": "'(?!')", - "endCaptures": { - "0": { - "name": "punctuation.definition.string.end.yaml" - } - }, - "name": "string.quoted.single.yaml", - "patterns": [ - { - "match": "''", - "name": "constant.character.escape.single-quoted.yaml" - } - ] - }, - "flow-sequence": { - "begin": "\\[", - "beginCaptures": { - "0": { - "name": "punctuation.definition.sequence.begin.yaml" - } - }, - "end": "\\]", - "endCaptures": { - "0": { - "name": "punctuation.definition.sequence.end.yaml" - } - }, - "name": "meta.flow-sequence.yaml", - "patterns": [ - { - "include": "#prototype" - }, - { - "match": ",", - "name": "punctuation.separator.sequence.yaml" - }, - { - "include": "#flow-pair" - }, - { - "include": "#flow-node" - } - ] - }, - "flow-value": { - "patterns": [ - { - "begin": "\\G(?![},\\]])", - "end": "(?=[},\\]])", - "name": "meta.flow-pair.value.yaml", - "patterns": [ - { - "include": "#flow-node" - } - ] - } - ] - }, - "node": { - "patterns": [ - { - "include": "#block-node" - } - ] - }, - "property": { - "begin": "(?=!|&)", - "end": "(?!\\G)", - "name": "meta.property.yaml", - "patterns": [ - { - "captures": { - "1": { - "name": "keyword.control.property.anchor.yaml" - }, - "2": { - "name": "punctuation.definition.anchor.yaml" - }, - "3": { - "name": "entity.name.type.anchor.yaml" - }, - "4": { - "name": "invalid.illegal.character.anchor.yaml" - } - }, - "match": "\\G((&))([^\\s\\[\\]\/{\/},]+)(\\S+)?" - }, - { - "match": "(?x)\n \\G\n (?:\n ! < (?: %[0-9A-Fa-f]{2} | [0-9A-Za-z\\-#;\/?:@&=+$,_.!~*'()\\[\\]] )+ >\n | (?:!(?:[0-9A-Za-z\\-]*!)?) (?: %[0-9A-Fa-f]{2} | [0-9A-Za-z\\-#;\/?:@&=+$_.~*'()] )+\n | !\n )\n (?=\\ |\\t|$)\n ", - "name": "storage.type.tag-handle.yaml" - }, - { - "match": "\\S+", - "name": "invalid.illegal.tag-handle.yaml" - } - ] - }, - "prototype": { - "patterns": [ - { - "include": "#comment" - }, - { - "include": "#property" - } - ] - } - } -} \ No newline at end of file From cdf9c1b7139ee4e178d55db84c39256db4c24767 Mon Sep 17 00:00:00 2001 From: Franck Nijhof Date: Fri, 14 Jan 2022 09:15:15 +0100 Subject: [PATCH 08/16] Move syntax out of generated structure (#1850) --- package.json | 16 ++++++++-------- .../jinja-braces-block.tmLanguage | 0 .../{generated => }/jinja-braces.tmLanguage | 0 .../jinja-conditionals.tmLanguage | 0 .../jinja-double-quote-escape.tmLanguage | 0 .../{generated => }/jinja-extras.tmLanguage | 0 .../{generated => }/jinja-keywords.tmLanguage | 0 .../jinja-single-quote-escape.tmLanguage | 0 8 files changed, 8 insertions(+), 8 deletions(-) rename syntaxes/home-assistant/{generated => }/jinja-braces-block.tmLanguage (100%) rename syntaxes/home-assistant/{generated => }/jinja-braces.tmLanguage (100%) rename syntaxes/home-assistant/{generated => }/jinja-conditionals.tmLanguage (100%) rename syntaxes/home-assistant/{generated => }/jinja-double-quote-escape.tmLanguage (100%) rename syntaxes/home-assistant/{generated => }/jinja-extras.tmLanguage (100%) rename syntaxes/home-assistant/{generated => }/jinja-keywords.tmLanguage (100%) rename syntaxes/home-assistant/{generated => }/jinja-single-quote-escape.tmLanguage (100%) diff --git a/package.json b/package.json index 5a50e9081d..fdabd450bf 100644 --- a/package.json +++ b/package.json @@ -120,7 +120,7 @@ "comments": [ "Highlighting of Home Assistant keywords in Jinja" ], - "path": "./syntaxes/home-assistant/generated/jinja-keywords.tmLanguage", + "path": "./syntaxes/home-assistant/jinja-keywords.tmLanguage", "scopeName": "injection.homeassistant.jinja-keywords", "injectTo": [ "source.home-assistant-jinja" @@ -130,7 +130,7 @@ "comments": [ "Additional Jinja grammars" ], - "path": "./syntaxes/home-assistant/generated/jinja-extras.tmLanguage", + "path": "./syntaxes/home-assistant/jinja-extras.tmLanguage", "scopeName": "injection.homeassistant.jinja-extras", "injectTo": [ "source.home-assistant" @@ -140,7 +140,7 @@ "comments": [ "Support for Jinja in double curly braces" ], - "path": "./syntaxes/home-assistant/generated/jinja-braces.tmLanguage", + "path": "./syntaxes/home-assistant/jinja-braces.tmLanguage", "scopeName": "injection.homeassistant.jinja-braces", "embeddedLanguages": { "meta.embedded.inline.jinja": "home-assistant-jinja" @@ -153,7 +153,7 @@ "comments": [ "Support for Jinja in single curly braces with percentage symbol" ], - "path": "./syntaxes/home-assistant/generated/jinja-braces-block.tmLanguage", + "path": "./syntaxes/home-assistant/jinja-braces-block.tmLanguage", "scopeName": "injection.homeassistant.jinja-braces-block", "embeddedLanguages": { "meta.embedded.block.jinja": "home-assistant-jinja" @@ -166,7 +166,7 @@ "comments": [ "Support for Jinja in conditionals" ], - "path": "./syntaxes/home-assistant/generated/jinja-conditionals.tmLanguage", + "path": "./syntaxes/home-assistant/jinja-conditionals.tmLanguage", "scopeName": "injection.homeassistant.jinja-conditionals", "embeddedLanguages": { "meta.embedded.inline.jinja": "home-assistant-jinja" @@ -180,7 +180,7 @@ "The quote escapes implemented in the conditionals injection do not work inside brackets etc.", "Support for single quote escapes in Jinja" ], - "path": "./syntaxes/home-assistant/generated/jinja-single-quote-escape.tmLanguage", + "path": "./syntaxes/home-assistant/jinja-single-quote-escape.tmLanguage", "scopeName": "injection.homeassistant.jinja-single-quote-escape", "injectTo": [ "source.home-assistant" @@ -191,7 +191,7 @@ "The quote escapes implemented in the conditionals injection do not work inside brackets etc.", "Support for double quote escapes in Jinja" ], - "path": "./syntaxes/home-assistant/generated/jinja-double-quote-escape.tmLanguage", + "path": "./syntaxes/home-assistant/jinja-double-quote-escape.tmLanguage", "scopeName": "injection.homeassistant.jinja-double-quote-escape", "injectTo": [ "source.home-assistant" @@ -461,4 +461,4 @@ "yaml": "1.10.2", "yaml-language-server": "0.12.0" } -} \ No newline at end of file +} diff --git a/syntaxes/home-assistant/generated/jinja-braces-block.tmLanguage b/syntaxes/home-assistant/jinja-braces-block.tmLanguage similarity index 100% rename from syntaxes/home-assistant/generated/jinja-braces-block.tmLanguage rename to syntaxes/home-assistant/jinja-braces-block.tmLanguage diff --git a/syntaxes/home-assistant/generated/jinja-braces.tmLanguage b/syntaxes/home-assistant/jinja-braces.tmLanguage similarity index 100% rename from syntaxes/home-assistant/generated/jinja-braces.tmLanguage rename to syntaxes/home-assistant/jinja-braces.tmLanguage diff --git a/syntaxes/home-assistant/generated/jinja-conditionals.tmLanguage b/syntaxes/home-assistant/jinja-conditionals.tmLanguage similarity index 100% rename from syntaxes/home-assistant/generated/jinja-conditionals.tmLanguage rename to syntaxes/home-assistant/jinja-conditionals.tmLanguage diff --git a/syntaxes/home-assistant/generated/jinja-double-quote-escape.tmLanguage b/syntaxes/home-assistant/jinja-double-quote-escape.tmLanguage similarity index 100% rename from syntaxes/home-assistant/generated/jinja-double-quote-escape.tmLanguage rename to syntaxes/home-assistant/jinja-double-quote-escape.tmLanguage diff --git a/syntaxes/home-assistant/generated/jinja-extras.tmLanguage b/syntaxes/home-assistant/jinja-extras.tmLanguage similarity index 100% rename from syntaxes/home-assistant/generated/jinja-extras.tmLanguage rename to syntaxes/home-assistant/jinja-extras.tmLanguage diff --git a/syntaxes/home-assistant/generated/jinja-keywords.tmLanguage b/syntaxes/home-assistant/jinja-keywords.tmLanguage similarity index 100% rename from syntaxes/home-assistant/generated/jinja-keywords.tmLanguage rename to syntaxes/home-assistant/jinja-keywords.tmLanguage diff --git a/syntaxes/home-assistant/generated/jinja-single-quote-escape.tmLanguage b/syntaxes/home-assistant/jinja-single-quote-escape.tmLanguage similarity index 100% rename from syntaxes/home-assistant/generated/jinja-single-quote-escape.tmLanguage rename to syntaxes/home-assistant/jinja-single-quote-escape.tmLanguage From f46dd5172cc47684ed6dfb49b26e6a7db98ba069 Mon Sep 17 00:00:00 2001 From: Kuba Wolanin Date: Sun, 16 Jan 2022 11:07:59 +0100 Subject: [PATCH 09/16] Support Home Assistant specific Jinja keywords (#1852) --- package.json | 5 +++-- syntaxes/home-assistant/jinja-double-quote-escape.tmLanguage | 2 +- syntaxes/home-assistant/jinja-extras.tmLanguage | 2 +- syntaxes/home-assistant/jinja-keywords.tmLanguage | 4 ++-- syntaxes/home-assistant/jinja-single-quote-escape.tmLanguage | 2 +- 5 files changed, 8 insertions(+), 7 deletions(-) diff --git a/package.json b/package.json index fdabd450bf..6e68e6efa9 100644 --- a/package.json +++ b/package.json @@ -123,7 +123,7 @@ "path": "./syntaxes/home-assistant/jinja-keywords.tmLanguage", "scopeName": "injection.homeassistant.jinja-keywords", "injectTo": [ - "source.home-assistant-jinja" + "source.home-assistant" ] }, { @@ -169,7 +169,8 @@ "path": "./syntaxes/home-assistant/jinja-conditionals.tmLanguage", "scopeName": "injection.homeassistant.jinja-conditionals", "embeddedLanguages": { - "meta.embedded.inline.jinja": "home-assistant-jinja" + "meta.embedded.inline.jinja": "home-assistant-jinja", + "meta.embedded.block.jinja": "home-assistant-jinja" }, "injectTo": [ "source.home-assistant" diff --git a/syntaxes/home-assistant/jinja-double-quote-escape.tmLanguage b/syntaxes/home-assistant/jinja-double-quote-escape.tmLanguage index 7372668c7b..980f148c6a 100644 --- a/syntaxes/home-assistant/jinja-double-quote-escape.tmLanguage +++ b/syntaxes/home-assistant/jinja-double-quote-escape.tmLanguage @@ -5,7 +5,7 @@ scopeName injection.homeassistant.jinja-double-quote-escape injectionSelector - L:string.quoted.double meta.embedded.inline.jinja + L:string.quoted.double meta.embedded.inline.jinja, L:string.quoted.double meta.embedded.block.jinja name Injection grammar for supproting double quote escapes in Jinja2 expressions patterns diff --git a/syntaxes/home-assistant/jinja-extras.tmLanguage b/syntaxes/home-assistant/jinja-extras.tmLanguage index 1a4ecb5f34..e658964397 100644 --- a/syntaxes/home-assistant/jinja-extras.tmLanguage +++ b/syntaxes/home-assistant/jinja-extras.tmLanguage @@ -5,7 +5,7 @@ scopeName injection.homeassistant.jinja-extras injectionSelector - L:meta.embedded.inline.jinja -string.quoted.double.jinja -string.quoted.single.jinja + L:meta.embedded.inline.jinja -string.quoted.double.jinja -string.quoted.single.jinja, L:meta.embedded.block.jinja -string.quoted.double.jinja -string.quoted.single.jinja name Grammar for Jinja2 syntax highlighting that is not provided out-of-the-box patterns diff --git a/syntaxes/home-assistant/jinja-keywords.tmLanguage b/syntaxes/home-assistant/jinja-keywords.tmLanguage index 1fa01e12c0..83dc849d92 100644 --- a/syntaxes/home-assistant/jinja-keywords.tmLanguage +++ b/syntaxes/home-assistant/jinja-keywords.tmLanguage @@ -5,7 +5,7 @@ scopeName injection.homeassistant.jinja-keywords injectionSelector - L:variable.other.jinja + L:meta.embedded.inline.jinja -string.quoted.double.jinja -string.quoted.single.jinja, L:meta.embedded.block.jinja -string.quoted.double.jinja -string.quoted.single.jinja name Grammar for detecting Home Assistant keywords comment @@ -25,7 +25,7 @@ keyword name - keyword.other.ninja + constant.other.ninja match (?x) \b( diff --git a/syntaxes/home-assistant/jinja-single-quote-escape.tmLanguage b/syntaxes/home-assistant/jinja-single-quote-escape.tmLanguage index 5a341c314f..b1ce799ab1 100644 --- a/syntaxes/home-assistant/jinja-single-quote-escape.tmLanguage +++ b/syntaxes/home-assistant/jinja-single-quote-escape.tmLanguage @@ -5,7 +5,7 @@ scopeName injection.homeassistant.jinja-single-quote-escape injectionSelector - L:string.quoted.single meta.embedded.inline.jinja + L:string.quoted.single meta.embedded.inline.jinja, L:string.quoted.single meta.embedded.block.jinja name Injection grammar for supproting single quote escapes in Jinja2 expressions patterns From a38ad633eeeea58ef887db331e715420992d2c51 Mon Sep 17 00:00:00 2001 From: Franck Nijhof Date: Sun, 16 Jan 2022 11:19:03 +0100 Subject: [PATCH 10/16] Change Jinja keywords regex layout to make it sortable/maintainable (#1854) --- .../home-assistant/jinja-keywords.tmLanguage | 78 ++++++++++++++++--- 1 file changed, 69 insertions(+), 9 deletions(-) diff --git a/syntaxes/home-assistant/jinja-keywords.tmLanguage b/syntaxes/home-assistant/jinja-keywords.tmLanguage index 83dc849d92..a71a8991a4 100644 --- a/syntaxes/home-assistant/jinja-keywords.tmLanguage +++ b/syntaxes/home-assistant/jinja-keywords.tmLanguage @@ -29,15 +29,75 @@ match (?x) \b( - acos | area_devices | area_entities | area_id | area_name | as_datetime | as_local | as_timestamp - | asin | atan | atan2 | average | base64_decode | base64_encode | bitwise_and | bitwise_or - | closest | cos | device_attr | device_entities | device_id | distance | expand | float - | from_json | int | integration_entities | is_defined | is_device_attr | is_number | is_state - | is_state_attr | log | match | max | min | multiply | now | ord | ordinal | pack | pi | random - | regex_findall | regex_findall_index | regex_match | regex_replace | regex_search | relative_time - | round | search | sin | sqrt | state_attr | states | strptime | tan | tau | timedelta - | timestamp_custom | timestamp_local | timestamp_utc | to_json | today_at | unpack | urlencode - | utcnow | value | value_json + acos + | area_devices + | area_entities + | area_id + | area_name + | as_datetime + | as_local + | as_timestamp + | asin + | atan + | atan2 + | average + | base64_decode + | base64_encode + | bitwise_and + | bitwise_or + | closest + | cos + | device_attr + | device_entities + | device_id + | distance + | expand + | float + | from_json + | int + | integration_entities + | is_defined + | is_device_attr + | is_number + | is_state + | is_state_attr + | log + | match + | max + | min + | multiply + | now + | ord + | ordinal + | pack + | pi + | random + | regex_findall + | regex_findall_index + | regex_match + | regex_replace + | regex_search + | relative_time + | round + | search + | sin + | sqrt + | state_attr + | states + | strptime + | tan + | tau + | timedelta + | timestamp_custom + | timestamp_local + | timestamp_utc + | to_json + | today_at + | unpack + | urlencode + | utcnow + | value + | value_json )\b From 3deff473c148c81627451f7b1a4943cf8d76ab23 Mon Sep 17 00:00:00 2001 From: Franck Nijhof Date: Sun, 16 Jan 2022 11:31:53 +0100 Subject: [PATCH 11/16] Add period option for statistics graph (#1855) --- .../src/schemas/lovelace/cards/statistics_graph.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/language-service/src/schemas/lovelace/cards/statistics_graph.ts b/src/language-service/src/schemas/lovelace/cards/statistics_graph.ts index d49b79ef77..e768540dc7 100644 --- a/src/language-service/src/schemas/lovelace/cards/statistics_graph.ts +++ b/src/language-service/src/schemas/lovelace/cards/statistics_graph.ts @@ -39,6 +39,12 @@ export interface Schema { */ days_to_show?: PositiveInteger; + /** + * The period of the rendered graph. + * https://www.home-assistant.io/lovelace/statistics-graph/#period + */ + period?: "5minute" | "hour" | "day" | "month"; + /** * The stat types to render. min, max, mean, sum. * https://www.home-assistant.io/lovelace/statistics-graph/#state_types From 2db4d62102e296d8b597a5a7320289a1f8962967 Mon Sep 17 00:00:00 2001 From: Franck Nijhof Date: Sun, 16 Jan 2022 11:49:23 +0100 Subject: [PATCH 12/16] Cleanup Hue integration YAML syntax (#1857) --- .../src/schemas/configuration.ts | 8 ----- .../src/schemas/integrations/core/hue.ts | 36 ------------------- .../src/schemas/integrations/core/index.d.ts | 1 - 3 files changed, 45 deletions(-) delete mode 100644 src/language-service/src/schemas/integrations/core/hue.ts diff --git a/src/language-service/src/schemas/configuration.ts b/src/language-service/src/schemas/configuration.ts index c3cbc0767e..5e8dee7112 100644 --- a/src/language-service/src/schemas/configuration.ts +++ b/src/language-service/src/schemas/configuration.ts @@ -233,14 +233,6 @@ export interface CoreIntegrations { */ cloud?: integrations.Core.Cloud.Schema | IncludeNamed | null; - /** - * DEPRECATED as of Home Assistant 0.113.0 - * - * The Philips Hue integration allows you to control and monitor the lights and motion sensors connected to your Hue bridge. - * https://www.home-assistant.io/integrations/hue - */ - hue?: integrations.Core.Hue.Schema | IncludeNamed; - /** * The KNX integration for Home Assistant allows you to connect to KNX/IP devices. * https://www.home-assistant.io/integrations/knx diff --git a/src/language-service/src/schemas/integrations/core/hue.ts b/src/language-service/src/schemas/integrations/core/hue.ts deleted file mode 100644 index dfd871afcc..0000000000 --- a/src/language-service/src/schemas/integrations/core/hue.ts +++ /dev/null @@ -1,36 +0,0 @@ -/** - * Hue integration - * Source: https://github.com/home-assistant/core/blob/dev/homeassistant/components/hue/__init__.py - */ -import { IncludeList, Deprecated } from "../../types"; - -export type Domain = "hue"; -export interface Schema { - bridges: Item[] | IncludeList; -} - -interface Item { - /** - * DEPRECATED as of Home Assistant 0.113.0 - * - * The Philips Hue integration allows you to control and monitor the lights and motion sensors connected to your Hue bridge. - * https://www.home-assistant.io/integrations/hue - */ - allow_hue_groups?: Deprecated; - - /** - * DEPRECATED as of Home Assistant 0.113.0 - * - * The Philips Hue integration allows you to control and monitor the lights and motion sensors connected to your Hue bridge. - * https://www.home-assistant.io/integrations/hue - */ - allow_unreachable?: Deprecated; - - /** - * DEPRECATED as of Home Assistant 0.113.0 - * - * The Philips Hue integration allows you to control and monitor the lights and motion sensors connected to your Hue bridge. - * https://www.home-assistant.io/integrations/hue - */ - host: Deprecated; -} diff --git a/src/language-service/src/schemas/integrations/core/index.d.ts b/src/language-service/src/schemas/integrations/core/index.d.ts index 520341340e..c8b97c41b9 100644 --- a/src/language-service/src/schemas/integrations/core/index.d.ts +++ b/src/language-service/src/schemas/integrations/core/index.d.ts @@ -12,7 +12,6 @@ export * as Fan from "./fan"; export * as Group from "./group"; export * as HomeAssistant from "./homeassistant"; export * as HTTP from "./http"; -export * as Hue from "./hue"; export * as InputBoolean from "./input_boolean"; export * as InputButton from "./input_button"; export * as InputDatetime from "./input_datetime"; From 166c601927bc8ef990c4aa3a3e966e3c17f64ae5 Mon Sep 17 00:00:00 2001 From: Franck Nijhof Date: Sun, 16 Jan 2022 11:59:43 +0100 Subject: [PATCH 13/16] Fix MQTT fan requires deprecated option (#1858) --- src/language-service/src/schemas/integrations/core/mqtt.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/language-service/src/schemas/integrations/core/mqtt.ts b/src/language-service/src/schemas/integrations/core/mqtt.ts index a508406533..12682e21fd 100644 --- a/src/language-service/src/schemas/integrations/core/mqtt.ts +++ b/src/language-service/src/schemas/integrations/core/mqtt.ts @@ -1803,7 +1803,7 @@ export interface FanPlatformSchema extends PlatformSchema { * List of speeds this fan is capable of running at. Valid entries are off, low, medium and high. * https://www.home-assistant.io/integrations/fan.mqtt/#speeds */ - speeds: Deprecated; + speeds?: Deprecated; /** * The MQTT topic subscribed to receive state updates. From a1a8461eca3e0dddb8d3263d3d325abb19671b26 Mon Sep 17 00:00:00 2001 From: Franck Nijhof Date: Sun, 16 Jan 2022 12:00:19 +0100 Subject: [PATCH 14/16] Add built-in Jinja2 keywords (#1856) --- .../home-assistant/jinja-keywords.tmLanguage | 47 ++++++++++++++++++- 1 file changed, 46 insertions(+), 1 deletion(-) diff --git a/syntaxes/home-assistant/jinja-keywords.tmLanguage b/syntaxes/home-assistant/jinja-keywords.tmLanguage index a71a8991a4..8aea6a5a78 100644 --- a/syntaxes/home-assistant/jinja-keywords.tmLanguage +++ b/syntaxes/home-assistant/jinja-keywords.tmLanguage @@ -12,6 +12,7 @@ Extracted from: https://github.com/home-assistant/core/blob/dev/homeassistant/helpers/template.py + https://jinja.palletsprojects.com/en/3.0.x/templates/#list-of-builtin-filters patterns @@ -29,7 +30,8 @@ match (?x) \b( - acos + abs + | acos | area_devices | area_entities | area_id @@ -40,20 +42,34 @@ | asin | atan | atan2 + | attr | average | base64_decode | base64_encode + | batch | bitwise_and | bitwise_or + | capitalize + | center | closest | cos + | default | device_attr | device_entities | device_id + | dictsort | distance + | escape | expand + | filesizeformat + | first | float + | forceescape + | format | from_json + | groupby + | iif + | indent | int | integration_entities | is_defined @@ -61,7 +77,13 @@ | is_number | is_state | is_state_attr + | join + | last + | length + | list | log + | lower + | map | match | max | min @@ -71,33 +93,56 @@ | ordinal | pack | pi + | pprint | random | regex_findall | regex_findall_index | regex_match | regex_replace | regex_search + | reject + | rejectattr | relative_time + | replace + | reverse | round + | safe | search + | select + | selectattr | sin + | slice + | sort | sqrt | state_attr | states + | string + | striptags | strptime + | sum | tan | tau | timedelta | timestamp_custom | timestamp_local | timestamp_utc + | title | to_json | today_at + | tojson + | trim + | truncate + | unique | unpack + | upper | urlencode + | urlize | utcnow | value | value_json + | wordcount + | wordwrap + | xmlattr )\b From fcf18f60fb614e63cd8122214b7dbfdb5695977e Mon Sep 17 00:00:00 2001 From: Franck Nijhof Date: Sun, 16 Jan 2022 13:36:07 +0100 Subject: [PATCH 15/16] Add support for modern template entities syntax (#1859) --- .../src/schemas/configuration.ts | 6 + .../src/schemas/integrations/core/index.d.ts | 1 + .../src/schemas/integrations/core/template.ts | 259 ++++++++++++++++-- .../src/schemas/mappings.json | 7 + 4 files changed, 257 insertions(+), 16 deletions(-) diff --git a/src/language-service/src/schemas/configuration.ts b/src/language-service/src/schemas/configuration.ts index 5e8dee7112..12d1192927 100644 --- a/src/language-service/src/schemas/configuration.ts +++ b/src/language-service/src/schemas/configuration.ts @@ -203,6 +203,12 @@ export interface InternalIntegrations { */ switch?: integrations.Core.Switch.Schema | IncludeList; + /** + * The template integration allows creating entities which derive their values from other data. + * https://www.home-assistant.io/integrations/template + */ + template?: integrations.Core.Template.Schema | IncludeList; + /** * The updater binary sensor will check daily for new releases. * https://www.home-assistant.io/integrations/updater diff --git a/src/language-service/src/schemas/integrations/core/index.d.ts b/src/language-service/src/schemas/integrations/core/index.d.ts index c8b97c41b9..359a2985cb 100644 --- a/src/language-service/src/schemas/integrations/core/index.d.ts +++ b/src/language-service/src/schemas/integrations/core/index.d.ts @@ -33,6 +33,7 @@ export * as Select from "./select"; export * as Sensor from "./sensor"; export * as Spotify from "./spotify"; export * as Switch from "./switch"; +export * as Template from "./template"; export * as Updater from "./updater"; export * as Vacuum from "./vacuum"; export * as Weather from "./weather"; diff --git a/src/language-service/src/schemas/integrations/core/template.ts b/src/language-service/src/schemas/integrations/core/template.ts index 84704690e5..f158c4f6d9 100644 --- a/src/language-service/src/schemas/integrations/core/template.ts +++ b/src/language-service/src/schemas/integrations/core/template.ts @@ -16,8 +16,235 @@ import { } from "../../types"; import { Action } from "../actions"; import { PlatformSchema } from "../platform"; +import { Trigger } from "../triggers"; export type Domain = "template"; +export type Schema = Item[] | IncludeList; +export type File = Item | Item[]; + +export interface Item { + /** + * List of binary sensors + * https://www.home-assistant.io/integrations/template#binary_sensor + */ + binary_sensor?: BinarySensorItem[] | IncludeList; + + /** + * List of buttons + * https://www.home-assistant.io/integrations/template#button + */ + button?: ButtonItem[] | IncludeList; + + /** + * List of numbers + * https://www.home-assistant.io/integrations/template#number + */ + number?: NumberItem[] | IncludeList; + + /** + * List of selects + * https://www.home-assistant.io/integrations/template#select + */ + select?: SelectItem[] | IncludeList; + + /** + * List of sensors + * https://www.home-assistant.io/integrations/template#sensor + */ + sensor?: SensorItem[] | IncludeList; + + /** + * Define an automation trigger to update the entities. Optional. If omitted will update based on referenced entities. See trigger documentation. + * https://www.home-assistant.io/integrations/template#trigger + */ + trigger?: Trigger | Trigger[] | IncludeList; + + /** + * The unique ID for this config block. This will be prefixed to all unique IDs of all entities in this block. + * https://www.home-assistant.io/integrations/template#unique_id + */ + unique_id?: string; +} + +interface BaseItem { + /** + * Defines a template to get the available state of the entity. If the template either fails to render or returns True, "1", "true", "yes", "on", "enable", or a non-zero number, the entity will be available. + * https://www.home-assistant.io/integrations/template#availability + */ + availability?: Template; + + /** + * Defines a template for the icon of the entity. + * https://www.home-assistant.io/integrations/template#icon + */ + icon?: Template; + + /** + * Defines a template to get the name of the entity. + * https://www.home-assistant.io/integrations/template#name + */ + name?: Template; + + /** + * An ID that uniquely identifies this entity. Will be combined with the unique ID of the configuration block if available. This allows changing the name, icon and entity_id from the web interface. + * https://www.home-assistant.io/integrations/template#unique_id + */ + unique_id?: string; +} + +interface BinarySensorItem extends BaseItem { + /** + * Defines a template to get the available state of the entity. If the template either fails to render or returns True, "1", "true", "yes", "on", "enable", or a non-zero number, the entity will be available. + * https://www.home-assistant.io/integrations/template#availability + */ + attributes?: { [key: string]: Template }; + + /** + * **Requires a trigger**. After how much time the entity should turn off after it rendered ‘on’. + * https://www.home-assistant.io/integrations/template#auto_off + */ + auto_off?: TimePeriod | Template; + + /** + * The amount of time (ie 0:00:05) the template state must be not met before this sensor will switch to on. This can also be a template. + * https://www.home-assistant.io/integrations/template#delay_off + */ + delay_off?: TimePeriod | Template; + + /** + * The amount of time (ie 0:00:05) the template state must be met before this sensor will switch to on. This can also be a template. + * https://www.home-assistant.io/integrations/template#delay_on + */ + delay_on?: TimePeriod | Template; + + /** + * Sets the class of the device, changing the device state and icon that is displayed on the UI (see below). It does not set the unit_of_measurement. + * https://www.home-assistant.io/integrations/template#device_class + */ + device_class?: DeviceClassesBinarySensor; + + /** + * Defines a template for the entity picture of the sensor. + * https://www.home-assistant.io/integrations/template#picture + */ + picture?: Template; + + /** + * The sensor is on if the template evaluates as True, yes, on, enable or a positive number. Any other value will render it as off. The actual appearance in the frontend (Open/Closed, Detected/Clear etc) depends on the sensor’s device_class value + * https://www.home-assistant.io/integrations/template#state + */ + state?: Template; +} + +interface ButtonItem extends BaseItem { + /** + * Defines actions to run to press the button. + * https://www.home-assistant.io/integrations/template#button + */ + press?: Action | Action[]; +} + +interface NumberItem extends BaseItem { + /** + * Template for the number’s maximum value. + * https://www.home-assistant.io/integrations/template#max + */ + max?: Template; + + /** + * Template for the number’s minimum value. + * https://www.home-assistant.io/integrations/template#min + */ + min?: Template; + + /** + * Flag that defines if number works in optimistic mode. + * https://www.home-assistant.io/integrations/template#optimistic + */ + optimistic?: boolean; + + /** + * Defines actions to run when the number value changes. The variable `value` will contain the number entered. + * https://www.home-assistant.io/integrations/template#set_value + */ + set_value: Action | Action[]; + + /** + * Defines a template to get the state of the sensor. + * https://www.home-assistant.io/integrations/template#state + */ + state: Template; + + /** + * Template for the number’s increment/decrement step. + * https://www.home-assistant.io/integrations/template#step + */ + step: Template; +} + +interface SelectItem extends BaseItem { + /** + * Flag that defines if select works in optimistic mode. + * https://www.home-assistant.io/integrations/template#options + */ + optimistic?: boolean; + + /** + * Template for the select’s available options. + * https://www.home-assistant.io/integrations/template#options + */ + options: Template; + + /** + * Defines actions to run to select an option from the options list. The variable `option` will contain the option selected. + * https://www.home-assistant.io/integrations/template#select_option + */ + select_option: Action | Action[]; + + /** + * Template for the select’s current value. + * https://www.home-assistant.io/integrations/template#state + */ + state: Template; +} + +interface SensorItem extends BaseItem { + /** + * Defines a template to get the available state of the entity. If the template either fails to render or returns True, "1", "true", "yes", "on", "enable", or a non-zero number, the entity will be available. + * https://www.home-assistant.io/integrations/template#availability + */ + attributes?: { [key: string]: Template }; + + /** + * Sets the class of the device, changing the device state and icon that is displayed on the UI (see below). It does not set the unit_of_measurement. + * https://www.home-assistant.io/integrations/template#device_class + */ + device_class?: DeviceClassesSensor; + + /** + * Defines a template for the entity picture of the sensor. + * https://www.home-assistant.io/integrations/template#picture + */ + picture?: Template; + + /** + * The state_class of the sensor. This will also display the value based on the user profile Number Format setting and influence the graphical presentation in the history visualization as a continuous value. + * https://www.home-assistant.io/integrations/template#state_class + */ + state_class?: StateClassesSensor; + + /** + * Defines a template to get the state of the sensor. + * https://www.home-assistant.io/integrations/template#state + */ + state: Template; + + /** + * Defines the units of measurement of the sensor, if any. This will also display the value based on the user profile Number Format setting and influence the graphical presentation in the history visualization as a continuous value. + * https://www.home-assistant.io/integrations/template#state + */ + unit_of_measurement?: string; +} export interface AlarmControlPanelPlatformSchema extends PlatformSchema { /** @@ -31,7 +258,7 @@ export interface AlarmControlPanelPlatformSchema extends PlatformSchema { * https://www.home-assistant.io/integrations/alarm_control_panel.template/#panels */ panels: { - [key: string]: AlarmControlPanelItem | IncludeNamed; + [key: string]: AlarmControlPanelPlatformItem | IncludeNamed; }; } @@ -47,7 +274,7 @@ export interface BinarySensorPlatformSchema extends PlatformSchema { * https://www.home-assistant.io/integrations/binary_sensor.template#sensors */ sensors: { - [key: string]: BinarySensorItem | IncludeNamed; + [key: string]: BinarySensorPlatformItem | IncludeNamed; }; } @@ -63,7 +290,7 @@ export interface CoverPlatformSchema extends PlatformSchema { * https://www.home-assistant.io/integrations/cover.template/#covers */ covers: { - [key: string]: CoverItem | IncludeNamed; + [key: string]: CoverPlatformItem | IncludeNamed; }; } @@ -79,7 +306,7 @@ export interface FanPlatformSchema extends PlatformSchema { * https://www.home-assistant.io/integrations/fan.template/#fans */ fans: { - [key: string]: FanItem | IncludeNamed; + [key: string]: FanPlatformItem | IncludeNamed; }; } @@ -95,7 +322,7 @@ export interface LightPlatformSchema extends PlatformSchema { * https://www.home-assistant.io/integrations/fan.template/#lights */ lights: { - [key: string]: LightItem | IncludeNamed; + [key: string]: LightPlatformItem | IncludeNamed; }; } @@ -161,7 +388,7 @@ export interface SensorPlatformSchema extends PlatformSchema { * https://www.home-assistant.io/integrations/template#sensors */ sensors: { - [key: string]: SensorItem | IncludeNamed; + [key: string]: SensorPlatformItem | IncludeNamed; }; } @@ -177,7 +404,7 @@ export interface SwitchPlatformSchema extends PlatformSchema { * https://www.home-assistant.io/integrations/switch.template#switches */ switches: { - [key: string]: SwitchItem | IncludeNamed; + [key: string]: SwitchPlatformItem | IncludeNamed; }; } @@ -193,7 +420,7 @@ export interface VacuumPlatformSchema extends PlatformSchema { * https://www.home-assistant.io/integrations/vacuum.template#vacuums */ vacuums: { - [key: string]: VacuumItem | IncludeNamed; + [key: string]: VacuumPlatformItem | IncludeNamed; }; } @@ -277,7 +504,7 @@ export interface WeatherPlatformSchema extends PlatformSchema { wind_speed_template?: Template; } -interface AlarmControlPanelItem { +interface AlarmControlPanelPlatformItem { /** * Defines an action to run when the alarm is armed to away mode. * https://www.home-assistant.io/integrations/alarm_control_panel.template/#arm_away @@ -333,7 +560,7 @@ interface AlarmControlPanelItem { value_template?: Template; } -interface BinarySensorItem { +interface BinarySensorPlatformItem { /** * Defines templates for attributes of the sensor. * https://www.home-assistant.io/integrations/binary_sensor.template#attribute_templates @@ -400,7 +627,7 @@ interface BinarySensorItem { value_template: Template; } -interface CoverItem { +interface CoverPlatformItem { /** * Defines a template to get the available state of the component. If the template returns true, the device is available. If the template returns any other value, the device will be unavailable. * https://www.home-assistant.io/integrations/cover.template/#availability_template @@ -498,7 +725,7 @@ interface CoverItem { value_template?: Template; } -interface FanItem { +interface FanPlatformItem { /** * Defines a template to get the available state of the component. If the template returns true, the device is available. * https://www.home-assistant.io/integrations/fan.template/#availability_template @@ -611,7 +838,7 @@ interface FanItem { value_template: Template; } -interface LightItem { +interface LightPlatformItem { /** * Defines a template to get the available state of the component. If the template returns true, the device is available. * https://www.home-assistant.io/integrations/light.template#availability_template @@ -745,7 +972,7 @@ interface LightItem { white_value_template?: Template; } -interface SensorItem { +interface SensorPlatformItem { /** * Defines templates for attributes of the sensor. * https://www.home-assistant.io/integrations/template#attribute_templates @@ -818,7 +1045,7 @@ interface SensorItem { value_template: Template; } -interface SwitchItem { +interface SwitchPlatformItem { /** * Defines a template to get the available state of the component. If the template returns true, the device is available. * https://www.home-assistant.io/integrations/switch.template#availability_template @@ -868,7 +1095,7 @@ interface SwitchItem { value_template?: Template; } -interface VacuumItem { +interface VacuumPlatformItem { /** * Defines templates for attributes of the sensor. * https://www.home-assistant.io/integrations/vacuum.template#attribute_templates diff --git a/src/language-service/src/schemas/mappings.json b/src/language-service/src/schemas/mappings.json index ee35536695..d3ade75e60 100644 --- a/src/language-service/src/schemas/mappings.json +++ b/src/language-service/src/schemas/mappings.json @@ -90,6 +90,13 @@ "tsFile": "integrations/core/sensor.ts", "fromType": "File" }, + { + "key": "integration-template", + "path": "configuration.yaml/template", + "file": "integration-template.json", + "tsFile": "integrations/core/template.ts", + "fromType": "File" + }, { "key": "integration-alarm_control_panel", "path": "configuration.yaml/alarm_control_panel", From 83e4e9b7e9c480b33f4fa3be88541ecd8de91572 Mon Sep 17 00:00:00 2001 From: Franck Nijhof Date: Sun, 16 Jan 2022 13:39:10 +0100 Subject: [PATCH 16/16] Bump version to v1.24.0 --- package-lock.json | 2 +- package.json | 2 +- src/language-service/package-lock.json | 2 +- src/language-service/package.json | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/package-lock.json b/package-lock.json index 89a5f4810d..93a1387c01 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "vscode-home-assistant", - "version": "1.23.0", + "version": "1.24.0", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 6e68e6efa9..afbc96e18e 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "vscode-home-assistant", "displayName": "Home Assistant Config Helper", "description": " Completion for entity-id's in Home Assistant Configurations", - "version": "1.23.0", + "version": "1.24.0", "preview": false, "engines": { "vscode": "^1.45.1" diff --git a/src/language-service/package-lock.json b/src/language-service/package-lock.json index 296d885787..ac38567054 100644 --- a/src/language-service/package-lock.json +++ b/src/language-service/package-lock.json @@ -1,6 +1,6 @@ { "name": "home-assistant-language-service", - "version": "1.23.0", + "version": "1.24.0", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/src/language-service/package.json b/src/language-service/package.json index dacfebbe8a..b7f0738206 100644 --- a/src/language-service/package.json +++ b/src/language-service/package.json @@ -1,6 +1,6 @@ { "name": "home-assistant-language-service", - "version": "1.23.0", + "version": "1.24.0", "description": "Home Assistant Language Service", "source": "src/haLanguageService.ts", "main": "dist/haLanguageService.js",