Changeset View
Changeset View
Standalone View
Standalone View
data/syntax/ruby.xml
Show All 25 Lines | |||||
26 | --> | 26 | --> | ||
27 | 27 | | |||
28 | <!-- | 28 | <!-- | ||
29 | TODO: Division after gdl contexts is interpreted as regexp | 29 | TODO: Division after gdl contexts is interpreted as regexp | ||
30 | --> | 30 | --> | ||
31 | 31 | | |||
32 | <!-- Hold the "language" opening tag on a single line, as mentioned in "language.dtd". --> | 32 | <!-- Hold the "language" opening tag on a single line, as mentioned in "language.dtd". --> | ||
33 | <language name="Ruby" section="Scripts" | 33 | <language name="Ruby" section="Scripts" | ||
34 | version="9" kateversion="3.3" | 34 | version="10" kateversion="3.3" | ||
35 | extensions="*.rb;*.rjs;*.rxml;*.xml.erb;*.js.erb;*.rake;Rakefile;Gemfile;*.gemspec;Vagrantfile" | 35 | extensions="*.rb;*.rjs;*.rxml;*.xml.erb;*.js.erb;*.rake;Rakefile;Gemfile;*.gemspec;Vagrantfile" | ||
36 | mimetype="application/x-ruby" | 36 | mimetype="application/x-ruby" | ||
37 | style="ruby" indenter="ruby" | 37 | style="ruby" indenter="ruby" | ||
38 | author="Stefan Lang (langstefan@gmx.at), Sebastian Vuorinen (sebastian.vuorinen@helsinki.fi), Robin Pedersen (robinpeder@gmail.com), Miquel Sabaté (mikisabate@gmail.com)" license="LGPLv2+"> | 38 | author="Stefan Lang (langstefan@gmx.at), Sebastian Vuorinen (sebastian.vuorinen@helsinki.fi), Robin Pedersen (robinpeder@gmail.com), Miquel Sabaté (mikisabate@gmail.com)" license="LGPLv2+"> | ||
39 | 39 | | |||
40 | <highlighting> | 40 | <highlighting> | ||
41 | 41 | | |||
42 | <list name="keywords"> | 42 | <list name="keywords"> | ||
▲ Show 20 Lines • Show All 156 Lines • ▼ Show 20 Line(s) | 189 | <context name="Normal" attribute="Normal Text" lineEndContext="#stay"> | |||
199 | <!-- "def" - "end" blocks --> | 199 | <!-- "def" - "end" blocks --> | ||
200 | <!-- check for statement modifiers with regexes --> | 200 | <!-- check for statement modifiers with regexes --> | ||
201 | <DetectChar attribute="Operator" char="{" context="Find closing block brace" beginRegion="def block"/> | 201 | <DetectChar attribute="Operator" char="{" context="Find closing block brace" beginRegion="def block"/> | ||
202 | <RegExpr attribute="Keyword" String="(\=|\(|\[|\{)\s*(if|unless|while|until)\b" context="#stay" beginRegion="def block"/> | 202 | <RegExpr attribute="Keyword" String="(\=|\(|\[|\{)\s*(if|unless|while|until)\b" context="#stay" beginRegion="def block"/> | ||
203 | <RegExpr attribute="Keyword" String="(while|until)\b(?!.*\bdo\b)" context="#stay" beginRegion="def block" /> | 203 | <RegExpr attribute="Keyword" String="(while|until)\b(?!.*\bdo\b)" context="#stay" beginRegion="def block" /> | ||
204 | <RegExpr attribute="Keyword" String="\;\s*(while|until)\b(?!.*\bdo\b)" context="#stay" beginRegion="def block"/> | 204 | <RegExpr attribute="Keyword" String="\;\s*(while|until)\b(?!.*\bdo\b)" context="#stay" beginRegion="def block"/> | ||
205 | <RegExpr attribute="Keyword" String="(if|unless)\b" context="#stay" beginRegion="def block" firstNonSpace="true"/> | 205 | <RegExpr attribute="Keyword" String="(if|unless)\b" context="#stay" beginRegion="def block" firstNonSpace="true"/> | ||
206 | <RegExpr attribute="Keyword" String="\;\s*(if|unless)\b" context="#stay" beginRegion="def block"/> | 206 | <RegExpr attribute="Keyword" String="\;\s*(if|unless)\b" context="#stay" beginRegion="def block"/> | ||
207 | <WordDetect attribute="Keyword" String="class" context="#stay" beginRegion="def block"/> | 207 | <WordDetect attribute="Keyword" String="class" context="no_heredoc" beginRegion="def block"/> | ||
208 | <WordDetect attribute="Keyword" String="module" context="#stay" beginRegion="def block"/> | 208 | <WordDetect attribute="Keyword" String="module" context="#stay" beginRegion="def block"/> | ||
209 | <WordDetect attribute="Keyword" String="begin" context="#stay" beginRegion="def block"/> | 209 | <WordDetect attribute="Keyword" String="begin" context="#stay" beginRegion="def block"/> | ||
210 | <RegExpr attribute="Keyword" String="\bfor\b(?!.*\bdo\b)" context="#stay" beginRegion="def block"/> | 210 | <RegExpr attribute="Keyword" String="\bfor\b(?!.*\bdo\b)" context="#stay" beginRegion="def block"/> | ||
211 | <WordDetect attribute="Keyword" String="case" context="#stay" beginRegion="def block"/> | 211 | <WordDetect attribute="Keyword" String="case" context="#stay" beginRegion="def block"/> | ||
212 | <WordDetect attribute="Keyword" String="do" context="#stay" beginRegion="def block"/> | 212 | <WordDetect attribute="Keyword" String="do" context="#stay" beginRegion="def block"/> | ||
213 | <WordDetect attribute="Keyword" String="def" context="#stay" beginRegion="def block"/> | 213 | <WordDetect attribute="Keyword" String="def" context="#stay" beginRegion="def block"/> | ||
214 | <WordDetect attribute="Keyword" String="end" context="#stay" endRegion="def block"/> | 214 | <WordDetect attribute="Keyword" String="end" context="#stay" endRegion="def block"/> | ||
215 | <!-- elsif/else close the current block and start a new one --> | 215 | <!-- elsif/else close the current block and start a new one --> | ||
▲ Show 20 Lines • Show All 42 Lines • ▼ Show 20 Line(s) | |||||
258 | 258 | | |||
259 | <!-- recognize the beginning of a HEREDOC | 259 | <!-- recognize the beginning of a HEREDOC | ||
260 | This uses new features in Kate 2.3 and later | 260 | This uses new features in Kate 2.3 and later | ||
261 | 261 | | |||
262 | There is no other chance of keeping heredoc apart from the | 262 | There is no other chance of keeping heredoc apart from the | ||
263 | push operator '<<' than requiring to put space between the operator | 263 | push operator '<<' than requiring to put space between the operator | ||
264 | and the string. | 264 | and the string. | ||
265 | --> | 265 | --> | ||
266 | <RegExpr attribute="Operator" context="find_indented_heredoc" String="\s*<<-(?=\w+|["'])" beginRegion="HereDocument" /> | 266 | <RegExpr attribute="Operator" context="find_indented_heredoc" String="\s*<<[-~](?=\w+|["'`])" beginRegion="HereDocument" /> | ||
267 | <RegExpr attribute="Operator" context="find_heredoc" String="\s*<<(?=\w+|["'])" beginRegion="HereDocument" /> | 267 | <RegExpr attribute="Operator" context="find_heredoc" String="\s*<<(?=\w+|["'`])" beginRegion="HereDocument" /> | ||
268 | 268 | | |||
269 | <DetectChar attribute="Operator" char="." context="#stay"/> | 269 | <DetectChar attribute="Operator" char="." context="#stay"/> | ||
270 | <Detect2Chars attribute="Operator" char="&" char1="&" context="#stay"/> | 270 | <Detect2Chars attribute="Operator" char="&" char1="&" context="#stay"/> | ||
271 | <Detect2Chars attribute="Operator" char="|" char1="|" context="#stay"/> | 271 | <Detect2Chars attribute="Operator" char="|" char1="|" context="#stay"/> | ||
272 | <RegExpr attribute="Operator" String="\s[\?\:\%]\s" context="#stay"/> | 272 | <RegExpr attribute="Operator" String="\s[\?\:\%]\s" context="#stay"/> | ||
273 | <RegExpr attribute="Operator" String="[|&<>\^\+*~\-=]+" context="#stay"/> | 273 | <RegExpr attribute="Operator" String="[|&<>\^\+*~\-=]+" context="#stay"/> | ||
274 | <!-- regexp hack --> | 274 | <!-- regexp hack --> | ||
275 | <RegExpr attribute="Operator" String="\s!" context="#stay"/> | 275 | <RegExpr attribute="Operator" String="\s!" context="#stay"/> | ||
276 | <RegExpr attribute="Operator" String="/=\s" context="#stay" insensitive="0"/> | 276 | <RegExpr attribute="Operator" String="/=\s" context="#stay" insensitive="0"/> | ||
277 | <Detect2Chars attribute="Operator" char="%" char1="=" context="#stay"/> | 277 | <Detect2Chars attribute="Operator" char="%" char1="=" context="#stay"/> | ||
278 | <Detect2Chars attribute="Operator" char=":" char1=":" context="Member Access"/> | 278 | <Detect2Chars attribute="Operator" char=":" char1=":" context="Member Access"/> | ||
279 | 279 | | |||
280 | <RegExpr attribute="Symbol" String=":(@{1,2}|\$)?[a-zA-Z_][a-zA-Z0-9_]*[=?!]?" context="check_div_1"/> | 280 | <RegExpr attribute="Symbol" String=":(@{1,2}|\$)?[a-zA-Z_][a-zA-Z0-9_]*[=?!]?" context="check_div_1"/> | ||
281 | <RegExpr attribute="Symbol" String=":\[\]=?" context="check_div_1"/> | 281 | <RegExpr attribute="Symbol" String=":\[\]=?" context="check_div_1"/> | ||
282 | 282 | | |||
283 | <RegExpr attribute="Symbol" String="(@{1,2}|\$)?[a-zA-Z_][a-zA-Z0-9_]*[=?!]?: " context="check_div_1"/> | 283 | <!-- Do not send to "check_div_1" context!: | ||
284 | <RegExpr attribute="Symbol" String="\[\]=?: " context="check_div_1"/> | 284 | after detecting these rules (": ") there can be a regular expression (see bug: #361875) --> | ||
285 | <RegExpr attribute="Symbol" String="(@{1,2}|\$)?[a-zA-Z_][a-zA-Z0-9_]*[=?!]?: " context="#stay"/> | ||||
286 | <RegExpr attribute="Symbol" String="\[\]=?: " context="#stay"/> | ||||
285 | 287 | | |||
286 | <DetectChar attribute="String" char=""" context="Quoted String"/> | 288 | <DetectChar attribute="String" char=""" context="Quoted String"/> | ||
287 | <DetectChar attribute="Raw String" char="'" context="Apostrophed String"/> | 289 | <DetectChar attribute="Raw String" char="'" context="Apostrophed String"/> | ||
288 | <DetectChar attribute="Command" char="`" context="Command String"/> | 290 | <DetectChar attribute="Command" char="`" context="Command String"/> | ||
289 | 291 | | |||
290 | <Detect2Chars attribute="Normal Text" char="?" char1="#" context="#stay"/> | 292 | <Detect2Chars attribute="Normal Text" char="?" char1="#" context="#stay"/> | ||
291 | 293 | | |||
292 | <RegExpr attribute="Comment" String="#\s*BEGIN.*$" context="#stay" beginRegion="marker" column="0"/> | 294 | <RegExpr attribute="Comment" String="#\s*BEGIN.*$" context="#stay" beginRegion="marker" column="0"/> | ||
▲ Show 20 Lines • Show All 138 Lines • ▼ Show 20 Line(s) | 341 | <!-- <DetectChar attribute="Operator" char="%" context="#pop#pop"/> --> | |||
431 | <context name="General Comment" attribute="Comment" lineEndContext="#pop"> | 433 | <context name="General Comment" attribute="Comment" lineEndContext="#pop"> | ||
432 | <IncludeRules context="##Alerts" /> | 434 | <IncludeRules context="##Alerts" /> | ||
433 | </context> | 435 | </context> | ||
434 | 436 | | |||
435 | <!-- HEREDOC support | 437 | <!-- HEREDOC support | ||
436 | The contexts below support both normal and indented heredocs | 438 | The contexts below support both normal and indented heredocs | ||
437 | --> | 439 | --> | ||
438 | <!-- here we markup the heredoc markers --> | 440 | <!-- here we markup the heredoc markers --> | ||
439 | <context name="find_heredoc" attribute="Normal Text" lineEndContext="#pop" > | 441 | <context name="find_heredoc" attribute="Normal Text" lineEndContext="#pop" fallthrough="true" fallthroughContext="#pop"> | ||
440 | <RegExpr attribute="Keyword" context="apostrophed_normal_heredoc" String="'(\w+)'" /> | 442 | <RegExpr attribute="Keyword" context="apostrophed_normal_heredoc" String="'(\w+)'" /> | ||
441 | <RegExpr attribute="Keyword" context="normal_heredoc" String=""?(\w+)"?" /> | 443 | <RegExpr attribute="Keyword" context="normal_heredoc" String="(\w+)" /> | ||
444 | <RegExpr attribute="Keyword" context="normal_heredoc" String=""(\w+)"" /> | ||||
445 | <RegExpr attribute="Keyword" context="normal_heredoc" String="`(\w+)`" /> | ||||
442 | </context> | 446 | </context> | ||
443 | <context name="find_indented_heredoc" attribute="Normal Text" lineEndContext="#pop" > | 447 | <context name="find_indented_heredoc" attribute="Normal Text" lineEndContext="#pop" fallthrough="true" fallthroughContext="#pop"> | ||
444 | <RegExpr attribute="Keyword" context="apostrophed_indented_heredoc" String="'(\w+)'" /> | 448 | <RegExpr attribute="Keyword" context="apostrophed_indented_heredoc" String="'(\w+)'" /> | ||
445 | <RegExpr attribute="Keyword" context="indented_heredoc" String=""?(\w+)"?" /> | 449 | <RegExpr attribute="Keyword" context="indented_heredoc" String="(\w+)" /> | ||
450 | <RegExpr attribute="Keyword" context="indented_heredoc" String=""(\w+)"" /> | ||||
451 | <RegExpr attribute="Keyword" context="indented_heredoc" String="`(\w+)`" /> | ||||
446 | </context> | 452 | </context> | ||
447 | <!-- these are the real heredoc contexts --> | 453 | <!-- these are the real heredoc contexts --> | ||
448 | <context name="indented_heredoc" attribute="Here Document" lineEndContext="#stay" dynamic="true"> | 454 | <context name="indented_heredoc" attribute="Here Document" lineEndContext="#stay" dynamic="true"> | ||
449 | <RegExpr attribute="Keyword" context="#pop#pop" String="%1$" dynamic="true" endRegion="HereDocument" firstNonSpace="true"/> | 455 | <RegExpr attribute="Keyword" context="#pop#pop" String="%1$" dynamic="true" endRegion="HereDocument" firstNonSpace="true"/> | ||
450 | <IncludeRules context="heredoc_rules" /> | 456 | <IncludeRules context="heredoc_rules" /> | ||
451 | </context> | 457 | </context> | ||
452 | <context name="apostrophed_indented_heredoc" attribute="Here Document" lineEndContext="#stay" dynamic="true"> | 458 | <context name="apostrophed_indented_heredoc" attribute="Here Document" lineEndContext="#stay" dynamic="true"> | ||
453 | <RegExpr attribute="Keyword" context="#pop#pop" String="%1$" dynamic="true" endRegion="HereDocument" firstNonSpace="true"/> | 459 | <RegExpr attribute="Keyword" context="#pop#pop" String="%1$" dynamic="true" endRegion="HereDocument" firstNonSpace="true"/> | ||
454 | </context> | 460 | </context> | ||
455 | 461 | | |||
456 | <context name="normal_heredoc" attribute="Here Document" lineEndContext="#stay" dynamic="true"> | 462 | <context name="normal_heredoc" attribute="Here Document" lineEndContext="#stay" dynamic="true"> | ||
457 | <RegExpr attribute="Keyword" context="#pop#pop" String="%1$" dynamic="true" endRegion="HereDocument" column="0"/> | 463 | <RegExpr attribute="Keyword" context="#pop#pop" String="%1$" dynamic="true" endRegion="HereDocument" column="0"/> | ||
458 | <IncludeRules context="heredoc_rules" /> | 464 | <IncludeRules context="heredoc_rules" /> | ||
459 | </context> | 465 | </context> | ||
460 | <context name="apostrophed_normal_heredoc" attribute="Here Document" lineEndContext="#stay" dynamic="true"> | 466 | <context name="apostrophed_normal_heredoc" attribute="Here Document" lineEndContext="#stay" dynamic="true"> | ||
461 | <RegExpr attribute="Keyword" context="#pop#pop" String="%1$" dynamic="true" endRegion="HereDocument" column="0"/> | 467 | <RegExpr attribute="Keyword" context="#pop#pop" String="%1$" dynamic="true" endRegion="HereDocument" column="0"/> | ||
462 | </context> | 468 | </context> | ||
463 | 469 | | |||
464 | <!-- rules for heredoc types --> | 470 | <!-- rules for heredoc types --> | ||
465 | <context name="heredoc_rules" attribute="Normal Text" lineEndContext="#stay"> | 471 | <context name="heredoc_rules" attribute="Normal Text" lineEndContext="#stay"> | ||
466 | <RegExpr attribute="Substitution" String="#@{1,2}" context="Short Subst"/> | 472 | <RegExpr attribute="Substitution" String="#@{1,2}" context="Short Subst"/> | ||
467 | <Detect2Chars attribute="Substitution" char="#" char1="{" context="Subst"/> | 473 | <Detect2Chars attribute="Substitution" char="#" char1="{" context="Subst"/> | ||
468 | </context> | 474 | </context> | ||
469 | 475 | | |||
476 | <!-- avoid highlighting heredoc markers, for example, in singleton class definition (see bug: #358273) --> | ||||
477 | <context name="no_heredoc" attribute="Normal Text" lineEndContext="#stay" fallthrough="true" fallthroughContext="#pop"> | ||||
478 | <DetectSpaces /> | ||||
479 | <Detect2Chars attribute="Operator" char="<" char1="<" context="#pop"/> | ||||
480 | <!-- comments --> | ||||
481 | <RegExpr attribute="Comment" String="#\s*BEGIN.*$" context="#stay" beginRegion="marker" column="0"/> | ||||
482 | <RegExpr attribute="Comment" String="#\s*END.*$" context="#stay" endRegion="marker" column="0"/> | ||||
483 | <DetectChar attribute="Comment" char="#" context="General Comment"/> | ||||
484 | </context> | ||||
485 | | ||||
470 | <!-- General delimited input support | 486 | <!-- General delimited input support | ||
471 | The contexts below handle the various gdl formats | 487 | The contexts below handle the various gdl formats | ||
472 | --> | 488 | --> | ||
473 | <context name="find_gdl_input" attribute="Normal Text" lineEndContext="#pop"> | 489 | <context name="find_gdl_input" attribute="Normal Text" lineEndContext="#pop"> | ||
474 | 490 | | |||
475 | <!-- handle token arrays --> | 491 | <!-- handle token arrays --> | ||
476 | <Detect2Chars attribute="GDL input" context="gdl_token_array_1" char="w" char1="(" /> | 492 | <Detect2Chars attribute="GDL input" context="gdl_token_array_1" char="w" char1="(" /> | ||
477 | <Detect2Chars attribute="GDL input" context="gdl_token_array_2" char="w" char1="{" /> | 493 | <Detect2Chars attribute="GDL input" context="gdl_token_array_2" char="w" char1="{" /> | ||
▲ Show 20 Lines • Show All 430 Lines • ▼ Show 20 Line(s) | |||||
908 | </highlighting> | 924 | </highlighting> | ||
909 | <general> | 925 | <general> | ||
910 | <comments> | 926 | <comments> | ||
911 | <comment name="singleLine" start="#"/> | 927 | <comment name="singleLine" start="#"/> | ||
912 | </comments> | 928 | </comments> | ||
913 | <keywords casesensitive="1" weakDeliminator="!?"/> | 929 | <keywords casesensitive="1" weakDeliminator="!?"/> | ||
914 | </general> | 930 | </general> | ||
915 | </language> | 931 | </language> | ||
932 | | ||||
933 | <!-- kate: replace-tabs off; --> |