Last active
June 14, 2016 01:14
-
-
Save lee8oi/3cd7cf880d78345c31d5 to your computer and use it in GitHub Desktop.
A modified version of the Go syntax highlighting for Kate/KDevelop designed to mimic Gist. Also adds new highlighting features (like declared functions return values).
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<!DOCTYPE language SYSTEM "language.dtd"> | |
<!-- | |
This file is part of KDE's Kate project | |
GO.XML supports syntax highlighting for the Go programming language | |
under Kate. Go is a compiled, garbage-collected, concurrent programming | |
language developed by Google Inc. | |
Copyright (C) 2010, Miquel Sabaté <[email protected]> | |
This program, including associated files, is free software. You may | |
distribute it and/or modify it under the terms of the GNU General Public | |
License as published by the Free Software Foundation; either Version 2 of | |
the license, or (at your option) any later version. | |
This program is distributed in the hope that it will be useful, but | |
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY | |
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
for more details. | |
You should have received a copy of the GNU General Public License along | |
with this program; if not, write to the Free Software Foundation, Inc., | |
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | |
--> | |
<!-- | |
This file has been modified by Lee Forest <[email protected]> | |
Jan 2015 - | |
Changed default colors to mimic Gist. | |
Added new highlighting: | |
Function | |
Declared Function | |
Declared Function Arguments | |
Declared Return Values | |
--> | |
<language name="Go" version="1.05" kateversion="2.4" section="Sources" indenter="cstyle" extensions="*.go" author="Lee Forest ([email protected])" license="GPL"> | |
<highlighting> | |
<list name="keywords"> | |
<!-- Keywords have been taken from The Go Programming Language Specification -> Keywords section --> | |
<item>break</item> | |
<item>case</item> | |
<item>chan</item> | |
<item>const</item> | |
<item>continue</item> | |
<item>default</item> | |
<item>defer</item> | |
<item>else</item> | |
<item>fallthrough</item> | |
<item>for</item> | |
<!-- <item>func</item> --> | |
<item>go</item> | |
<item>goto</item> | |
<item>if</item> | |
<item>import</item> | |
<item>interface</item> | |
<item>map</item> | |
<item>package</item> | |
<item>range</item> | |
<item>return</item> | |
<item>select</item> | |
<item>struct</item> | |
<item>switch</item> | |
<item>type</item> | |
<item>var</item> | |
</list> | |
<list name="types"> | |
<item>bool</item> | |
<item>byte</item> | |
<item>complex64</item> | |
<item>complex128</item> | |
<item>error</item> | |
<item>float32</item> | |
<item>float64</item> | |
<item>int</item> | |
<item>int8</item> | |
<item>int16</item> | |
<item>int32</item> | |
<item>int64</item> | |
<item>rune</item> | |
<item>string</item> | |
<item>uint</item> | |
<item>uintptr</item> | |
<item>uint8</item> | |
<item>uint16</item> | |
<item>uint32</item> | |
<item>uint64</item> | |
</list> | |
<list name="builtin"> | |
<item>append</item> | |
<item>cap</item> | |
<item>close</item> | |
<item>complex</item> | |
<item>copy</item> | |
<item>delete</item> | |
<item>imag</item> | |
<item>len</item> | |
<item>make</item> | |
<item>new</item> | |
<item>panic</item> | |
<item>print</item> | |
<item>println</item> | |
<item>real</item> | |
<item>recover</item> | |
</list> | |
<list name="predeclared"> | |
<item>false</item> | |
<item>nil</item> | |
<item>true</item> | |
<item>iota</item> | |
</list> | |
<contexts> | |
<context name="normal" attribute="Normal Text" lineEndContext="#stay"> | |
<keyword attribute="Keyword" context="#stay" String="keywords" /> | |
<keyword attribute="Predeclared Identifier" context="#stay" String="predeclared" /> | |
<keyword attribute="Data Type" context="#stay" String="types" /> | |
<keyword attribute="Builtin Function" context="#stay" String="builtin" /> | |
<RegExpr attribute="Keyword" context="Function" String="func\s(?=\w+)"/> | |
<RegExpr attribute="Function" context="#stay" String="([a-zA-Z]+) ?(?=\()"/> | |
<DetectIdentifier /> | |
<DetectChar attribute="Symbol" context="#stay" char="{" beginRegion="Brace1" /> | |
<DetectChar attribute="Symbol" context="#stay" char="}" endRegion="Brace1" /> | |
<Detect2Chars attribute="Comment" context="Commentar 1" char="/" char1="/" /> | |
<Detect2Chars attribute="Comment" context="Commentar 2" char="/" char1="*" /> | |
<Int attribute="Decimal" context="#stay" /> | |
<Float attribute="Float" context="#stay" /> | |
<HlCOct attribute="Octal" context="#stay"/> | |
<HlCHex attribute="Hex" context="#stay"/> | |
<HlCChar attribute="Char" context="#stay" /> | |
<DetectChar attribute="String" context="String" char=""" /> | |
<DetectChar attribute="String" context="Multiline String" char="`"/> | |
<AnyChar attribute="Symbol" context="#stay" String=":!%&()+,-/.*<=>?[]|~^;"/> | |
</context> | |
<context attribute="Normal Text" name="Function" fallthrough="true" fallthroughContext="normal"> | |
<RegExpr String="[\w\s]+(?=\()" attribute="Declared Function" context="Arguments"/> | |
</context> | |
<context attribute="Normal Text" name="Arguments" lineEndContext="#stay" fallthrough="true" fallthroughContext="normal"> | |
<RegExpr String="\(\)" attribute="Normal Text" context="#stay"/> | |
<RegExpr String="\([\w\[\]\*\.(interface{})]+\)" attribute="Declared Function Arguments" context="#stay"/> | |
<RegExpr String="\)\s\(" attribute="Normal Text" context="Return Values" /> | |
<RegExpr String="[\*\w.]+" attribute="Declared Function Arguments" context="#stay"/> | |
<RegExpr String="\[" attribute="Normal Text" context="#stay" /> | |
<RegExpr String="\]" attribute="Normal Text" context="#stay" /> | |
<RegExpr String="\(" attribute="Normal Text" context="#stay" /> | |
<RegExpr String="\)" attribute="Normal Text" context="#pop#pop" /> | |
<DetectChar char="," attribute="Normal Text" context="#stay"/> | |
<DetectSpaces attribute="Normal Text" context="#stay" /> | |
<StringDetect String="{}" attribute="Declared Function Arguments" context="#stay"/> | |
</context> | |
<context attribute="Normal Text" name="Return Values" fallthrough="true" fallthroughContext="normal"> | |
<StringDetect String="func" attribute="Declared Return Values"/> | |
<RegExpr String="\([\w\[\]\*\.(interface{})]+\)" attribute="Declared Return Values" context="#stay"/> | |
<RegExpr String="\(\)" attribute="Declared Return Values" context="#stay"/> | |
<RegExpr String="[\*\w.]+" attribute="Declared Return Values" context="#stay"/> | |
<RegExpr String="\[" attribute="Normal Text" context="#stay" /> | |
<RegExpr String="\]" attribute="Normal Text" context="#stay" /> | |
<RegExpr String="\(" attribute="Normal Text" context="#stay" /> | |
<RegExpr String="\)" attribute="Normal Text" context="#stay" /> | |
<DetectChar char="," attribute="Normal Text" context="#stay"/> | |
<DetectSpaces attribute="Normal Text" context="#stay" /> | |
<StringDetect String="{}" attribute="Declared Return Values" context="#stay"/> | |
</context> | |
<context attribute="Comment" lineEndContext="#pop" name="Commentar 1"> | |
<LineContinue attribute="Comment" context="#stay"/> | |
<DetectSpaces /> | |
<IncludeRules context="##Alerts" /> | |
<DetectIdentifier /> | |
</context> | |
<context attribute="Comment" lineEndContext="#stay" name="Commentar 2"> | |
<DetectSpaces /> | |
<Detect2Chars attribute="Comment" context="#pop" char="*" char1="/" endRegion="Comment"/> | |
<IncludeRules context="##Alerts" /> | |
<DetectIdentifier /> | |
</context> | |
<context attribute="String" lineEndContext="#pop" name="String"> | |
<LineContinue attribute="String" context="#stay" /> | |
<HlCStringChar attribute="String Char" context="#stay" /> | |
<DetectChar attribute="String" context="#pop" char=""" /> | |
</context> | |
<context attribute="String" lineEndContext="#stay" name="Multiline String"> | |
<LineContinue attribute="String" context="#stay"/> | |
<HlCStringChar attribute="String Char" context="#stay"/> | |
<DetectChar attribute="String" context="#pop" char="`"/> | |
</context> | |
</contexts> | |
<itemDatas> | |
<itemData name="Normal Text" defStyleNum="dsNormal" spellChecking="false"/> | |
<itemData name="Keyword" defStyleNum="dsKeyword" color="#a71d5d" spellChecking="false"/> | |
<itemData name="Predeclared Identifier" defStyleNum="dsOthers" color="#0086B3" spellChecking="false" /> | |
<itemData name="Builtin Function" defStyleNum="dsFunction" color="#644A9B" spellChecking="false" /> | |
<itemData name="Declared Function" defStyleNum="dsFunction" color="#795DA3" spellChecking="false" /> | |
<itemData name="Declared Function Arguments" defStyleNum="dsNormal" color="#1D3E81" spellChecking="false" /> | |
<itemData name="Declared Return Values" defStyleNum="dsNormal" color="#2754AF" spellChecking="false" /> | |
<itemData name="Function" defStyleNum="dsFunction" color="#00769E" spellChecking="false" /> | |
<itemData name="Data Type" defStyleNum="dsDataType" color="#A71D5D" spellChecking="false"/> | |
<itemData name="String Char" defStyleNum="dsChar" /> | |
<itemData name="String" defStyleNum="dsString" color="#DF5000" /> | |
<itemData name="Comment" defStyleNum="dsComment" /> | |
<itemData name="Decimal" defStyleNum="dsDecVal" color="#0086B3" spellChecking="false"/> | |
<itemData name="Octal" defStyleNum="dsBaseN" spellChecking="false"/> | |
<itemData name="Hex" defStyleNum="dsBaseN" spellChecking="false"/> | |
<itemData name="Float" defStyleNum="dsFloat" spellChecking="false"/> | |
<itemData name="Char" defStyleNum="dsChar" spellChecking="false"/> | |
<itemData name="Symbol" defStyleNum="dsNormal" spellChecking="false"/> | |
<itemData name="Error" defStyleNum="dsError" spellChecking="false"/> | |
</itemDatas> | |
</highlighting> | |
<general> | |
<comments> | |
<comment name="singleLine" start="//" /> | |
<comment name="multiLine" start="/*" end="*/" region="Comment"/> | |
</comments> | |
<keywords casesensitive="1" additionalDeliminator="'"" /> | |
</general> | |
</language> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is actually my first time doing syntax highlighting and it took me 3 days to get it right. I added separate highlighting settings for functions, declared functions, declared function arguments, and declared return values.
To install this file backup your /usr/share/apps/katepart/syntax/go.xml and replace it with this one.