2020-04-20 17:15:43 +00:00
|
|
|
## Syntax highlighting for Go.
|
2014-05-16 20:21:34 +00:00
|
|
|
|
2018-02-07 10:25:46 +00:00
|
|
|
syntax go "\.go$"
|
2016-05-25 20:13:50 +00:00
|
|
|
comment "//"
|
2014-03-31 20:26:03 +00:00
|
|
|
|
2019-11-04 18:52:35 +00:00
|
|
|
formatter gofmt -w
|
|
|
|
|
2014-04-08 12:09:29 +00:00
|
|
|
# Types.
|
|
|
|
color green "\<(bool|u?int(8|16|32|64)?|float(32|64)|complex(64|128)|byte|rune|uintptr|string|error)\>"
|
2020-05-24 21:20:38 +00:00
|
|
|
color green "\<(chan|const|func|interface|map|struct|type|var)\>"
|
|
|
|
color green "<-[[:space:]]*chan\>|\<chan[[:space:]]*<-"
|
2014-03-31 20:26:03 +00:00
|
|
|
|
2014-04-08 12:09:29 +00: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.
|
2018-01-08 06:31:58 +00:00
|
|
|
color red "\<([1-9][0-9]*|0[0-7]*|0[xX][0-9A-Fa-f]+)\>"
|
|
|
|
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-03-31 20:26:03 +00:00
|
|
|
|
2014-04-08 12:09:29 +00:00
|
|
|
# Strings and characters; slightly fuzzy.
|
|
|
|
color red "\<(true|false|nil|iota|_)\>"
|
|
|
|
color red "'(\\.|[^'])+'"
|
|
|
|
color red ""(\\.|[^"])*""
|
|
|
|
color red start=""(\\.|[^"])*\\[[:space:]]*$" end="^(\\.|[^"])*""
|
2014-03-31 20:26:03 +00:00
|
|
|
|
2014-04-08 12:09:29 +00:00
|
|
|
# Comments.
|
2014-03-31 20:26:03 +00:00
|
|
|
color brightblue "//.*"
|
|
|
|
color brightblue start="/\*" end="\*/"
|
|
|
|
|
2020-05-24 21:20:38 +00:00
|
|
|
# Special comments.
|
|
|
|
color brightcyan "//[[:space:]]*\+build[[:space:]]+(([a-zA-Z_0-9]+[[:space:]]*)+,[[:space:]]*)*[a-zA-Z_0-9]+"
|
|
|
|
|
2014-04-08 12:09:29 +00:00
|
|
|
# Trailing whitespace.
|
|
|
|
color ,green "[[:space:]]+$"
|