Skip to content

Commit

Permalink
Extend the playground highlighting rules for type hints
Browse files Browse the repository at this point in the history
  • Loading branch information
irh committed May 30, 2024
1 parent b0f8fe3 commit ab73a90
Showing 1 changed file with 56 additions and 3 deletions.
59 changes: 56 additions & 3 deletions website/playground/src/koto-highlight-rules.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ export function register_koto_editor_mode() {
include: "#section"
}, {
include: "#string"
}, {
include: "#let"
}, {
include: "#function"
}, {
include: "#identifier"
}],
Expand Down Expand Up @@ -128,9 +132,6 @@ export function register_koto_editor_mode() {
}, {
token: "punctuation.comma.koto",
regex: /,/
}, {
token: "punctuation.definition.parameters.koto",
regex: /\|/
}, {
token: "punctuation.meta.decorator.koto",
regex: "@(?:" + identifier + ")?"
Expand Down Expand Up @@ -220,6 +221,58 @@ export function register_koto_editor_mode() {
}, {
defaultToken: "variable.parameter.koto"
}]
}],
"#id_with_type": [{
token: [
"variable.other.koto",
"text",
"storage.type.koto"
],
regex: /([[:alpha:]_][[:alnum:]_]*)(?:(:\s*)([[:alpha:]_][[:alnum:]_]*))?/
}],
"#let": [{
token: "keyword.control.koto",
regex: /\blet\b/,
push: [{
token: "keyword.operator.assignment.koto",
regex: /\=/,
next: "pop"
}, {
include: "#id_with_type"
}]
}],
"#function": [{
token: "keyword.other.function-definition.koto",
regex: /\|/,
push: [{
token: "punctuation.definition.arguments.end.koto",
regex: /\|/,
next: "pop"
}, {
include: "#function_arguments"
}, {
include: "#return_type"
}]
}],
"#function_arguments": [{
token: "punctuation.definition.arguments.begin.koto",
regex: /\(/,
push: [{
token: "punctuation.definition.arguments.end.koto",
regex: /\)/,
next: "pop"
}, {
include: "#function_arguments"
}]
}, {
token: "punctuation.separator.parameters.koto",
regex: /,/
}, {
include: "#id_with_type"
}],
"#return_type": [{
token: ["text", "storage.type.koto"],
regex: /(->\s*)([[:alpha:]_][[:alnum:]_]*)/
}]
}

Expand Down

0 comments on commit ab73a90

Please sign in to comment.