From 5e901c41e82c101f914a42c1325e35d431d6891c Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Tue, 8 Apr 2014 12:09:29 +0000 Subject: [PATCH] Extending the syntax highlighting for Go lang. Tweaked version of file submitted by Robert Clausecker. git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4748 35c25a1d-7b9e-4130-9fde-d3aeb78583b8 --- ChangeLog | 2 ++ doc/syntax/go.nanorc | 45 ++++++++++++++++++++++++++++++++------------ 2 files changed, 35 insertions(+), 12 deletions(-) diff --git a/ChangeLog b/ChangeLog index 998cb2b4..7e335de6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -4,6 +4,8 @@ * src/rcfile.c (parse_binding): Uppercase only the first two or three characters of the key name, in order to preserve ^Space and M-Space, so they can be unbound. Fixes Savannah bug #41940. + * doc/syntax/go.nanorc: Extend the syntax highlighting for Go lang, + from the submission by Robert Clausecker . 2014-04-07 Benno Schulenberg * src/{proto.h,global.c,text.c}: Keep a pointer to the Uncut item in diff --git a/doc/syntax/go.nanorc b/doc/syntax/go.nanorc index 8573a87c..b60c72f4 100644 --- a/doc/syntax/go.nanorc +++ b/doc/syntax/go.nanorc @@ -1,21 +1,42 @@ -## Here is an example for Python. +## Here is an example for Go. ## syntax "go" "\.go$" -header "^#!.*/python[-0-9._]*" -icolor brightblue "def [0-9A-Z_]+" -color brightcyan "\<(break|default|func|interface|select|case|defer|go|map|struct|chan|else|goto|package|switch|const|fallthrough|if|range|type|continue|for|import|return|var)\>" +# Types. +color green "\<(bool|u?int(8|16|32|64)?|float(32|64)|complex(64|128)|byte|rune|uintptr|string|error)\>" +color green "\<((<-[[:space:]]*)chan|chan[[:space:]]*<-|const|func|interface|map|struct|type|var)\>" -## String highlighting. You will in general want your comments and -## strings to come last, because syntax highlighting rules will be -## applied in the order they are read in. -color brightyellow "<[^= ]*>" ""(\\.|[^"])*"" -## -## This string is VERY resource intensive! -color brightyellow start=""(\\.|[^"])*\\[[:space:]]*$" end="^(\\.|[^"])*"" +# 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)\>" +color brightcyan "//[[:space:]]*\+build[[:space:]]+(([a-zA-Z_0-9]+[[:space:]]*)+,[[:space:]]*)*[a-zA-Z_0-9]+" + +# Literals. +color red "\<[0-9]+\.[0-9]*([Ee][+-][0-9]+)?i?\>" +color red "\<[0-9]+[Ee][+-][0-9]+i?\>" +color red "\<\.[0-9]+([Ee][+-][0-9]+)?i?\>" +color red "\<[0-9]+i\>" +color red "\<[1-9][0-9]*\>" +color red "\<0[0-7]*\>" +icolor red "\<0x[0-9a-f]+\>" +# Strings and characters; slightly fuzzy. +color red "\<(true|false|nil|iota|_)\>" +color red "'(\\.|[^'])+'" +color red ""(\\.|[^"])*"" +color red start=""(\\.|[^"])*\\[[:space:]]*$" end="^(\\.|[^"])*"" -## Comment highlighting +# Comments. color brightblue "//.*" color brightblue start="/\*" end="\*/" +# Trailing whitespace. +color ,green "[[:space:]]+$" -- 2.39.5