Skip to content

Commit 26a2739

Browse files
committed
feat(vscode): derive the Vue TextMate grammars with Monogram
Replace the hand-written Vue syntax grammars with ones derived by Monogram from a single proven Vue/HTML grammar. The main SFC grammar and the two injections (directives + interpolations) are now generated output. The injections keep the same scopeNames (vue.directives / vue.interpolations), selectors, and injectTo set, and remain thin stubs that include text.html.vue#vue-directives / #vue-interpolations (the rule bodies live in the main grammar's repository) — the same topology as before. The <template> body now embeds text.html.derivative (the embedded-HTML-fragment scope VS Code's HTML extension provides), which is what the interpolation injection targets. Notable behaviour change: an `as` type assertion in a directive value (#5012 / #6007 / #2096 / #520) no longer eats the closing quote — the derived grammar bounds the value with a capture-embed, so `:msg="msg as string"` recovers correctly after the cast instead of leaking TypeScript across the rest of the tag. Grammar snapshot regenerated (extensions/vscode/tests/grammar.spec.ts).
1 parent 5d4e9fa commit 26a2739

4 files changed

Lines changed: 2856 additions & 1718 deletions

File tree

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
{
22
"$schema": "https://raw.githubusercontent.com/martinring/tmlanguage/master/tmlanguage.json",
3-
"fileTypes": [],
4-
"injectionSelector": "L:meta.tag -meta.attribute -meta.ng-binding -entity.name.tag.pug -attribute_value -source.tsx -source.js.jsx, L:meta.element -meta.attribute",
3+
"scopeName": "vue.directives",
4+
"injectionSelector": "L:meta.tag -meta.attribute -meta.ng-binding -entity.name.tag.pug -attribute_value -source.tsx -source.js.jsx -source.ts.embedded.html.vue, L:meta.element -meta.attribute -source.ts.embedded.html.vue",
55
"patterns": [
66
{
77
"include": "text.html.vue#vue-directives"
88
}
9-
],
10-
"scopeName": "vue.directives"
11-
}
9+
]
10+
}
Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
{
22
"$schema": "https://raw.githubusercontent.com/martinring/tmlanguage/master/tmlanguage.json",
3-
"fileTypes": [],
4-
"injectionSelector": "L:text.pug -comment -string.comment, L:text.html.derivative -comment.block, L:text.html.markdown -comment.block",
3+
"scopeName": "vue.interpolations",
4+
"injectionSelector": "L:text.html.derivative -comment.block -source.ts.embedded.html.vue, L:text.html.markdown -comment.block -source.ts.embedded.html.vue, L:text.pug -comment -string.comment -source.ts.embedded.html.vue",
55
"patterns": [
66
{
77
"include": "text.html.vue#vue-interpolations"
88
}
9-
],
10-
"scopeName": "vue.interpolations"
11-
}
9+
]
10+
}

0 commit comments

Comments
 (0)