2020-04-20 20:15:43 +03:00
|
|
|
## Syntax highlighting for Go.
|
2014-05-17 00:21:34 +04:00
|
|
|
|
2020-12-10 17:48:14 +03:00
|
|
|
## Original author: Robert Clausecker
|
|
|
|
## License: CC0 (public domain)
|
|
|
|
|
2018-02-07 13:25:46 +03:00
|
|
|
syntax go "\.go$"
|
2016-05-25 23:13:50 +03:00
|
|
|
comment "//"
|
2014-04-01 00:26:03 +04:00
|
|
|
|
2019-11-04 21:52:35 +03:00
|
|
|
formatter gofmt -w
|
|
|
|
|
2014-04-08 16:09:29 +04:00
|
|
|
# Types.
|
|
|
|
color green "\<(bool|u?int(8|16|32|64)?|float(32|64)|complex(64|128)|byte|rune|uintptr|string|error)\>"
|
2020-05-25 00:20:38 +03:00
|
|
|
color green "\<(chan|const|func|interface|map|struct|type|var)\>"
|
2021-04-27 12:18:41 +03:00
|
|
|
color green "<-[[:blank:]]*chan\>|\<chan[[:blank:]]*<-"
|
2014-04-01 00:26:03 +04:00
|
|
|
|
2014-04-08 16:09:29 +04:00
|
|
|
# Predefined functions.
|
|
|
|
color blue "\<(append|cap|close|complex|copy|delete|imag|len|make|new|panic|print|println|real|recover)\>"
|
|
|
|
|
|
|
|
# Control structures.
|
|
|
|
color brightyellow "\<(case|default|defer|else|for|go|if|range|select|switch)\>"
|
|
|
|
|
|
|
|
# Control flow.
|
|
|
|
color magenta "\<(break|continue|fallthrough|goto|return)\>"
|
|
|
|
|
|
|
|
# Declarations.
|
|
|
|
color brightcyan "\<(package|import)\>"
|
|
|
|
|
|
|
|
# Literals.
|
2021-10-27 12:06:40 +03:00
|
|
|
color red "\<(true|false|nil|iota|_)\>"
|
2021-11-15 17:56:11 +03:00
|
|
|
color red "\<([1-9][0-9]*|0[0-7]*|0[xX][[:xdigit:]]+)\>"
|
2018-01-08 09:31:58 +03:00
|
|
|
color red "\<[0-9]+\.[0-9]*([eE][+-]?[0-9]+)?i?\>"
|
|
|
|
color red "\<[0-9]+[eE][+-]?[0-9]+i?\>"
|
|
|
|
color red "\B\.[0-9]+([eE][+-]?[0-9]+)?i?\>"
|
|
|
|
color red "\<[0-9]+i\>"
|
2014-04-01 00:26:03 +04:00
|
|
|
|
2014-04-08 16:09:29 +04:00
|
|
|
# Strings and characters; slightly fuzzy.
|
2021-10-27 10:45:42 +03:00
|
|
|
color red ""([^"\]|\\.)*"|'([^'\]|\\.)+'"
|
|
|
|
color red start=""([^"\]|\\.)*\\[[:blank:]]*$" end="^([^"\]|\\.)*""
|
2014-04-01 00:26:03 +04:00
|
|
|
|
2014-04-08 16:09:29 +04:00
|
|
|
# Comments.
|
2014-04-01 00:26:03 +04:00
|
|
|
color brightblue "//.*"
|
|
|
|
color brightblue start="/\*" end="\*/"
|
|
|
|
|
2020-05-25 00:20:38 +03:00
|
|
|
# Special comments.
|
2021-04-27 12:18:41 +03:00
|
|
|
color brightcyan "//[[:blank:]]*\+build[[:blank:]]+(([a-zA-Z_0-9]+[[:blank:]]*)+,[[:blank:]]*)*[a-zA-Z_0-9]+"
|
2020-05-25 00:20:38 +03:00
|
|
|
|
2014-04-08 16:09:29 +04:00
|
|
|
# Trailing whitespace.
|
|
|
|
color ,green "[[:space:]]+$"
|