Skip to content

Commit

Permalink
Improvements for new version
Browse files Browse the repository at this point in the history
* Make ytt its own language so users of other yaml extensions can choose ytt in
  language selector and still use this extension.
* Wire in configuration for autoclosing, comment toggling, autosurrounding,
  if/for/def + end highlighting
* Stop highlighting annotations as starlark
* Add support for (if|for|def)/end
* Change coloring so def and yaml keys do not collide
* Match end coloring to def, if and for

Signed-off-by: John Ryan <[email protected]>
  • Loading branch information
ewrenn8 authored and pivotaljohn committed Aug 19, 2020
1 parent beaa2a1 commit 4d3be9b
Show file tree
Hide file tree
Showing 5 changed files with 106 additions and 22 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Binary file modified images/syntax-highlighting.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
83 changes: 66 additions & 17 deletions language-configuration.json
Original file line number Diff line number Diff line change
@@ -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": [
["{", "}"],
["[", "]"],
["(", ")"],
["\"", "\""],
["'", "'"]
[
"{",
"}"
],
[
"[",
"]"
],
[
"(",
")"
],
[
"\"",
"\""
],
[
"'",
"'"
]
]
}
}
17 changes: 15 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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"
}
Expand Down
25 changes: 23 additions & 2 deletions syntaxes/ytt.tmLanguage.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
Expand All @@ -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"
Expand Down

0 comments on commit 4d3be9b

Please sign in to comment.