Skip to content

Commit

Permalink
Fix syntax highlighting for strings and dictionary literals.
Browse files Browse the repository at this point in the history
  • Loading branch information
moetelo committed Oct 22, 2023
1 parent a8d936f commit 1bc968e
Show file tree
Hide file tree
Showing 2 changed files with 83 additions and 2 deletions.
40 changes: 38 additions & 2 deletions packages/vscode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,49 @@
"configuration": "./languages/twig.configuration.json"
}
],
"semanticTokenTypes": [
{
"id": "embedded_begin",
"superType": "embedded_delimiter",
"description": "Begin of embedded"
},
{
"id": "embedded_end",
"superType": "embedded_delimiter",
"description": "End of embedded"
},
{
"id": "null",
"superType": "constant",
"description": "null or none"
},
{
"id": "boolean",
"superType": "constant",
"description": "true or false"
}
],
"configurationDefaults": {
"editor.semanticTokenColorCustomizations": {
"enabled": true,
"rules": {
"embedded_delimiter": {
"foreground": "#777777"
}
}
}
},
"grammars": [
{
"language": "twig",
"scopeName": "text.html.twig",
"path": "./syntaxes/twig.tmLanguage.json",
"path": "./syntaxes/html.tmLanguage.json",
"embeddedLanguages": {
"text.html.derivative": "html"
"text.html": "html",
"source.twig": "twig",
"source.js": "javascript",
"source.json": "json",
"source.css": "css"
}
}
]
Expand Down
45 changes: 45 additions & 0 deletions packages/vscode/syntaxes/html.tmLanguage.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{
"name": "twig",
"scopeName": "text.html.twig",
"injections": {
"text.html.twig - (meta.embedded | meta.tag), L:((text.html.twig meta.tag) - meta.embedded.block.twig), L:(source.js - meta.embedded.block.twig), L:(source.css - meta.embedded.block.twig)": {
"patterns": [
{
"include": "#twig-tag"
}
]
}
},
"patterns": [
{
"include": "text.html.derivative"
}
],
"repository": {
"twig-tag": {
"patterns": [
{
"begin": "\\{(\\{|\\%|\\#)",
"beginCaptures": {
"0": {
"name": "punctuation.section.embedded.begin.twig"
}
},
"end": "(\\}|\\%|\\#)\\}",
"endCaptures": {
"0": {
"name": "punctuation.section.embedded.end.twig"
}
},
"name": "meta.embedded.block.twig",
"contentName": "source.twig",
"patterns": [
{
"include": "source.twig"
}
]
}
]
}
}
}

0 comments on commit 1bc968e

Please sign in to comment.