mirror of
https://github.com/stan220/godot-docs.git
synced 2026-09-08 16:28:59 +00:00
Use different color for control flow keywords in GDScript syntax highlighting
This matches the Godot script editor's behavior. Note that this does not apply to C# and shaders (which currently use GLSL highlighting), as it would require copying their respective highlighters to this repository and modifying them.
This commit is contained in:
+23
-10
@@ -85,6 +85,7 @@ class GDScriptLexer(RegexLexer):
|
||||
Operator,
|
||||
),
|
||||
include("keywords"),
|
||||
include("control_flow_keywords"),
|
||||
(r"(func)((?:\s|\\\s)+)", bygroups(Keyword, Text), "funcname"),
|
||||
(r"(class)((?:\s|\\\s)+)", bygroups(Keyword, Text), "classname"),
|
||||
include("builtins"),
|
||||
@@ -155,16 +156,6 @@ class GDScriptLexer(RegexLexer):
|
||||
"enum",
|
||||
"static",
|
||||
"var",
|
||||
"break",
|
||||
"continue",
|
||||
"if",
|
||||
"elif",
|
||||
"else",
|
||||
"for",
|
||||
"pass",
|
||||
"return",
|
||||
"match",
|
||||
"while",
|
||||
"super",
|
||||
),
|
||||
suffix=r"\b",
|
||||
@@ -172,6 +163,28 @@ class GDScriptLexer(RegexLexer):
|
||||
Keyword,
|
||||
),
|
||||
],
|
||||
"control_flow_keywords": [
|
||||
(
|
||||
words(
|
||||
(
|
||||
"break",
|
||||
"continue",
|
||||
"elif",
|
||||
"else",
|
||||
"if",
|
||||
"for",
|
||||
"match",
|
||||
"pass",
|
||||
"return",
|
||||
"while",
|
||||
),
|
||||
suffix=r"\b",
|
||||
),
|
||||
# Custom control flow class used to give control flow keywords a different color,
|
||||
# like in the Godot editor.
|
||||
Keyword.ControlFlow,
|
||||
),
|
||||
],
|
||||
"builtins": [
|
||||
(
|
||||
words(
|
||||
|
||||
Reference in New Issue
Block a user