Add function call JS syntax highlighting
MODIFY
packages/@romejs/cli-diagnostics/highlightCode.ts
packages/@romejs/cli-diagnostics/highlightCode.ts
@@ -163,7 +163,7 @@ function highlightJS(input: string, sourceType: ConstSourceType): string {
return reduce(
input,
tokens,
- (token, value, prev) => {
+ (token, value, prev, next) => {
const {type} = token;
let tokenType: MarkupTokenType;
@@ -255,7 +255,15 @@ function highlightJS(input: string, sourceType: ConstSourceType): string {
}
case "name": {
- tokenType = value === "from" ? "keyword" : "variable";
+ tokenType = "variable";
+
+ if (value === "from") {
+ tokenType = "keyword";
+ }
+
+ if (next !== undefined && next.type.label === "(") {
+ tokenType = "function";
+ }
break;
}

MODIFY
packages/@romejs/string-markup/grid/ansi.ts
packages/@romejs/string-markup/grid/ansi.ts
@@ -96,6 +96,7 @@ const tokenTypeToScope: Dict<MarkupTokenType> = {
"string.regexp": "regex",
"string": "string",
"comment": "comment",
+ "entity.name.function": "function",
//"": "operator",
//"": "punctuation",
"variable": "variable",

MODIFY
packages/@romejs/string-markup/grid/tagFormatters.ts
packages/@romejs/string-markup/grid/tagFormatters.ts
@@ -27,6 +27,7 @@ export function normalizeTokenType(
case "punctuation":
case "variable":
case "attr-name":
+ case "function":
return type;
default:

MODIFY
packages/@romejs/string-markup/types.ts
packages/@romejs/string-markup/types.ts
@@ -107,7 +107,8 @@ export type MarkupTokenType =
| "operator"
| "punctuation"
| "variable"
- | "attr-name";
+ | "attr-name"
+ | "function";
export type MarkupColor =
| "black"

Add function call JS syntax highlighting (#668)