nano/syntax/go.nanorc
Ryan Westlund 3480518a5c syntax: go: highlight the chan keyword, and the special +build comment
This fixes https://savannah.gnu.org/bugs/?58424
Reported-by: Ryan Westlund <rlwestlund@gmail.com>

Signed-off-by: Ryan Westlund <rlwestlund@gmail.com>
2020-05-26 16:50:31 +02:00

47 lines
1.3 KiB
Plaintext

## Syntax highlighting for Go.
syntax go "\.go$"
comment "//"
formatter gofmt -w
# Types.
color green "\<(bool|u?int(8|16|32|64)?|float(32|64)|complex(64|128)|byte|rune|uintptr|string|error)\>"
color green "\<(chan|const|func|interface|map|struct|type|var)\>"
color green "<-[[:space:]]*chan\>|\<chan[[:space:]]*<-"
# 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.
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\>"
# Strings and characters; slightly fuzzy.
color red "\<(true|false|nil|iota|_)\>"
color red "'(\\.|[^'])+'"
color red ""(\\.|[^"])*""
color red start=""(\\.|[^"])*\\[[:space:]]*$" end="^(\\.|[^"])*""
# Comments.
color brightblue "//.*"
color brightblue start="/\*" end="\*/"
# Special comments.
color brightcyan "//[[:space:]]*\+build[[:space:]]+(([a-zA-Z_0-9]+[[:space:]]*)+,[[:space:]]*)*[a-zA-Z_0-9]+"
# Trailing whitespace.
color ,green "[[:space:]]+$"