commit 5e901c41e82c101f914a42c1325e35d431d6891c
parent f7c5eeed2d5601155d001c2aa4b4de5c9e1ceb3c
Author: Benno Schulenberg <bensberg@justemail.net>
Date: Tue, 8 Apr 2014 12:09:29 +0000
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
Diffstat:
2 files changed, 35 insertions(+), 12 deletions(-)
diff --git 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 <fuzxxl@Savannah>.
2014-04-07 Benno Schulenberg <bensberg@justemail.net>
* 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
@@ -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:]]+$"