Skip to content

Instantly share code, notes, and snippets.

@KevinJones
Created November 24, 2025 21:03
Show Gist options
  • Select an option

  • Save KevinJones/e304ec73301ea76e528205c9991946c9 to your computer and use it in GitHub Desktop.

Select an option

Save KevinJones/e304ec73301ea76e528205c9991946c9 to your computer and use it in GitHub Desktop.
Wren Syntax Definition for Kate
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE language
[
<!ENTITY HEX "[0-9A-Fa-f]">
]>
<!--
Wren (wren.io) syntax highlighting for the Kate code editor. To use, place this file at
~/.local/share/org.kde.syntax-highlighting/syntax
or wherever your Kate installation looks for syntax definition files.
TODO list:
- use and test more
- raw strings
- possibly styles for _fields, __static_fields
Helpful links:
- Kate Syntax Highlighting List https://kate-editor.org/syntax/
- KDE Syntax Highlighting Engine https://invent.kde.org/frameworks/syntax-highlighting
- "The Highlight Definition XML Format" https://docs.kde.org/stable5/en/kate/katepart/highlight.html#katehighlight-xml-format
- Wren Example Syntax https://github.com/wren-lang/wren/blob/main/example/syntax.wren
- Wren Syntax Guide https://wren.io/syntax.html
Initially released 2025-11-24 by Kevin Jones (kevin.chris.jones@gmail.com).
* * *
This is free and unencumbered software released into the public domain.
Anyone is free to copy, modify, publish, use, compile, sell, or
distribute this software, either in source code form or as a compiled
binary, for any purpose, commercial or non-commercial, and by any
means.
In jurisdictions that recognize copyright laws, the author or authors
of this software dedicate any and all copyright interest in the
software to the public domain. We make this dedication for the benefit
of the public at large and to the detriment of our heirs and
successors. We intend this dedication to be an overt act of
relinquishment in perpetuity of all present and future rights to this
software under copyright law.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
For more information, please refer to <https://unlicense.org/>
-->
<language name="Wren" version="1" kateversion="5.94" indenter="cstyle" section="Scripts" extensions="*.wren" mimetype="text/x-wren" author="Kevin Jones (kevin.chris.jones@gmail.com)" license="unlicense">
<highlighting>
<list name="keywords">
<item>as</item>
<item>class</item>
<item>construct</item>
<item>foreign</item>
<item>import</item>
<item>in</item>
<item>is</item>
<item>static</item>
<item>super</item>
<item>this</item>
<item>true</item>
<item>var</item>
</list>
<list name="specialvars">
<item>false</item>
<item>null</item>
<item>true</item>
</list>
<list name="control">
<item>break</item>
<item>continue</item>
<item>else</item>
<item>for</item>
<item>if</item>
<item>return</item>
<item>while</item>
</list>
<list name="startcontrol">
<item>if</item>
</list>
<list name="elsecontrol">
<item>else</item>
</list>
<list name="basevar">
<!-- Core Classes -->
<item>Bool</item>
<item>Class</item>
<item>Fiber</item>
<item>Fn</item>
<item>List</item>
<item>Map</item>
<item>Null</item>
<item>Object</item>
<item>Range</item>
<item>Sequence</item>
<item>String</item>
<item>System</item>BFunc
<!-- modules? I guess? -->
<item>core</item>
<item>meta</item>
<item>random</item>
</list>
<list name="basefunc">
<item>Fiber.abort</item>
<item>Fiber.current</item>
<item>Fiber.new</item>
<item>Fiber.suspend</item>
<item>Fiber.yield</item>
<item>Fn.new</item>
<item>List.filled</item>
<item>List.new</item>
<item>Map.new</item>
<item>Object.same</item>
<item>String.fromCodePoint</item>
<item>String.fromByte</item>
<item>System.clock</item>
<item>System.gc</item>
<item>System.print</item>
<item>System.printAll</item>
<item>System.write</item>
<item>System.writeAll</item>
</list>
<contexts>
<context name="normal" attribute="Normal Text" lineEndContext="#stay">
<keyword attribute="Keyword" context="#stay" String="keywords"/>
<keyword attribute="Special Variable" context="#stay" String="specialvars"/>
<keyword attribute="Control" context="#stay" String="control"/>
<keyword attribute="BFunc" context="#stay" String="basefunc" weakDeliminator="."/>
<keyword attribute="BVar" context="#stay" String="basevar"/>
<DetectChar attribute="String" context="String" char="&quot;" />
<Detect2Chars attribute="Comment" context="Commentar 1" char="/" char1="/" />
<Detect2Chars attribute="Comment" context="Commentar 2" char="/" char1="*" beginRegion="Comment" />
<DetectChar attribute="Symbol" context="#stay" char="{" beginRegion="Brace1" />
<DetectChar attribute="Symbol" context="#stay" char="}" endRegion="Brace1" />
<!-- numbers: hex, decimal, exponents -->
<RegExpr attribute="Numbers" context="NumberSuffix" String="(?:\b0x[0-9A-Fa-f]+\b)|(?:\b(?:[0-9]+)(?:\.[0-9]+)?(?:e[0-9]+)?\b)"/>
<!-- operators -->
<DetectChar char="(" attribute="Symbol" />
<DetectChar char=")" attribute="Symbol" />
<DetectChar char="[" attribute="Symbol" />
<DetectChar char="]" attribute="Symbol" />
<DetectChar char="-" attribute="Symbol" />
<DetectChar char="!" attribute="Symbol" />
<DetectChar char="~" attribute="Symbol" />
<DetectChar char="*" attribute="Symbol" />
<DetectChar char="/" attribute="Symbol" />
<DetectChar char="%" attribute="Symbol" />
<DetectChar char="+" attribute="Symbol" />
<RegExpr String="\.{2,3}" attribute="Symbol" />
<DetectChar char="&amp;" attribute="Symbol" />
<DetectChar char="^" attribute="Symbol" />
<DetectChar char="|" attribute="Symbol" />
<DetectChar char="&lt;" attribute="Symbol" />
<DetectChar char="&gt;" attribute="Symbol" />
<DetectChar char="=" attribute="Symbol" />
<Detect2Chars char="?" char1=":" attribute="Symbol" />
<DetectChar char="." attribute="Symbol" />
</context>
<context name="StartControl" attribute="Normal Text" lineEndContext="#stay">
<keyword attribute="Control" context="#stay" endRegion="chunk" beginRegion="chunk" String="elsecontrol" />
<keyword attribute="Control" context="#pop" endRegion="chunk" String="endcontrol" />
</context>
<context name="String" attribute="String" lineEndContext="#pop" >
<DetectChar attribute="String" context="#pop" char="&quot;" />
<IncludeRules context="FindEscape" />
<!-- wren can embed arbitrary expressions inside a string. -->
<Detect2Chars attribute="Symbol" context="String Embed" char="%" char1="("/>
</context>
<context name="String Embed" attribute="Normal Text" lineEndContext="#stay" >
<IncludeRules context="normal" />
<DetectChar char="(" context="String Embed" attribute = "Normal Text"/>
<DetectChar char=")" context="#pop" attribute="Normal Text" />
</context>
<!-- Escape characters in strings, like \0 for null, \t for tab. -->
<context attribute="String" lineEndContext="#pop" name="FindEscape">
<DetectChar context="EscapedChar" char="\" lookAhead="1"/>
</context>
<context attribute="String" lineEndContext="#pop" name="EscapedChar">
<RegExpr attribute="String Char" context="#pop" String="\\[%0abfnrtv\\'&quot;]|\\x&HEX;{2}|\\u&HEX;{4}|\\U&HEX;{8}" />
<RegExpr attribute="Error" context="#pop" String="\\[xuU]&HEX;*|\\" />
</context>
<context attribute="Comment" lineEndContext="#pop" name="Commentar 1">
<DetectSpaces />
<IncludeRules context="##Comments" />
<DetectIdentifier />
</context>
<context attribute="Comment" lineEndContext="#stay" name="Commentar 2">
<DetectSpaces />
<!-- Wren allows for nested /* */ comments, unlike C. -->
<Detect2Chars attribute="Comment" context="Commentar 2" char="/" char1="*" />
<Detect2Chars attribute="Comment" context="#pop" char="*" char1="/" endRegion="Comment"/>
<IncludeRules context="##Comments" />
<DetectIdentifier />
</context>
</contexts>
<itemDatas>
<itemData name="Normal Text" defStyleNum="dsNormal" spellChecking="false"/>
<itemData name="Keyword" defStyleNum="dsKeyword" spellChecking="false"/>
<itemData name="Special Variable" defStyleNum="dsKeyword" spellChecking="false"/>
<itemData name="Control" defStyleNum="dsControlFlow" spellChecking="false"/>
<itemData name="BFunc" defStyleNum="dsBuiltIn" spellChecking="false" />
<itemData name="BVar" defStyleNum="dsBuiltIn" spellChecking="false" />
<itemData name="Comment" defStyleNum="dsComment" spellChecking="true"/>
<itemData name="String" defStyleNum="dsString" spellChecking="true"/>
<itemData name="Symbol" defStyleNum="dsOperator" spellChecking="false"/>
<itemData name="Numbers" defStyleNum="dsDecVal" spellChecking="false"/>
<itemData name="Error" defStyleNum="dsError" spellChecking="false"/>
<itemData name="String Char" defStyleNum="dsChar" spellChecking="false"/>
</itemDatas>
</highlighting>
<general>
<comments>
<comment name="singleLine" start="//" position="afterwhitespace" />
<comment name="multiLine" start="/*" end="*/" region="BlockComment" />
</comments>
</general>
</language>
<!-- kate: space-indent on; indent-width 2; replace-tabs on; -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment