]> git.wh0rd.org Git - nano.git/commitdiff
Extending the syntax highlighting for Go lang.
authorBenno Schulenberg <bensberg@justemail.net>
Tue, 8 Apr 2014 12:09:29 +0000 (12:09 +0000)
committerBenno Schulenberg <bensberg@justemail.net>
Tue, 8 Apr 2014 12:09:29 +0000 (12:09 +0000)
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
doc/syntax/go.nanorc

index 998cb2b417a710c2349ed5a533d178193490bdb9..7e335de6df3d1aa07712b5e97c9daaab97be1aa6 100644 (file)
--- 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
index 8573a87c480f2367f076ab14c674775686b3e6bc..b60c72f46fbfbbbd503f2998f6046b89d69a6569 100644 (file)
@@ -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:]]+$"