Skip to content

Commit 14a5214

Browse files
authored
support format g4 (#232)
* chore: install antlr-format-cli to format g4 files * style: format all g4 files * chore: apply antlr-format to lint-staged
1 parent 17eba1f commit 14a5214

20 files changed

+16945
-13872
lines changed

.lintstagedrc.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
module.exports = {
22
'*.js': [`prettier --write`],
33
'*.ts': [`prettier --write`],
4+
'*.g4': [`antlr-format -c ./antlr.format.json -v`],
45
};

antlr.format.json

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
{
2+
"main": {
3+
"alignTrailingComments": true,
4+
"columnLimit": 150,
5+
"minEmptyLines": 1,
6+
"maxEmptyLinesToKeep": 1,
7+
"reflowComments": false,
8+
"useTab": false,
9+
"allowShortRulesOnASingleLine": false,
10+
"allowShortBlocksOnASingleLine": true,
11+
"alignSemicolons": "hanging",
12+
"alignColons": "hanging",
13+
"spaceBeforeAssignmentOperators": false,
14+
"keepEmptyLinesAtTheStartOfBlocks": true
15+
},
16+
"lexer": {
17+
"alignTrailingComments": true,
18+
"columnLimit": 150,
19+
"maxEmptyLinesToKeep": 1,
20+
"reflowComments": false,
21+
"useTab": false,
22+
"allowShortRulesOnASingleLine": true,
23+
"allowShortBlocksOnASingleLine": true,
24+
"minEmptyLines": 0,
25+
"alignSemicolons": "none",
26+
"alignColons": "trailing",
27+
"singleLineOverrulesHangingColon": true,
28+
"alignLexerCommands": true,
29+
"alignLabels": true,
30+
"alignTrailers": true,
31+
"spaceBeforeAssignmentOperators": false,
32+
"groupedAlignments": true
33+
}
34+
}

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
"release": "node ./scripts/release.js",
2929
"lint": "prettier --check '**/*.ts' --config ./.prettierrc",
3030
"lint-fix": "prettier --write '**/*.ts' --config ./.prettierrc",
31+
"format-g4": "antlr-format -c ./antlr.format.json -v ./src/grammar/**/*.g4",
3132
"cleanComment": "node ./scripts/cleanCommentCli.js"
3233
},
3334
"license": "MIT",
@@ -39,6 +40,7 @@
3940
"@swc/jest": "^0.2.26",
4041
"@types/jest": "^29.5.1",
4142
"@types/node": "^18.15.11",
43+
"antlr-format-cli": "^1.2.1",
4244
"antlr4ts-cli": "^0.5.0-alpha.4",
4345
"chalk": "4.1.2",
4446
"commitizen": "^4.3.0",

pnpm-lock.yaml

Lines changed: 128 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)