Skip to content

Commit a631fc4

Browse files
Copilottsnobip
andcommitted
Format JavaScript files with Prettier
Co-authored-by: tsnobip <[email protected]>
1 parent 87c0785 commit a631fc4

File tree

2 files changed

+39
-15
lines changed

2 files changed

+39
-15
lines changed

plugins/cm6-reason-mode.js

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { StreamLanguage } from "@codemirror/language";
66
const reasonLanguage = StreamLanguage.define({
77
name: "reason",
88
startState: () => ({ tokenize: null, context: [] }),
9-
9+
1010
token(stream, state) {
1111
// Handle whitespace
1212
if (stream.eatSpace()) return null;
@@ -28,7 +28,11 @@ const reasonLanguage = StreamLanguage.define({
2828
}
2929

3030
// Handle character literals
31-
if (stream.match(/'(?:[^'\\]|\\(?:[nrt0'"]|x[\da-fA-F]{2}|u\{[\da-fA-F]{6}\}))'/)) {
31+
if (
32+
stream.match(
33+
/'(?:[^'\\]|\\(?:[nrt0'"]|x[\da-fA-F]{2}|u\{[\da-fA-F]{6}\}))'/,
34+
)
35+
) {
3236
return "string-2";
3337
}
3438

@@ -38,7 +42,11 @@ const reasonLanguage = StreamLanguage.define({
3842
}
3943

4044
// Handle numbers
41-
if (stream.match(/^(?:(?:[0-9][0-9_]*)(?:(?:[Ee][+-]?[0-9_]+)|\.[0-9_]+(?:[Ee][+-]?[0-9_]+)?)(?:f32|f64)?)|(?:0(?:b[01_]+|(?:o[0-7_]+)|(?:x[0-9a-fA-F_]+))|(?:[0-9][0-9_]*))(?:u8|u16|u32|u64|i8|i16|i32|i64|isize|usize)?/)) {
45+
if (
46+
stream.match(
47+
/^(?:(?:[0-9][0-9_]*)(?:(?:[Ee][+-]?[0-9_]+)|\.[0-9_]+(?:[Ee][+-]?[0-9_]+)?)(?:f32|f64)?)|(?:0(?:b[01_]+|(?:o[0-7_]+)|(?:x[0-9a-fA-F_]+))|(?:[0-9][0-9_]*))(?:u8|u16|u32|u64|i8|i16|i32|i64|isize|usize)?/,
48+
)
49+
) {
4250
return "number";
4351
}
4452

@@ -49,7 +57,11 @@ const reasonLanguage = StreamLanguage.define({
4957
}
5058

5159
// Handle keywords
52-
if (stream.match(/^(?:switch|module|as|do|else|external|for|if|in|loop|mod|pub|ref|type|while|open|open\!)\b/)) {
60+
if (
61+
stream.match(
62+
/^(?:switch|module|as|do|else|external|for|if|in|loop|mod|pub|ref|type|while|open|open\!)\b/,
63+
)
64+
) {
5365
return "keyword";
5466
}
5567

@@ -98,7 +110,7 @@ const reasonLanguage = StreamLanguage.define({
98110
stream.next();
99111
return null;
100112
},
101-
113+
102114
tokenTable: {
103115
comment: "comment",
104116
string: "string",
@@ -110,8 +122,8 @@ const reasonLanguage = StreamLanguage.define({
110122
namespace: "namespace",
111123
typeName: "typeName",
112124
operator: "operator",
113-
variableName: "variableName"
114-
}
125+
variableName: "variableName",
126+
},
115127
});
116128

117129
function tokenString(stream, state) {

plugins/cm6-rescript-mode.js

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { StreamLanguage } from "@codemirror/language";
66
const rescriptLanguage = StreamLanguage.define({
77
name: "rescript",
88
startState: () => ({ tokenize: null, context: [] }),
9-
9+
1010
token(stream, state) {
1111
// Handle whitespace
1212
if (stream.eatSpace()) return null;
@@ -26,15 +26,19 @@ const rescriptLanguage = StreamLanguage.define({
2626
state.tokenize = tokenString;
2727
return state.tokenize(stream, state);
2828
}
29-
29+
3030
// Handle template/interpolation strings
3131
if (stream.match(/^b?`/)) {
3232
state.tokenize = tokenTemplateString;
3333
return state.tokenize(stream, state);
3434
}
3535

3636
// Handle character literals
37-
if (stream.match(/'(?:[^'\\]|\\(?:[nrt0'"]|x[\da-fA-F]{2}|u\{[\da-fA-F]{6}\}))'/)) {
37+
if (
38+
stream.match(
39+
/'(?:[^'\\]|\\(?:[nrt0'"]|x[\da-fA-F]{2}|u\{[\da-fA-F]{6}\}))'/,
40+
)
41+
) {
3842
return "string-2";
3943
}
4044

@@ -44,7 +48,11 @@ const rescriptLanguage = StreamLanguage.define({
4448
}
4549

4650
// Handle numbers
47-
if (stream.match(/^(?:(?:[0-9][0-9_]*)(?:(?:[Ee][+-]?[0-9_]+)|\.[0-9_]+(?:[Ee][+-]?[0-9_]+)?)(?:f32|f64)?)|(?:0(?:b[01_]+|(?:o[0-7_]+)|(?:x[0-9a-fA-F_]+))|(?:[0-9][0-9_]*))(?:u8|u16|u32|u64|i8|i16|i32|i64|isize|usize)?/)) {
51+
if (
52+
stream.match(
53+
/^(?:(?:[0-9][0-9_]*)(?:(?:[Ee][+-]?[0-9_]+)|\.[0-9_]+(?:[Ee][+-]?[0-9_]+)?)(?:f32|f64)?)|(?:0(?:b[01_]+|(?:o[0-7_]+)|(?:x[0-9a-fA-F_]+))|(?:[0-9][0-9_]*))(?:u8|u16|u32|u64|i8|i16|i32|i64|isize|usize)?/,
54+
)
55+
) {
4856
return "number";
4957
}
5058

@@ -55,7 +63,11 @@ const rescriptLanguage = StreamLanguage.define({
5563
}
5664

5765
// Handle keywords
58-
if (stream.match(/^(?:and|as|assert|catch|async|await|constraint|downto|else|exception|export|external|false|for|if|import|in|include|lazy|let|module|mutable|of|open|private|switch|to|true|try|type|when|while|with\!)\b/)) {
66+
if (
67+
stream.match(
68+
/^(?:and|as|assert|catch|async|await|constraint|downto|else|exception|export|external|false|for|if|import|in|include|lazy|let|module|mutable|of|open|private|switch|to|true|try|type|when|while|with\!)\b/,
69+
)
70+
) {
5971
return "keyword";
6072
}
6173

@@ -108,7 +120,7 @@ const rescriptLanguage = StreamLanguage.define({
108120
stream.next();
109121
return null;
110122
},
111-
123+
112124
tokenTable: {
113125
comment: "comment",
114126
string: "string",
@@ -121,8 +133,8 @@ const rescriptLanguage = StreamLanguage.define({
121133
typeName: "typeName",
122134
meta: "meta",
123135
operator: "operator",
124-
variableName: "variableName"
125-
}
136+
variableName: "variableName",
137+
},
126138
});
127139

128140
function tokenString(stream, state) {

0 commit comments

Comments
 (0)