From 421f4b36b27154f14e8f9bb89c261ae2d2119a82 Mon Sep 17 00:00:00 2001 From: Zach DeCook Date: Tue, 14 Jul 2020 17:00:56 -0400 Subject: [PATCH 1/3] * PHP: Improve operator coloring, support Nowdocs, Heredocs --- php.nanorc | 46 +++++++++++++++++++++++++++++++++------------- 1 file changed, 33 insertions(+), 13 deletions(-) diff --git a/php.nanorc b/php.nanorc index de27228..7e2a3ea 100644 --- a/php.nanorc +++ b/php.nanorc @@ -3,35 +3,53 @@ syntax "PHP" "\.php[2345s~]?$|\.module$" magic "PHP script" comment "//" color white start="<\?(php|=)?" end="\?>" -# Functions -color brightblue "([a-zA-Z0-9_-]*)\(" # Constructs color brightblue "(class|extends|goto) ([a-zA-Z0-9_]*)" -color green "[^a-z0-9_-]{1}(var|class|function|echo|case|break|default|exit|switch|if|else|elseif|endif|foreach|endforeach|@|while|public|private|protected|return|true|false|null|TRUE|FALSE|NULL|const|static|extends|as|array|require|include|require_once|include_once|define|do|continue|declare|goto|print|in|namespace|use)[^a-z0-9_-]{1}" +color brightblue "[^a-z0-9_-]{1}(var|class|function|echo|case|break|default|exit|switch|if|else|elseif|endif|foreach|endforeach|@|while|public|private|protected|return|true|false|null|TRUE|FALSE|NULL|const|static|extends|as|array|require|include|require_once|include_once|define|do|continue|declare|goto|print|in|namespace|use)[^a-z0-9_-]{1}" color brightblue "[a-zA-Z0-9_]+:" # Variables -color white "\$[a-zA-Z_0-9$]*|[=!<>]" -color white "\->[a-zA-Z_0-9$]*|[=!<>]" +color green "\$[a-zA-Z_0-9$]*|[=!<>]" +color green "\->[a-zA-Z_0-9$]*|[=!<>]" +# Functions +color brightblue "([a-zA-Z0-9_-]*)\(" +# Special values +color brightmagenta "[^a-z0-9_-]{1}(true|false|null|TRUE|FALSE|NULL)$" +color brightmagenta "[^a-z0-9_-]{1}(true|false|null|TRUE|FALSE|NULL)[^a-z0-9_-]{1}" # Special Characters color yellow "[.,{}();]" -color yellow "\[" -color yellow "\]" -color yellow "[=][^>]" +color cyan "\[" +color cyan "\]" # Numbers color magenta "[+-]*([0-9]\.)*[0-9]+([eE][+-]?([0-9]\.)*[0-9])*" color magenta "0x[0-9a-zA-Z]*" # Special Variables color brightblue "(\$this|parent::|self::|\$this->)" +color magenta ";" +# Comparison operators +color yellow "(<|>)" +# Assignment operator +color brightblue "=" # Bitwise Operations -color magenta "(\;|\||\^){1}" +color magenta "(&|\||\^)" +color magenta "(<<|>>)" +# Comparison operators +color yellow "(==|===|!=|<>|!==|<=|>=|<=>)" +# Logical Operators +color yellow "( and | or | xor |!|&&|\|\|)" # And/Or/SRO/etc -color green "(\;\;|\|\||::|=>|->)" +color green "(\;\;|\|\||::|=>)" +color cyan "->" # Online Comments -color brightyellow "(#.*|//.*)$" -# STRINGS! -color red "('[^']*')|(\"[^\"]*\")" +color brightyellow "^(#.*|//.*)$" +color brightyellow "[ | ](#.*|//.*)$" +# Double quoted STRINGS! +color red "(\"[^\"]*\")" +# Heredoc (typically ends with a semicolon). +color red start="<<<['\"]?[A-Z][A-Z0-9_]*['\"]?" end="^[A-Z][A-Z0-9_]*;" # Inline Variables color white "\{\$[^}]*\}" +# Single quoted string +color red "('[^']*')" # PHP Tags color red "(<\?(php)?|\?>)" # General HTML @@ -40,3 +58,5 @@ color red start="\?>" end="<\?(php|=)?" color ,green "[[:space:]]+$" # multi-line comments color brightyellow start="/\*" end="\*/" +# Nowdoc +color red start="<<<'[A-Z][A-Z0-9_]*'" end="^[A-Z][A-Z0-9_]*;" From d307f5a75b3a8ac8cab564b45f6f9fe35dc966d0 Mon Sep 17 00:00:00 2001 From: Zach DeCook Date: Tue, 14 Jul 2020 17:20:52 -0400 Subject: [PATCH 2/3] * PHP: Decrease priority of inline comment --- php.nanorc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/php.nanorc b/php.nanorc index 7e2a3ea..26e5cb6 100644 --- a/php.nanorc +++ b/php.nanorc @@ -39,9 +39,6 @@ color yellow "( and | or | xor |!|&&|\|\|)" # And/Or/SRO/etc color green "(\;\;|\|\||::|=>)" color cyan "->" -# Online Comments -color brightyellow "^(#.*|//.*)$" -color brightyellow "[ | ](#.*|//.*)$" # Double quoted STRINGS! color red "(\"[^\"]*\")" # Heredoc (typically ends with a semicolon). @@ -50,6 +47,9 @@ color red start="<<<['\"]?[A-Z][A-Z0-9_]*['\"]?" end="^[A-Z][A-Z0-9_]*;" color white "\{\$[^}]*\}" # Single quoted string color red "('[^']*')" +# Online Comments +color brightyellow "^(#.*|//.*)$" +color brightyellow "[ | ](#.*|//.*)$" # PHP Tags color red "(<\?(php)?|\?>)" # General HTML From e50fb095bfea449a60a62a9a28e007f76476ee51 Mon Sep 17 00:00:00 2001 From: Zach DeCook Date: Wed, 15 Jul 2020 14:50:36 -0400 Subject: [PATCH 3/3] * PHP: Make paamayim nekodotayim same color as arrow --- php.nanorc | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/php.nanorc b/php.nanorc index 26e5cb6..693695f 100644 --- a/php.nanorc +++ b/php.nanorc @@ -37,8 +37,7 @@ color yellow "(==|===|!=|<>|!==|<=|>=|<=>)" # Logical Operators color yellow "( and | or | xor |!|&&|\|\|)" # And/Or/SRO/etc -color green "(\;\;|\|\||::|=>)" -color cyan "->" +color cyan "(\;\;|\|\||::|=>|->)" # Double quoted STRINGS! color red "(\"[^\"]*\")" # Heredoc (typically ends with a semicolon).