diff --git a/_extensions/gdscript.py b/_extensions/gdscript.py index 9ea18aeb886..30091413eed 100644 --- a/_extensions/gdscript.py +++ b/_extensions/gdscript.py @@ -85,6 +85,7 @@ def innerstring_rules(ttype): 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,21 +156,33 @@ def innerstring_rules(ttype): "enum", "static", "var", + "super", + ), + suffix=r"\b", + ), + Keyword, + ), + ], + "control_flow_keywords": [ + ( + words( + ( "break", "continue", - "if", "elif", "else", + "if", "for", + "match", "pass", "return", - "match", "while", - "super", ), suffix=r"\b", ), - Keyword, + # Custom control flow class used to give control flow keywords a different color, + # like in the Godot editor. + Keyword.ControlFlow, ), ], "builtins": [ diff --git a/_static/css/custom.css b/_static/css/custom.css index 815d26eebce..21988bfedb7 100644 --- a/_static/css/custom.css +++ b/_static/css/custom.css @@ -95,6 +95,7 @@ --highlight-comment-color: #408090; --highlight-keyword-color: #007020; --highlight-keyword2-color: #902000; + --highlight-control-flow-keyword-color: #902060; --highlight-number-color: #208050; --highlight-decorator-color: #4070a0; --highlight-type-color: #007020; @@ -223,6 +224,7 @@ --highlight-comment-color: rgba(204, 206, 211, 0.5); --highlight-keyword-color: #ff7085; --highlight-keyword2-color: #42ffc2; + --highlight-control-flow-keyword-color: #ff8ccc; --highlight-number-color: #a1ffe0; --highlight-decorator-color: #ffb373; --highlight-type-color: #8effda; @@ -877,6 +879,10 @@ code, color: var(--highlight-keyword-color); } +.highlight .k-ControlFlow /* Keyword.ControlFlow */ { + color: var(--highlight-control-flow-keyword-color); +} + .highlight .ch /* Comment.Hashbang */, .highlight .cp /* Comment.Preproc */ { color: var(--highlight-keyword2-color);