Skip to content

Commit 1164ddd

Browse files
authored
Merge pull request #85 from vsczpv/kate-editors
Add syntax highlighting definitions for the KDE editors
2 parents 382680b + 9332541 commit 1164ddd

7 files changed

Lines changed: 373 additions & 0 deletions

File tree

KDE/README.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Kerboscript Syntax Highlighting for KDE Editors
2+
3+
This syntax definition is compatible with KSyntaxHighlight based KDE editors like Kate, KWrite and KDevelop.
4+
5+
## Installation
6+
7+
Download the `kerboscript.xml` file and place it in the `$HOME/.local/share/org.kde.syntax-highlighting/syntax` directory, or equivalent.
8+
The item `Kerboscript` should then become available in language select drop-down menu, in the Scripts section.
9+
10+
## Supported Features
11+
12+
The KSyntaxHighlight framework does static analysis only, with some basic state machine and regex functions, thus this syntax definition relegates itself to valid syntax highlight only, that is, it won't tell you if you committed a mistake. Some limited version of syntax error highlighting is planned, though.
13+
14+
- Keywords, builtin function/bound variable, toggleables and control flow all have their own highlighting.
15+
16+
- Comment toggling.
17+
18+
- Keywords/builtins after colon operator `:` treated as identifier.
19+
20+
- Your usual batch of literal value highlighting (strings, numbers, etc.).
21+
22+
## Gallery
23+
24+
> Breeze Dark
25+
26+
![Syntax Highlighting with Breeze Dark](bdark.png "Screenshot showing syntax highlighting with Breeze Dark theme")
27+
28+
> Breeze Light
29+
30+
![Syntax Highlighting with Breeze Light](blight.png "Screenshot showing syntax highlighting with Breeze Light theme")
31+
32+
> "Solar Dark" (Solarized lookalike)
33+
34+
![Syntax Highlighting with Solarized Dark](solarized.png "Screenshot showing syntax highlighting with Solarized Dark theme")
35+
36+
> Monokai
37+
38+
![Syntax Highlighting with Monokai](monokai.png "Screenshot showing syntax highlighting with Monokai theme")
39+
40+
## Maintainer
41+
42+
Please tag @vsczpv for any issues.

KDE/bdark.png

40 KB
Loading

KDE/blight.png

41 KB
Loading

KDE/kerboscript.xml

