Skip to content

Instantly share code, notes, and snippets.

@krdln
Last active August 29, 2015 14:01
Show Gist options
  • Save krdln/b9215ea8b46b48d51953 to your computer and use it in GitHub Desktop.
Save krdln/b9215ea8b46b48d51953 to your computer and use it in GitHub Desktop.
Rust nano highlighting
## Simple syntax highlighter for rust
##
syntax "rust" "\.rs$"
## keywords
color brightgreen "\<(as|be|break|copy|else|enum|extern|false|fn|for|if|impl|let|loop|match|mod|mut|priv|pub|ref|return|static|struct|super|true|trait|type|unsafe|use|while|yield|in|crate|continue|box)\>"
color brightwhite "\<(self)\>"
color cyan "\<(mut)\>"
## basic types
color cyan "\<(int|i8|i16|i32|i64|uint|u8|u16|u32|u64|str|f32|f64|bool|char)\>"
## typenames
color cyan "\<(A|B|C|D|E|F|G|H|I|J|K|L|M|N|O|P|Q|R|S|T|U|V|W|X|Y|Z)[a-zA-Z_0-9]*\>"
## lifetimes
color cyan "\<\'[a-zA-Z_0-9]+\>"
## symbols
#color brightred "[;{}]"
#color brightred ";"
color yellow "->|=>|!"
color cyan "[&~@*]"
color white "&&"
## numbers
color green "\<([0-9_]+)([ui](8|16|32|64)?)?\>"
color green "\<0b([01_]+)([ui](8|16|32|64)?)?\>"
color green "\<0x([0-9A-Fa-f_]+)([ui](8|16|32|64)?)?\>"
color green "\<([0-9_]+|(([0-9_]*\.[0-9_]+)([eE][\+-]?[0-9_]+)?|([1-9_][0-9_]*[eE][\+-]?[0-9_]+)))(f|f32|f64)?\>"
## attributes
color yellow "#!?\[.*\]"
color brightyellow "#!?"
## strings
color yellow ""(\\.|[^"])*""
#color brightyellow "\\.|%."
## comments
color magenta "//.*"
color magenta start="/\*" end="\*/"
# colors: {bright,}{green,red,blue,white,yellow,cyan,magenta,black}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment