Skip to content

Commit

Permalink
chore: Add build step to build grammars from source
Browse files Browse the repository at this point in the history
Add build step to build grammars from source
  • Loading branch information
lifeart authored Dec 22, 2023
2 parents 94b9692 + 84c04d7 commit 052377c
Show file tree
Hide file tree
Showing 16 changed files with 1,884 additions and 20 deletions.
10 changes: 10 additions & 0 deletions .github/workflows/workflow.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,16 @@ jobs:
- name: install dependencies
run: yarn install --frozen-lockfile

- name: build grammars
run: yarn build:grammars

- name: add and commit grammars
uses: EndBug/add-and-commit@v9
with:
add: 'syntaxes'
default_author: github_actions
message: 'chore: build grammar json files for ${{ steps.gitversion.outputs.majorMinorPatch }}'

- name: update metadata in package.json
uses: onlyutkarsh/patch-files-action@v1.0.1
with:
Expand Down
13 changes: 7 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@
"web:package": "webpack --mode production",
"prettier": "prettier --write \"**/*.{js,ts,json,yaml}\"",
"prettier:package": "prettier --write \"package.json\"",
"chrome": "vscode-test-web --browserType=chromium --extensionDevelopmentPath=."
"chrome": "vscode-test-web --browserType=chromium --extensionDevelopmentPath=.",
"build:grammars": "node ./syntaxes/src/index.mjs"
},
"extensionKind": [
"ui"
Expand Down Expand Up @@ -99,7 +100,7 @@
"grammars": [
{
"language": "glimmer-js",
"path": "./syntaxes/glimmer-js.json",
"path": "./syntaxes/source.gjs.json",
"scopeName": "source.gjs",
"embeddedLanguages": {
"source.gjs": "javascript"
Expand All @@ -115,7 +116,7 @@
},
{
"language": "glimmer-ts",
"path": "./syntaxes/glimmer-ts.json",
"path": "./syntaxes/source.gts.json",
"scopeName": "source.gts",
"embeddedLanguages": {
"source.gts": "typescript"
Expand All @@ -133,15 +134,15 @@
"label": "Handlebars (Ember)",
"language": "handlebars",
"scopeName": "text.html.ember-handlebars",
"path": "./syntaxes/handlebars.tmLanguage.json"
"path": "./syntaxes/text.html.ember-handlebars.json"
},
{
"injectTo": [
"source.js",
"source.ts"
],
"scopeName": "inline.hbs",
"path": "./syntaxes/inline-hbs.json",
"path": "./syntaxes/inline.hbs.json",
"embeddedLanguages": {
"meta.embedded.block.html": "handlebars"
}
Expand All @@ -152,7 +153,7 @@
"source.gjs"
],
"scopeName": "inline.template",
"path": "./syntaxes/inline-template.json",
"path": "./syntaxes/inline.template.json",
"embeddedLanguages": {
"meta.embedded.block.html": "handlebars",
"meta.js.embeddedTemplateWithoutArgs": "handlebars",
Expand Down
3 changes: 3 additions & 0 deletions syntaxes/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Warning!

This directory contains the compiled grammars. If you need to make modifications please edit the files found in `syntaxes/src/` and then run `yarn run build:grammars` to compile them.
4 changes: 0 additions & 4 deletions syntaxes/glimmer-js.json

This file was deleted.

4 changes: 0 additions & 4 deletions syntaxes/glimmer-ts.json

This file was deleted.

7 changes: 5 additions & 2 deletions syntaxes/inline-hbs.json → syntaxes/inline.hbs.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
{
"fileTypes": ["js", "ts"],
"fileTypes": [
"js",
"ts"
],
"injectionSelector": "L:source.js -comment -(string -meta.embedded), L:source.ts -comment -(string -meta.embedded)",
"injections": {
"L:source": {
Expand Down Expand Up @@ -146,4 +149,4 @@
}
],
"scopeName": "inline.hbs"
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
{
"fileTypes": ["gjs", "gts"],
"fileTypes": [
"gjs",
"gts"
],
"injectionSelector": "L:source.gjs -comment -(string -meta.embedded), L:source.gts -comment -(string -meta.embedded)",
"patterns": [
{
Expand Down Expand Up @@ -86,4 +89,4 @@
}
],
"scopeName": "inline.template"
}
}
230 changes: 230 additions & 0 deletions syntaxes/source.gjs.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,230 @@
{
"$schema": "https://raw.githubusercontent.com/martinring/tmlanguage/master/tmlanguage.json",
"name": "Glimmer JS",
"scopeName": "source.gjs",
"patterns": [
{
"include": "source.js"
}
],
"injections": {
"L:source.gjs -comment -(string -meta.embedded)": {
"patterns": [
{
"name": "meta.js.embeddedTemplateWithoutArgs",
"begin": "\\s*(<)(template)\\s*(>)",
"beginCaptures": {
"1": {
"name": "punctuation.definition.tag.html"
},
"2": {
"name": "entity.name.tag.other.html"
},
"3": {
"name": "punctuation.definition.tag.html"
}
},
"end": "(</)(template)(>)",
"endCaptures": {
"1": {
"name": "punctuation.definition.tag.html"
},
"2": {
"name": "entity.name.tag.other.html"
},
"3": {
"name": "punctuation.definition.tag.html"
}
},
"patterns": [
{
"include": "text.html.ember-handlebars"
}
]
},
{
"name": "meta.js.embeddedTemplateWithArgs",
"begin": "(<)(template)",
"beginCaptures": {
"1": {
"name": "punctuation.definition.tag.html"
},
"2": {
"name": "entity.name.tag.other.html"
}
},
"end": "(</)(template)(>)",
"endCaptures": {
"1": {
"name": "punctuation.definition.tag.html"
},
"2": {
"name": "entity.name.tag.other.html"
},
"3": {
"name": "punctuation.definition.tag.html"
}
},
"patterns": [
{
"begin": "(?<=\\<template)",
"end": "(?=\\>)",
"patterns": [
{
"include": "text.html.ember-handlebars#tag-like-content"
}
]
},
{
"begin": "(>)",
"beginCaptures": {
"1": {
"name": "punctuation.definition.tag.end.js"
}
},
"end": "(?=</template>)",
"contentName": "meta.html.embedded.block",
"patterns": [
{
"include": "text.html.ember-handlebars"
}
]
}
]
},
{
"name": "string.js.taggedTemplate",
"contentName": "meta.embedded.block.html",
"begin": "(?x)(\\b(?:\\w+\\.)*(?:hbs|html)\\s*)(`)",
"beginCaptures": {
"1": {
"name": "entity.name.function.tagged-template.js"
},
"2": {
"name": "punctuation.definition.string.template.begin.js"
}
},
"end": "(`)",
"endCaptures": {
"0": {
"name": "string.js"
},
"1": {
"name": "punctuation.definition.string.template.end.js"
}
},
"patterns": [
{
"include": "source.ts#template-substitution-element"
},
{
"include": "text.html.ember-handlebars"
}
]
},
{
"begin": "((createTemplate|hbs|html))(\\()",
"contentName": "meta.embedded.block.html",
"beginCaptures": {
"1": {
"name": "entity.name.function.ts"
},
"2": {
"name": "meta.function-call.ts"
},
"3": {
"name": "meta.brace.round.ts"
}
},
"end": "(\\))",
"endCaptures": {
"1": {
"name": "meta.brace.round.ts"
}
},
"patterns": [
{
"begin": "((`))",
"beginCaptures": {
"1": {
"name": "string.template.ts"
},
"2": {
"name": "punctuation.definition.string.template.begin.ts"
}
},
"end": "((`))",
"endCaptures": {
"1": {
"name": "string.template.ts"
},
"2": {
"name": "punctuation.definition.string.template.end.ts"
}
},
"patterns": [
{
"include": "text.html.ember-handlebars"
}
]
}
]
},
{
"begin": "((precompileTemplate)\\s*)(\\()",
"beginCaptures": {
"1": {
"name": "entity.name.function.ts"
},
"2": {
"name": "meta.function-call.ts"
},
"3": {
"name": "meta.brace.round.ts"
}
},
"end": "(\\))",
"endCaptures": {
"1": {
"name": "meta.brace.round.ts"
}
},
"patterns": [
{
"begin": "((`|'|\"))",
"contentName": "meta.embedded.block.html",
"beginCaptures": {
"1": {
"name": "string.template.ts"
},
"2": {
"name": "punctuation.definition.string.template.begin.ts"
}
},
"end": "((`|'|\"))",
"endCaptures": {
"1": {
"name": "string.template.ts"
},
"2": {
"name": "punctuation.definition.string.template.end.ts"
}
},
"patterns": [
{
"include": "text.html.ember-handlebars"
}
]
},
{
"include": "source.ts#object-literal"
},
{
"include": "source.ts"
}
]
}
]
}
}
}
Loading

0 comments on commit 052377c

Please sign in to comment.