Skip to content

Instantly share code, notes, and snippets.

@CTalvio
Last active February 16, 2023 20:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save CTalvio/6de535f9258cfebd71ab64d7e6af4ee6 to your computer and use it in GitHub Desktop.
Save CTalvio/6de535f9258cfebd71ab64d7e6af4ee6 to your computer and use it in GitHub Desktop.
Squirrel highlighting XML for the Kate text editor
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE language SYSTEM "language.dtd">
<language name="Squirrel" version="1.0" kateversion="2.5" section="Scripts" extensions="*.nut;*.gnut">
<highlighting>
<list name="keywords">
<item> break </item>
<item> case </item>
<item> catch </item>
<item> class </item>
<item> clone </item>
<item> constructor </item>
<item> continue </item>
<item> default </item>
<item> delegate </item>
<item> delete </item>
<item> do </item>
<item> else </item>
<item> enum </item>
<item> extends </item>
<item> extern </item>
<item> false </item>
<item> for </item>
<item> foreach </item>
<item> function </item>
<item> goto </item>
<item> if </item>
<item> in </item>
<item> inline </item>
<item> instanceof </item>
<item> null </item>
<item> parent </item>
<item> resume </item>
<item> return </item>
<item> sizeof </item>
<item> static </item>
<item> struct </item>
<item> switch </item>
<item> this </item>
<item> throw </item>
<item> true </item>
<item> try </item>
<item> typedef </item>
<item> typeof </item>
<item> union </item>
<item> vargc </item>
<item> vargv </item>
<item> while </item>
<item> yield </item>
<item> #if </item>
<item> #endif </item>
<item> #else </item>
<item> #elseif </item>
<item> const </item>
<item> thread </item>
</list>
<list name="datatype">
<item> entity </item>
<item> void </item>
<item> var </item>
<item> int </item>
<item> float </item>
<item> bool </item>
<item> string </item>
<item> array </item>
<item> table </item>
<item> function </item>
<item> class </item>
<item> instanceof </item>
</list>
<list name="types">
<item> local </item>
<item> global </item>
<item> globalize </item>
</list>
<contexts>
<context attribute="Normal Text" lineEndContext="#stay" name="Normal">
<DetectSpaces />
<keyword attribute="Keyword" context="#stay" String="keywords"/>
<keyword attribute="Function Type" context="#stay" String="types"/>
<keyword attribute="Data Type" context="#stay" String="datatype"/>
<DetectChar attribute="String" context="string" char="&quot;" />
<Float attribute="Float" context="#stay"/>
<HlCOct attribute="Octal" context="#stay"/>
<HlCHex attribute="Hex" context="#stay"/>
<Int attribute="Decimal" context="#stay"/>
<Detect2Chars attribute="Comment" context="Comment 1" char="/" char1="/"/>
<Detect2Chars attribute="Comment" context="Comment 2" char="/" char1="*" beginRegion="Comment"/>
<AnyChar attribute="Symbol" context="#stay" String="@%\',.?"/>
<AnyChar attribute="Stuff" context="#stay" String="(){}[]"/>
<AnyChar attribute="Operator" context="#stay" String="!=-+*/:;&lt;&gt;&amp;~^|"/>
<RegExpr attribute="Function" context="#stay" String="[a-zA-Z_]* *(?=\()"/>
</context>
<context attribute="String" lineEndContext="#stay" name="string" >
<DetectChar attribute="String" context="#pop" char="&quot;" />
</context>
<context attribute="Comment" lineEndContext="#pop" name="Comment 1"/>
<context attribute="Comment" lineEndContext="#stay" name="Comment 2">
<Detect2Chars attribute="Comment" context="#pop" char="*" char1="/" endRegion="Comment"/>
</context>
</contexts>
<itemDatas>
<itemData name="Stuff" defStyleNum="dsSpecialChar" />
<itemData name="Normal Text" defStyleNum="dsNormal" />
<itemData name="Keyword" defStyleNum="dsKeyword" />
<itemData name="Function Type" defStyleNum="dsDataType" />
<itemData name="Data Type" defStyleNum="dsDataType" />
<itemData name="String" defStyleNum="dsString" />
<itemData name="Decimal" defStyleNum="dsDecVal"/>
<itemData name="Octal" defStyleNum="dsBaseN"/>
<itemData name="Hex" defStyleNum="dsBaseN"/>
<itemData name="Float" defStyleNum="dsFloat"/>
<itemData name="Char" defStyleNum="dsChar"/>
<itemData name="String" defStyleNum="dsString"/>
<itemData name="String Char" defStyleNum="dsChar"/>
<itemData name="Comment" defStyleNum="dsComment"/>
<itemData name="Function" defStyleNum="dsFunction"/>
<itemData name="Variable" defStyleNum="dsVariable"/>
<itemData name="Operator" defStyleNum="dsOperator"/>
<itemData name="Symbol" defStyleNum="dsNormal"/>
</itemDatas>
<general>
<comments>
<comment name="singleLine" start="//"/>
<comment name="multiLine" start="/*" end="*/" region="Comment"/>
</comments>
<keywords casesensitive="1"/>
</general>
</highlighting>
</language>
@CTalvio
Copy link
Author

CTalvio commented Feb 15, 2023

To use this on linux, drop it in $HOME/.local/share/org.kde.syntax-highlighting/syntax/

On windows, the location is %USERPROFILE%\AppData\Local\org.kde.syntax-highlighting\syntax

@CTalvio
Copy link
Author

CTalvio commented Feb 16, 2023

If you are not getting highlighting after installing the file, check Tools>Highlighting>Scripts for and entry named "Squirrel". If there is one, the highlighting file has been picked up. You can enable it manually for individual files from here. But you may need to create a filetype to apply the highlighting automatically on file open.

Go to Settings>Configure Kate>Open/Save>Modes & Filetypes

If you cannot find Scripts/Squirrel in the list, add it. Then set Highlighting to Scripts/Squirrel and set "File extensions" to *.nut;*.gnut

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment