Skip to content

Commit f5a42f7

Browse files
angelozerrmickaelistria
authored andcommitted
OnEnterRules support for js, ts files
Signed-off-by: azerr <[email protected]>
1 parent d195840 commit f5a42f7

File tree

4 files changed

+184
-46
lines changed

4 files changed

+184
-46
lines changed

org.eclipse.wildwebdeveloper/language-configurations/javascript/javascript-language-configuration.json

Lines changed: 0 additions & 44 deletions
This file was deleted.
Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
/**
2+
* Copyright (c) 2015-2017 Angelo ZERR.
3+
* All rights reserved. This program and the accompanying materials
4+
* are made available under the terms of the Eclipse Public License v1.0
5+
* which accompanies this distribution, and is available at
6+
* http://www.eclipse.org/legal/epl-v10.html
7+
*
8+
* Initial code from https://github.com/Microsoft/vscode/
9+
* Initial copyright Copyright (C) Microsoft Corporation. All rights reserved.
10+
* Initial license: MIT
11+
*
12+
* Contributors:
13+
* - Microsoft Corporation: Initial code licensed under MIT license
14+
*
15+
* @see https://github.com/Microsoft/vscode/blob/master/extensions/javascript/javascript-language-configuration.json
16+
*/
17+
{
18+
"comments": {
19+
"lineComment": "//",
20+
"blockComment": [ "/*", "*/" ]
21+
},
22+
"brackets": [
23+
["{", "}"],
24+
["[", "]"],
25+
["(", ")"]
26+
],
27+
"autoClosingPairs": [
28+
{ "open": "{", "close": "}" },
29+
{ "open": "[", "close": "]" },
30+
{ "open": "(", "close": ")" },
31+
{ "open": "'", "close": "'", "notIn": ["string", "comment"] },
32+
{ "open": "\"", "close": "\"", "notIn": ["string"] },
33+
{ "open": "`", "close": "`", "notIn": ["string", "comment"] },
34+
{ "open": "/**", "close": " */", "notIn": ["string"] }
35+
],
36+
"surroundingPairs": [
37+
["{", "}"],
38+
["[", "]"],
39+
["(", ")"],
40+
["'", "'"],
41+
["\"", "\""],
42+
["`", "`"]
43+
],
44+
"onEnterRules": [
45+
{
46+
// e.g. /** | */
47+
"beforeText": {
48+
"pattern": "^\\s*/\\*\\*(?!/)([^\\*]|\\*(?!/))*$"
49+
},
50+
"afterText": {
51+
"pattern": "^\\s*\\*/$"
52+
},
53+
"action": {
54+
"indent": "indentOutdent",
55+
"appendText": " * "
56+
}
57+
},
58+
{
59+
// e.g. /** ...|
60+
"beforeText": {
61+
"pattern": "^\\s*/\\*\\*(?!/)([^\\*]|\\*(?!/))*$"
62+
},
63+
"action": {
64+
"indent": "none",
65+
"appendText": " * "
66+
}
67+
},
68+
{
69+
// e.g. * ...|
70+
"beforeText": {
71+
"pattern": "^(\\t|[ ])*[ ]\\*([ ]([^\\*]|\\*(?!/))*)?$"
72+
},
73+
"previousLineText": {
74+
"pattern": "(?=^(\\s*(/\\*\\*|\\*)).*)(?=(?!(\\s*\\*/)))"
75+
},
76+
"action": {
77+
"indent": "none",
78+
"appendText": "* "
79+
}
80+
},
81+
{
82+
// e.g. */|
83+
"beforeText": {
84+
"pattern": "^(\\t|[ ])*[ ]\\*/\\s*$"
85+
},
86+
"action": {
87+
"indent": "none",
88+
"removeText": 1
89+
}
90+
},
91+
{
92+
// e.g. *-----*/|
93+
"beforeText": {
94+
"pattern": "^(\\t|[ ])*[ ]\\*[^/]*\\*/\\s*$"
95+
},
96+
"action": {
97+
"indent": "none",
98+
"removeText": 1
99+
}
100+
},
101+
{
102+
"beforeText": {
103+
"pattern": "^\\s*(\\bcase\\s.+:|\\bdefault:)$"
104+
},
105+
"afterText": {
106+
"pattern": "^(?!\\s*(\\bcase\\b|\\bdefault\\b))"
107+
},
108+
"action": {
109+
"indent": "indent"
110+
}
111+
}
112+
]
113+
}

