Skip to content

Commit 6bccc03

Browse files
committed
feat: update language pack grammars
1 parent 149c73e commit 6bccc03

28 files changed

+4328
-2562
lines changed

org.eclipse.tm4e.core/src/main/java/org/eclipse/tm4e/core/internal/grammar/raw/RawCaptures.java

+3
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ public Iterable<String> getCaptureIds() {
4242
public void forEachCapture(final BiConsumer<String, IRawRule> action) {
4343
forEach((final String captureId, final Object rule) -> {
4444
try {
45+
// to handle e.g. https://github.com/microsoft/vscode/blob/f4edc9af6c1d8e3018ca13a4e0d7de350f8f1368/extensions/yaml/syntaxes/yaml-1.1.tmLanguage.json#L139-L159
46+
if ("comment".equals(captureId) && rule instanceof String)
47+
return;
4548
action.accept(captureId, (IRawRule) rule);
4649
} catch (final ClassCastException ex) {
4750
// log ClassCastException with some context, to better troubleshoot issues like https://github.com/eclipse-tm4e/tm4e/issues/754

org.eclipse.tm4e.language_pack/README.md

+60-60
Large diffs are not rendered by default.

org.eclipse.tm4e.language_pack/about.html

+62-62
Large diffs are not rendered by default.

org.eclipse.tm4e.language_pack/plugin.xml

+2-2
Original file line numberDiff line numberDiff line change
@@ -652,7 +652,7 @@
652652
<!-- ======================================== -->
653653
<extension point="org.eclipse.core.contenttype.contentTypes">
654654
<content-type id="org.eclipse.tm4e.language_pack.jsonc" name="JSON with Comments" base-type="org.eclipse.tm4e.language_pack.basetype" priority="low"
655-
file-extensions="babelrc,eslintrc,hintrc,jsfmtrc,jshintrc,jsonc,swcrc" file-names=".babelrc.json,.ember-cli,babel.config.json,typedoc.json" file-patterns="*.eslintrc.json" />
655+
file-extensions="babelrc,eslintrc,hintrc,jsfmtrc,jshintrc,jsonc,swcrc" file-names=".babelrc.json,.ember-cli,babel.config.json,bun.lock,typedoc.json" file-patterns="*.eslintrc.json" />
656656
</extension>
657657
<extension point="org.eclipse.tm4e.registry.grammars">
658658
<grammar scopeName="source.json.comments" path="syntaxes/json/jsonc.tmLanguage.json" />
@@ -672,7 +672,7 @@
672672
<!-- ======================================== -->
673673
<extension point="org.eclipse.core.contenttype.contentTypes">
674674
<content-type id="org.eclipse.tm4e.language_pack.jsonl" name="JSON Lines" base-type="org.eclipse.tm4e.language_pack.basetype" priority="low"
675-
file-extensions="jsonl" />
675+
file-extensions="jsonl,ndjson" />
676676
</extension>
677677
<extension point="org.eclipse.tm4e.registry.grammars">
678678
<grammar scopeName="source.json.lines" path="syntaxes/json/jsonl.tmLanguage.json" />
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,94 @@
11
{
22
"comments": {
33
"lineComment": "//",
4-
"blockComment": ["/*", "*/"]
4+
"blockComment": [
5+
"/*",
6+
"*/"
7+
]
58
},
69
"brackets": [
7-
["{", "}"],
8-
["[", "]"],
9-
["(", ")"]
10+
[
11+
"{",
12+
"}"
13+
],
14+
[
15+
"[",
16+
"]"
17+
],
18+
[
19+
"(",
20+
")"
21+
]
1022
],
1123
"autoClosingPairs": [
12-
{ "open": "[", "close": "]" },
13-
{ "open": "{", "close": "}" },
14-
{ "open": "(", "close": ")" },
15-
{ "open": "'", "close": "'", "notIn": ["string", "comment"] },
16-
{ "open": "\"", "close": "\"", "notIn": ["string"] },
17-
{ "open": "/*", "close": "*/", "notIn": ["string", "comment"] },
18-
{ "open": "/**", "close": " */", "notIn": ["string"] }
24+
{
25+
"open": "[",
26+
"close": "]"
27+
},
28+
{
29+
"open": "{",
30+
"close": "}"
31+
},
32+
{
33+
"open": "(",
34+
"close": ")"
35+
},
36+
{
37+
"open": "'",
38+
"close": "'",
39+
"notIn": [
40+
"string",
41+
"comment"
42+
]
43+
},
44+
{
45+
"open": "\"",
46+
"close": "\"",
47+
"notIn": [
48+
"string"
49+
]
50+
},
51+
{
52+
"open": "/*",
53+
"close": "*/",
54+
"notIn": [
55+
"string",
56+
"comment"
57+
]
58+
},
59+
{
60+
"open": "/**",
61+
"close": " */",
62+
"notIn": [
63+
"string"
64+
]
65+
}
1966
],
2067
"surroundingPairs": [
21-
["{", "}"],
22-
["[", "]"],
23-
["(", ")"],
24-
["\"", "\""],
25-
["'", "'"],
26-
["<", ">"]
68+
[
69+
"{",
70+
"}"
71+
],
72+
[
73+
"[",
74+
"]"
75+
],
76+
[
77+
"(",
78+
")"
79+
],
80+
[
81+
"\"",
82+
"\""
83+
],
84+
[
85+
"'",
86+
"'"
87+
],
88+
[
89+
"<",
90+
">"
91+
]
2792
],
2893
"wordPattern": "(-?\\d*\\.\\d\\w*)|([^\\`\\~\\!\\@\\#\\%\\^\\&\\*\\(\\)\\-\\=\\+\\[\\{\\]\\}\\\\\\|\\;\\:\\'\\\"\\,\\.\\<\\>\\/\\?\\s]+)",
2994
"folding": {
@@ -32,6 +97,14 @@
3297
"end": "^\\s*#pragma\\s+endregion\\b"
3398
}
3499
},
100+
"indentationRules": {
101+
"decreaseIndentPattern": {
102+
"pattern": "^\\s*[\\}\\]\\)].*$"
103+
},
104+
"increaseIndentPattern": {
105+
"pattern": "^.*(\\{[^}]*|\\([^)]*|\\[[^\\]]*)$"
106+
},
107+
},
35108
"onEnterRules": [
36109
{
37110
// Decrease indentation after single line if/else if/else, for, or while
@@ -41,6 +114,19 @@
41114
"action": {
42115
"indent": "outdent"
43116
}
44-
}
117+
},
118+
// Add // when pressing enter from inside line comment
119+
{
120+
"beforeText": {
121+
"pattern": "\/\/.*"
122+
},
123+
"afterText": {
124+
"pattern": "^(?!\\s*$).+"
125+
},
126+
"action": {
127+
"indent": "none",
128+
"appendText": "// "
129+
}
130+
},
45131
]
46132
}
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,94 @@
11
{
22
"comments": {
33
"lineComment": "//",
4-
"blockComment": ["/*", "*/"]
4+
"blockComment": [
5+
"/*",
6+
"*/"
7+
]
58
},
69
"brackets": [
7-
["{", "}"],
8-
["[", "]"],
9-
["(", ")"]
10+
[
11+
"{",
12+
"}"
13+
],
14+
[
15+
"[",
16+
"]"
17+
],
18+
[
19+
"(",
20+
")"
21+
]
1022
],
1123
"autoClosingPairs": [
12-
{ "open": "[", "close": "]" },
13-
{ "open": "{", "close": "}" },
14-
{ "open": "(", "close": ")" },
15-
{ "open": "'", "close": "'", "notIn": ["string", "comment"] },
16-
{ "open": "\"", "close": "\"", "notIn": ["string"] },
17-
{ "open": "/*", "close": "*/", "notIn": ["string", "comment"] },
18-
{ "open": "/**", "close": " */", "notIn": ["string"] }
24+
{
25+
"open": "[",
26+
"close": "]"
27+
},
28+
{
29+
"open": "{",
30+
"close": "}"
31+
},
32+
{
33+
"open": "(",
34+
"close": ")"
35+
},
36+
{
37+
"open": "'",
38+
"close": "'",
39+
"notIn": [
40+
"string",
41+
"comment"
42+
]
43+
},
44+
{
45+
"open": "\"",
46+
"close": "\"",
47+
"notIn": [
48+
"string"
49+
]
50+
},
51+
{
52+
"open": "/*",
53+
"close": "*/",
54+
"notIn": [
55+
"string",
56+
"comment"
57+
]
58+
},
59+
{
60+
"open": "/**",
61+
"close": " */",
62+
"notIn": [
63+
"string"
64+
]
65+
}
1966
],
2067
"surroundingPairs": [
21-
["{", "}"],
22-
["[", "]"],
23-
["(", ")"],
24-
["\"", "\""],
25-
["'", "'"],
26-
["<", ">"]
68+
[
69+
"{",
70+
"}"
71+
],
72+
[
73+
"[",
74+
"]"
75+
],
76+
[
77+
"(",
78+
")"
79+
],
80+
[
81+
"\"",
82+
"\""
83+
],
84+
[
85+
"'",
86+
"'"
87+
],
88+
[
89+
"<",
90+
">"
91+
]
2792
],
2893
"wordPattern": "(-?\\d*\\.\\d\\w*)|([^\\`\\~\\!\\@\\#\\%\\^\\&\\*\\(\\)\\-\\=\\+\\[\\{\\]\\}\\\\\\|\\;\\:\\'\\\"\\,\\.\\<\\>\\/\\?\\s]+)",
2994
"folding": {
@@ -32,6 +97,14 @@
3297
"end": "^\\s*#pragma\\s+endregion\\b"
3398
}
3499
},
100+
"indentationRules": {
101+
"decreaseIndentPattern": {
102+
"pattern": "^\\s*[\\}\\]\\)].*$"
103+
},
104+
"increaseIndentPattern": {
105+
"pattern": "^.*(\\{[^}]*|\\([^)]*|\\[[^\\]]*)$"
106+
},
107+
},
35108
"onEnterRules": [
36109
{
37110
// Decrease indentation after single line if/else if/else, for, or while
@@ -41,6 +114,19 @@
41114
"action": {
42115
"indent": "outdent"
43116
}
44-
}
117+
},
118+
// Add // when pressing enter from inside line comment
119+
{
120+
"beforeText": {
121+
"pattern": "\/\/.*"
122+
},
123+
"afterText": {
124+
"pattern": "^(?!\\s*$).+"
125+
},
126+
"action": {
127+
"indent": "none",
128+
"appendText": "// "
129+
}
130+
},
45131
]
46132
}

0 commit comments

Comments
 (0)