Benno Schulenberg | 5e901c4 | 2014-04-08 12:09:29 +0000 | [diff] [blame] | 1 | ## Here is an example for Go. |
Benno Schulenberg | fe9da94 | 2014-05-16 20:21:34 +0000 | [diff] [blame] | 2 | |
Chris Allegretta | 211a5e4 | 2014-03-31 20:26:03 +0000 | [diff] [blame] | 3 | syntax "go" "\.go$" |
Mike Scalora | 6a2032f | 2016-05-25 22:13:50 +0200 | [diff] [blame] | 4 | comment "//" |
Chris Allegretta | 211a5e4 | 2014-03-31 20:26:03 +0000 | [diff] [blame] | 5 | |
Benno Schulenberg | 6f35203 | 2016-02-11 17:30:16 +0000 | [diff] [blame] | 6 | # Set up a formatter since spelling is probably useless... |
| 7 | formatter gofmt -w |
| 8 | |
Benno Schulenberg | 5e901c4 | 2014-04-08 12:09:29 +0000 | [diff] [blame] | 9 | # Types. |
| 10 | color green "\<(bool|u?int(8|16|32|64)?|float(32|64)|complex(64|128)|byte|rune|uintptr|string|error)\>" |
| 11 | color green "\<((<-[[:space:]]*)chan|chan[[:space:]]*<-|const|func|interface|map|struct|type|var)\>" |
Chris Allegretta | 211a5e4 | 2014-03-31 20:26:03 +0000 | [diff] [blame] | 12 | |
Benno Schulenberg | 5e901c4 | 2014-04-08 12:09:29 +0000 | [diff] [blame] | 13 | # Predefined functions. |
| 14 | color blue "\<(append|cap|close|complex|copy|delete|imag|len|make|new|panic|print|println|real|recover)\>" |
Chris Allegretta | 211a5e4 | 2014-03-31 20:26:03 +0000 | [diff] [blame] | 15 | |
Benno Schulenberg | 5e901c4 | 2014-04-08 12:09:29 +0000 | [diff] [blame] | 16 | # Control structures. |
| 17 | color brightyellow "\<(case|default|defer|else|for|go|if|range|select|switch)\>" |
Chris Allegretta | 211a5e4 | 2014-03-31 20:26:03 +0000 | [diff] [blame] | 18 | |
Benno Schulenberg | 5e901c4 | 2014-04-08 12:09:29 +0000 | [diff] [blame] | 19 | # Control flow. |
| 20 | color magenta "\<(break|continue|fallthrough|goto|return)\>" |
| 21 | |
| 22 | # Declarations. |
| 23 | color brightcyan "\<(package|import)\>" |
| 24 | color brightcyan "//[[:space:]]*\+build[[:space:]]+(([a-zA-Z_0-9]+[[:space:]]*)+,[[:space:]]*)*[a-zA-Z_0-9]+" |
| 25 | |
| 26 | # Literals. |
| 27 | color red "\<[0-9]+\.[0-9]*([Ee][+-][0-9]+)?i?\>" |
| 28 | color red "\<[0-9]+[Ee][+-][0-9]+i?\>" |
| 29 | color red "\<\.[0-9]+([Ee][+-][0-9]+)?i?\>" |
| 30 | color red "\<[0-9]+i\>" |
| 31 | color red "\<[1-9][0-9]*\>" |
| 32 | color red "\<0[0-7]*\>" |
| 33 | icolor red "\<0x[0-9a-f]+\>" |
| 34 | |
| 35 | # Strings and characters; slightly fuzzy. |
| 36 | color red "\<(true|false|nil|iota|_)\>" |
| 37 | color red "'(\\.|[^'])+'" |
| 38 | color red ""(\\.|[^"])*"" |
| 39 | color red start=""(\\.|[^"])*\\[[:space:]]*$" end="^(\\.|[^"])*"" |
| 40 | |
| 41 | # Comments. |
Chris Allegretta | 211a5e4 | 2014-03-31 20:26:03 +0000 | [diff] [blame] | 42 | color brightblue "//.*" |
| 43 | color brightblue start="/\*" end="\*/" |
| 44 | |
Benno Schulenberg | 5e901c4 | 2014-04-08 12:09:29 +0000 | [diff] [blame] | 45 | # Trailing whitespace. |
| 46 | color ,green "[[:space:]]+$" |