diff --git a/README.md b/README.md index 68f895c..2bec353 100644 --- a/README.md +++ b/README.md @@ -15,4 +15,5 @@ This extensions requires the [starlark language extension](https://github.com/ph ## Known Issues -Theme overlap between starlark and yaml highlighting. +Multi-line function calls result in all following annotations being matched as +starlark comments. diff --git a/images/syntax-highlighting.png b/images/syntax-highlighting.png index 7a87818..b00b5e7 100644 Binary files a/images/syntax-highlighting.png and b/images/syntax-highlighting.png differ diff --git a/language-configuration.json b/language-configuration.json index 8f162a0..6fe158e 100644 --- a/language-configuration.json +++ b/language-configuration.json @@ -1,30 +1,79 @@ { "comments": { // symbol used for single line comment. Remove this entry if your language does not support line comments - "lineComment": "//", - // symbols used for start and end a block comment. Remove this entry if your language does not support block comments - "blockComment": [ "/*", "*/" ] + "lineComment": "#!", }, // symbols used as brackets "brackets": [ - ["{", "}"], - ["[", "]"], - ["(", ")"] + [ + "{", + "}" + ], + [ + "[", + "]" + ], + [ + "(", + ")" + ], + [ + "if", + "end" + ], + [ + "def", + "end" + ], + [ + "for", + "end" + ] ], // symbols that are auto closed when typing "autoClosingPairs": [ - ["{", "}"], - ["[", "]"], - ["(", ")"], - ["\"", "\""], - ["'", "'"] + [ + "{", + "}" + ], + [ + "[", + "]" + ], + [ + "(", + ")" + ], + [ + "\"", + "\"" + ], + [ + "'", + "'" + ] ], // symbols that can be used to surround a selection "surroundingPairs": [ - ["{", "}"], - ["[", "]"], - ["(", ")"], - ["\"", "\""], - ["'", "'"] + [ + "{", + "}" + ], + [ + "[", + "]" + ], + [ + "(", + ")" + ], + [ + "\"", + "\"" + ], + [ + "'", + "'" + ] ] -} \ No newline at end of file +} diff --git a/package.json b/package.json index 22d2be2..f764d94 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "vscode-ytt", "displayName": "vscode-ytt", "description": "Syntax highlighting for ytt", - "version": "0.0.2", + "version": "0.0.3", "publisher": "ewrenn", "repository": { "type": "git", @@ -18,9 +18,22 @@ "Programming Languages" ], "contributes": { + "languages": [ + { + "id": "ytt", + "extensions": [ + ".yaml", + ".yml" + ], + "aliases": [ + "ytt" + ], + "configuration": "./language-configuration.json" + } + ], "grammars": [ { - "language": "yaml", + "language": "ytt", "scopeName": "source.yaml.ytt", "path": "./syntaxes/ytt.tmLanguage.json" } diff --git a/syntaxes/ytt.tmLanguage.json b/syntaxes/ytt.tmLanguage.json index 45bcd61..7bd128c 100644 --- a/syntaxes/ytt.tmLanguage.json +++ b/syntaxes/ytt.tmLanguage.json @@ -41,14 +41,23 @@ "name": "comment.line.number-sign.ytt" }, "ytt-annotation": { - "begin": "#@", + "begin": "#@\\S*", "beginCaptures": { "0": { - "name": "keyword.control.flow.ytt" + "name": "support.class.ytt" } }, "end": "\\n", "patterns": [ + { + "include": "#ytt-combo-end" + }, + { + "include": "#ytt-end" + }, + { + "include": "#ytt-def" + }, { "include": "source.starlark" } @@ -63,6 +72,18 @@ }, "end": "\\n", "name": "comment.line.number-sign" + }, + "ytt-combo-end": { + "match": "(for|if|def)\/end", + "name": "keyword.control.flow.ytt" + }, + "ytt-end": { + "match": "\\s+end$", + "name": "keyword.control.flow.ytt" + }, + "ytt-def": { + "match": "\\s*\\b(def)\\s+(?=[[:alpha:]_][[:word:]]*\\s*\\()", + "name": "keyword.control.flow.ytt" } }, "scopeName": "source.yaml.ytt"