Lines changed: 330 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,330 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE language>
3+
4+
<!-- SPDX-License-Identifier: GPL-3.0-or-later -->
5+
6+
<!--
7+
Copyright (C) 2025 Vinícius Schütz Piva https://github.com/vsczpv
8+
9+
This program is free software: you can redistribute it and/or modify
10+
it under the terms of the GNU General Public License as published by
11+
the Free Software Foundation, either version 3 of the License, or
12+
(at your option) any later version.
13+
14+
This program is distributed in the hope that it will be useful,
15+
but WITHOUT ANY WARRANTY; without even the implied warranty of
16+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17+
GNU General Public License for more details.
18+
19+
You should have received a copy of the GNU General Public License
20+
along with this program. If not, see <http://www.gnu.org/licenses/>.
21+
-->
22+
23+
24+
<language name="Kerboscript"
25+
version="1"
26+
section="Scripts"
27+
extensions="*.ks"
28+
kateversion="5.0"
29+
casesensitive="0"
30+
author="Vinícius Schütz Piva"
31+
license="GPLv3+"
32+
identer="cstyle">
33+
<highlighting>
34+
<list name="keywords">
35+
<item>add</item>
36+
<item>and</item>
37+
<item>all</item>
38+
<item>at</item>
39+
<item>choose</item>
40+
<item>clearscreen</item>
41+
<item>compile</item>
42+
<item>copy</item>
43+
<item>declare</item>
44+
<item>defined</item>
45+
<item>delete</item>
46+
<item>edit</item>
47+
<item>false</item>
48+
<item>file</item>
49+
<item>function</item>
50+
<item>global</item>
51+
<item>in</item>
52+
<item>is</item>
53+
<item>list</item>
54+
<item>local</item>
55+
<item>lock</item>
56+
<item>log</item>
57+
<item>not</item>
58+
<item>off</item>
59+
<item>once</item>
60+
<item>or</item>
61+
<item>parameter</item>
62+
<item>preserve</item>
63+
<item>print</item>
64+
<item>reboot</item>
65+
<item>remove</item>
66+
<item>rename</item>
67+
<item>run</item>
68+
<item>runoncepath</item>
69+
<item>runpath</item>
70+
<item>set</item>
71+
<item>shutdown</item>
72+
<item>stage</item>
73+
<item>switch</item>
74+
<item>to</item>
75+
<item>toggle</item>
76+
<item>true</item>
77+
<item>unlock</item>
78+
<item>unset</item>
79+
<item>volume</item>
80+
</list>
81+
<list name="controls">
82+
<item>break</item>
83+
<item>else</item>
84+
<item>do</item>
85+
<item>if</item>
86+
<item>for</item>
87+
<item>from</item>
88+
<item>on</item>
89+
<item>return</item>
90+
<item>step</item>
91+
<item>then</item>
92+
<item>until</item>
93+
<item>wait</item>
94+
<item>when</item>
95+
</list>
96+
<list name="builtins">
97+
<item>abs</item>
98+
<item>ceiling</item>
99+
<item>floor</item>
100+
<item>ln</item>
101+
<item>log10</item>
102+
<item>mod</item>
103+
<item>min</item>
104+
<item>max</item>
105+
<item>random</item>
106+
<item>randomseed</item>
107+
<item>sqrt</item>
108+
<item>char</item>
109+
<item>unchar</item>
110+
<item>sin</item>
111+
<item>cos</item>
112+
<item>tan</item>
113+
<item>arcsin</item>
114+
<item>arccos</item>
115+
<item>arctan</item>
116+
<item>arctan2</item>
117+
<item>v</item>
118+
<item>vdot</item>
119+
<item>vectordotproduct</item>
120+
<item>vcrs</item>
121+
<item>vectorcrossproduct</item>
122+
<item>vang</item>
123+
<item>vectorangle</item>
124+
<item>vxcl</item>
125+
<item>vectorexclude</item>
126+
<item>r</item>
127+
<item>q</item>
128+
<item>heading</item>
129+
<item>lookdirup</item>
130+
<item>angleaxis</item>
131+
<item>rotatefromto</item>
132+
<item>latlng</item>
133+
134+
<item>ship</item>
135+
<item>target</item>
136+
<item>hastarget</item>
137+
138+
<item>throttle</item>
139+
<item>steering</item>
140+
<item>wheelthrottle</item>
141+
<item>wheelsteering</item>
142+
143+
<item>constant</item>
144+
<item>terminal</item>
145+
<item>core</item>
146+
<item>archive</item>
147+
<item>constant</item>
148+
149+
<item>nextnode</item>
150+
<item>hasnode</item>
151+
<item>allnodes</item>
152+
153+
<item>alt</item>
154+
<item>eta</item>
155+
<item>encounter</item>
156+
157+
<item>missiontime</item>
158+
<item>time</item>
159+
160+
<item>version</item>
161+
<item>sessiontime</item>
162+
163+
<item>homeconnection</item>
164+
<item>controlconnection</item>
165+
166+
<item>kuniverse</item>
167+
<item>config</item>
168+
<item>warp</item>
169+
<item>warpmode</item>
170+
<item>mapview</item>
171+
<item>loaddistance</item>
172+
173+
<item>profileresult</item>
174+
<item>opcodesleft</item>
175+
<item>addons</item>
176+
177+
<item>solarprimevector</item>
178+
179+
<item>steeringmanager</item>
180+
181+
<item>sasmode</item>
182+
<item>navmode</item>
183+
184+
<item>positionat</item>
185+
<item>velocityat</item>
186+
<item>orbitat</item>
187+
188+
<item>path</item>
189+
<item>scriptpath</item>
190+
<item>volume</item>
191+
<item>cd</item>
192+
<item>copypath</item>
193+
<item>movepath</item>
194+
<item>deletepath</item>
195+
<item>exists</item>
196+
<item>create</item>
197+
<item>createdir</item>
198+
<item>open</item>
199+
<item>writejson</item>
200+
<item>readjson</item>
201+
202+
<item>at</item>
203+
<item>processor</item>
204+
205+
<item>lexicon</item>
206+
<item>list</item>
207+
<item>queue</item>
208+
<item>range</item>
209+
<item>stack</item>
210+
<item>uniqueset</item>
211+
</list>
212+
<list name="toggleables">
213+
<item>sas</item>
214+
<item>rcs</item>
215+
<item>gear</item>
216+
<item>lights</item>
217+
<item>brakes</item>
218+
<item>abort</item>
219+
<item>legs</item>
220+
<item>chutes</item>
221+
<item>chutessafe</item>
222+
<item>panels</item>
223+
<item>radiators</item>
224+
<item>ladders</item>
225+
<item>bays</item>
226+
<item>intakes</item>
227+
<item>deploydrills</item>
228+
<item>drills</item>
229+
<item>fuelcells</item>
230+
<item>isru</item>
231+
232+
<item>ag1</item>
233+
<item>ag2</item>
234+
<item>ag3</item>
235+
<item>ag4</item>
236+
<item>ag5</item>
237+
<item>ag6</item>
238+
<item>ag7</item>
239+
<item>ag8</item>
240+
<item>ag9</item>
241+
<item>ag10</item>
242+
<item>agn</item>
243+
244+
</list>
245+
<contexts>
246+
<context attribute="NormalText" lineEndContext="#pop" name="NormalText">
247+
248+
<keyword attribute="Builtin" context="#stay" String="builtins"/>
249+
<keyword attribute="Keyword" context="#stay" String="keywords"/>
250+
<keyword attribute="Control" context="#stay" String="controls"/>
251+
<keyword attribute="Toggleable" context="#stay" String="toggleables"/>
252+
253+
<DetectChar attribute="String" context="string" char="&quot;"/>
254+
255+
<Detect2Chars attribute="Comment" context="Comment" char="/" char1="/" lookAhead="true"/>
256+
257+
<DetectChar attribute="Operator" context="#stay" char="+"/>
258+
<DetectChar attribute="Operator" context="#stay" char="-"/>
259+
<DetectChar attribute="Operator" context="#stay" char="*"/>
260+
<DetectChar attribute="Operator" context="#stay" char="/"/>
261+
<DetectChar attribute="Operator" context="#stay" char="^"/>
262+
<DetectChar attribute="Operator" context="#stay" char="&gt;="/>
263+
<DetectChar attribute="Operator" context="#stay" char="&lt;="/>
264+
<DetectChar attribute="Operator" context="#stay" char="&lt;"/>
265+
<DetectChar attribute="Operator" context="#stay" char="&gt;"/>
266+
<DetectChar attribute="Operator" context="#stay" char="="/>
267+
<DetectChar attribute="Operator" context="#stay" char="("/>
268+
<DetectChar attribute="Operator" context="#stay" char=")"/>
269+
<DetectChar attribute="Operator" context="#stay" char="["/>
270+
<DetectChar attribute="Operator" context="#stay" char="]"/>
271+
<DetectChar attribute="Operator" context="#stay" char="{"/>
272+
<DetectChar attribute="Operator" context="#stay" char="}"/>
273+
<DetectChar attribute="Operator" context="#stay" char=","/>
274+
275+
276+
<RegExpr attribute="NumberFloat" context="NormalText" String="([-+])?\b([0-9_]+\.?[0-9_]*)(e[-+]?[0-9_]+)\b|([-+])?\b([0-9_]+\.?[0-9_]*)\b"/>
277+
278+
<RegExpr attribute="Operator" context="#stay" String="\.$"/>
279+
280+
<RegExpr attribute="UntaggedIdentifier" context="#stay" String="\w+"/>
281+
<DetectChar attribute="UntaggedIdentifier" context="ColonContext" char=":"/>
282+
283+
</context>
284+
<context attribute="String" lineEndContext="#stay" name="string">
285+
<DetectChar attribute="String" context="#pop" char="&quot;"/>
286+
</context>
287+
<context attribute="Comment" lineEndContext="#pop" name="Comment">
288+
<DetectSpaces/>
289+
<IncludeRules context="##Comments"/>
290+
<DetectIdentifier/>
291+
</context>
292+
<!-- Some words in Kerboscript are both used in keyword/builtin AND as structure
293+
parameters, which makes it hard to highlight them without some context
294+
logic. For example, SHUTDOWN is both a keyword command AND a method on engine
295+
structures, so the code "engine:Shutdown()" would, otherwise, be highlighted
296+
wrongly. However, as far as I'm concerned, no one will ever something like this:
297+
298+
object : if ... {}
299+
300+
so simply treating everything after a colon as a word should work.
301+
-->
302+
<context attribute="UntaggedIdentifier" lineEndContext="#pop" name="ColonContext">
303+
<RegExpr attribute="UntaggedIdentifier" context="NormalText" String="\w+"/>
304+
</context>
305+
</contexts>
306+
<itemDatas>
307+
<itemData name="NormalText" defStyleNum="dsNormal"/>
308+
<itemData name="Keyword" defStyleNum="dsKeyword"/>
309+
<itemData name="Control" defStyleNum="dsControlFlow"/>
310+
<itemData name="String" defStyleNum="dsString"/>
311+
<itemData name="Comment" defStyleNum="dsComment"/>
312+
<itemData name="NumberFloat" defStyleNum="dsFloat"/>
313+
<itemData name="Operator" defStyleNum="dsOperator"/>
314+
<itemData name="UntaggedIdentifier" defStyleNum="dsVariable"/>
315+
<itemData name="Builtin" defStyleNum="dsBuiltIn"/>
316+
<itemData name="Toggleable" defStyleNum="dsExtension"/>
317+
</itemDatas>
318+
</highlighting>
319+
<general>
320+
<comments>
321+
<comment name="singleLine" start="//"/>
322+
</comments>
323+
<keywords casesensitive="0"/>
324+
<folding identationsensitive="0"/>
325+
<emptyLines>
326+
<emptyLine regexpr="\s+"/>
327+
</emptyLines>
328+
</general>
329+
</language>
330+
<!-- kate: space-indent on; indent-width 2; replace-tabs on; -->

KDE/monokai.png

39.5 KB
Loading

KDE/solarized.png

39.8 KB
Loading

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ Syntax definitions are available for the following editors/IDEs:
1111
* [BBEdit](https://github.com/KSP-KOS/EditorTools/tree/develop/BBEdit)
1212
* [gedit](https://github.com/KSP-KOS/EditorTools/tree/develop/Gedit)
1313
* [IntelliJ IDEA](https://github.com/KSP-KOS/EditorTools/tree/develop/IDEA)
14+
* [Kate/KWrite/KDevelop](https://github.com/KSP-KOS/EditorTools/tree/develop/KDE)
1415
* [nano](https://github.com/KSP-KOS/EditorTools/tree/develop/Nano)
1516
* [Notepad++](https://github.com/KSP-KOS/EditorTools/tree/develop/NotepadPlusPlus)
1617
* [Sublime Text 3](https://github.com/KSP-KOS/EditorTools/tree/develop/SublimeText3)

0 commit comments

Comments
 (0)