Luke Francl | ba9214c | 2016-06-23 21:42:12 +0200 | [diff] [blame] | 1 | ## Syntax highlighting for Rust. |
| 2 | ## Copyright 2015 Luke Francl. |
| 3 | ## Licensed under GPL version 3. |
| 4 | |
| 5 | ## NOTE: Rules are applied in order: later rules re-colorize matching text. |
| 6 | |
| 7 | syntax "rust" "\.rs" |
| 8 | comment "//" |
| 9 | |
| 10 | # Function definitions |
| 11 | color magenta "fn [a-z_0-9]+" |
| 12 | |
| 13 | # Reserved words |
| 14 | color yellow "\<(abstract|alignof|as|become|box|break|const|continue|crate|do|else|enum|extern|false|final|fn|for|if|impl|in|let|loop|macro|match|mod|move|mut|offsetof|override|priv|pub|pure|ref|return|sizeof|static|self|struct|super|true|trait|type|typeof|unsafe|unsized|use|virtual|where|while|yield)\>" |
| 15 | |
| 16 | # Macros |
| 17 | color red "[a-z_]+!" |
| 18 | |
| 19 | # Constants |
| 20 | color magenta "[A-Z][A-Z_0-9]+" |
| 21 | |
| 22 | # Traits/Enums/Structs/Types/... |
Dirkjan Ochtman | 1349c1d | 2016-07-21 10:21:19 +0200 | [diff] [blame] | 23 | color magenta "[A-Z][A-Za-z0-9]+" |
Luke Francl | ba9214c | 2016-06-23 21:42:12 +0200 | [diff] [blame] | 24 | |
| 25 | # Strings |
| 26 | color green "\".*\"" |
| 27 | color green start="\".*\\$" end=".*\"" |
| 28 | ## NOTE: This isn't accurate, but matching "#{0,} for the end of the string is too liberal. |
| 29 | color green start="r#+\"" end="\"#+" |
| 30 | |
| 31 | # Comments |
| 32 | color blue "//.*" |
| 33 | color blue start="/\*" end="\*/" |
| 34 | |
| 35 | # Attributes |
| 36 | color magenta start="#!\[" end="\]" |
| 37 | |
| 38 | # Some common markers |
| 39 | color brightcyan "(XXX|TODO|FIXME|\?\?\?)" |