Skip to content

Commit 9adad22

Browse files
committed
add regions, unicode idents, attributes to GtkSourceView language-spec
1 parent db438ad commit 9adad22

File tree

1 file changed

+32
-8
lines changed
  • src/etc/gedit/share/gtksourceview-3.0/language-specs

1 file changed

+32
-8
lines changed

src/etc/gedit/share/gtksourceview-3.0/language-specs/rust.lang

Lines changed: 32 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,9 @@
1919
<style id="type" _name="Data Type" map-to="def:type"/>
2020
<style id="constant" _name="Constant" map-to="def:constant"/>
2121
<style id="identifier" _name="Identifier" map-to="def:identifier"/>
22-
<style id="number" _name="Number" map-to="def:decimal"/>
22+
<style id="number" _name="Number" map-to="def:number"/>
2323
<style id="scope" _name="Scope" map-to="def:preprocessor"/>
24+
<style id="attribute" _name="Attribute" map-to="def:preprocessor"/>
2425
</styles>
2526

2627
<definitions>
@@ -216,9 +217,19 @@
216217
</match>
217218
</context>
218219

220+
<define-regex id="ident" extended="true">
221+
([^[:cntrl:][:space:][:punct:][:digit:]]|_)([^[:cntrl:][:punct:][:space:]]|_)*
222+
</define-regex>
223+
219224
<context id="scope" style-ref="scope">
220225
<match extended="true">
221-
[a-zA-Z_][a-zA-Z0-9_]*::
226+
\%{ident}::
227+
</match>
228+
</context>
229+
230+
<context id="lifetime" style-ref="keyword">
231+
<match extended="true">
232+
'\%{ident}
222233
</match>
223234
</context>
224235

@@ -231,12 +242,23 @@
231242
</include>
232243
</context>
233244

234-
<context id="char" style-ref="char" end-at-line-end="true" class="char" class-disabled="no-spell-check">
235-
<start>'</start>
236-
<end>'</end>
237-
<include>
238-
<context ref="def:escape"/>
239-
</include>
245+
<define-regex id="hex_digit" extended="true">
246+
[0-9a-fA-F]
247+
</define-regex>
248+
249+
<define-regex id="common_escape" extended="true">
250+
(n|r|t)|
251+
x\%{hex_digit}{2}|
252+
u\%{hex_digit}{4}|
253+
U\%{hex_digit}{8}
254+
</define-regex>
255+
256+
<context id="char" style-ref="char" class="char">
257+
<match extended="true">'([^\\]|\\\%{common_escape})'</match>
258+
</context>
259+
260+
<context id="attribute" style-ref="attribute" class="attribute">
261+
<match extended="true">\#\[[^\]]+\]</match>
240262
</context>
241263

242264
<context id="rust" class="no-spell-check">
@@ -255,6 +277,8 @@
255277
<context ref="scope"/>
256278
<context ref="string"/>
257279
<context ref="char"/>
280+
<context ref="lifetime"/>
281+
<context ref="attribute"/>
258282
</include>
259283
</context>
260284

0 commit comments

Comments
 (0)