org.eclipse.wildwebdeveloper/language-configurations/typescript/language-configuration.json renamed to org.eclipse.wildwebdeveloper/language-configurations/typescript/language-configuration.jsonc

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,5 +40,74 @@
4040
["'", "'"],
4141
["\"", "\""],
4242
["`", "`"]
43+
],
44+
"onEnterRules": [
45+
{
46+
// e.g. /** | */
47+
"beforeText": {
48+
"pattern": "^\\s*/\\*\\*(?!/)([^\\*]|\\*(?!/))*$"
49+
},
50+
"afterText": {
51+
"pattern": "^\\s*\\*/$"
52+
},
53+
"action": {
54+
"indent": "indentOutdent",
55+
"appendText": " * "
56+
}
57+
},
58+
{
59+
// e.g. /** ...|
60+
"beforeText": {
61+
"pattern": "^\\s*/\\*\\*(?!/)([^\\*]|\\*(?!/))*$"
62+
},
63+
"action": {
64+
"indent": "none",
65+
"appendText": " * "
66+
}
67+
},
68+
{
69+
// e.g. * ...|
70+
"beforeText": {
71+
"pattern": "^(\\t|[ ])*[ ]\\*([ ]([^\\*]|\\*(?!/))*)?$"
72+
},
73+
"previousLineText": {
74+
"pattern": "(?=^(\\s*(/\\*\\*|\\*)).*)(?=(?!(\\s*\\*/)))"
75+
},
76+
"action": {
77+
"indent": "none",
78+
"appendText": "* "
79+
}
80+
},
81+
{
82+
// e.g. */|
83+
"beforeText": {
84+
"pattern": "^(\\t|[ ])*[ ]\\*/\\s*$"
85+
},
86+
"action": {
87+
"indent": "none",
88+
"removeText": 1
89+
}
90+
},
91+
{
92+
// e.g. *-----*/|
93+
"beforeText": {
94+
"pattern": "^(\\t|[ ])*[ ]\\*[^/]*\\*/\\s*$"
95+
},
96+
"action": {
97+
"indent": "none",
98+
"removeText": 1
99+
}
100+
},
101+
{
102+
"beforeText": {
103+
"pattern": "^\\s*(\\bcase\\s.+:|\\bdefault:)$"
104+
},
105+
"afterText": {
106+
"pattern": "^(?!\\s*(\\bcase\\b|\\bdefault\\b))"
107+
},
108+
"action": {
109+
"indent": "indent"
110+
}
111+
}
43112
]
44113
}

org.eclipse.wildwebdeveloper/plugin.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -427,11 +427,11 @@
427427
point="org.eclipse.tm4e.languageconfiguration.languageConfigurations">
428428
<languageConfiguration
429429
contentTypeId="org.eclipse.wildwebdeveloper.js"
430-
path="language-configurations/javascript/javascript-language-configuration.json">
430+
path="language-configurations/javascript/javascript-language-configuration.jsonc">
431431
</languageConfiguration>
432432
<languageConfiguration
433433
contentTypeId="org.eclipse.wildwebdeveloper.ts"
434-
path="language-configurations/typescript/language-configuration.json">
434+
path="language-configurations/typescript/language-configuration.jsonc">
435435
</languageConfiguration>
436436
<!-- TODO replace with more specific language configuration if we include some -->
437437
<languageConfiguration

0 commit comments

Comments
 (0)