PATCH: differentiate between class methods and constants

Doug Kearns dougkearns at gmail.com
Tue Aug 2 10:54:49 EDT 2005


This allows the highlighting to differentiate between constants and
capitalized class methods invoked using the 'scope operator'.

Regards,
Doug


Index: syntax/ruby.vim
===================================================================
RCS file: /var/cvs/vim-ruby/vim-ruby/syntax/ruby.vim,v
retrieving revision 1.50
diff -u -r1.50 ruby.vim
--- syntax/ruby.vim	1 Aug 2005 15:27:38 -0000	1.50
+++ syntax/ruby.vim	2 Aug 2005 14:49:09 -0000
@@ -68,7 +68,7 @@
 syn match rubyLocalVariableOrMethod "[_[:lower:]][_[:alnum:]]*[?!=]\=" contains=NONE display transparent
 
 if !exists("ruby_no_identifiers")
-  syn match  rubyConstant		"\%(::\)\=\zs\u\w*"	display
+  syn match  rubyConstant               "\%(\%(\.\@<!\.\)\@<!\|::\)\_s*\zs\u\w*\>\%(\s*(\)\@!" display
   syn match  rubyClassVariable		"@@\h\w*"		display
   syn match  rubyInstanceVariable	"@\h\w*"		display
   syn match  rubyGlobalVariable		"$\%(\h\w*\|-.\)"
@@ -84,12 +84,12 @@
   syn match rubyPredefinedVariable "$-[0FIKadilpvw]\>"									display
   syn match rubyPredefinedVariable "$\%(deferr\|defout\|stderr\|stdin\|stdout\)\>"					display
   syn match rubyPredefinedVariable "$\%(DEBUG\|FILENAME\|KCODE\|LOAD_PATH\|SAFE\|VERBOSE\)\>"				display
-  syn match rubyPredefinedConstant "\<\%(::\)\=\zs\%(MatchingData\|ARGF\|ARGV\|ENV\)\>"					display
-  syn match rubyPredefinedConstant "\<\%(::\)\=\zs\%(DATA\|FALSE\|NIL\|RUBY_PLATFORM\|RUBY_RELEASE_DATE\)\>"		display
-  syn match rubyPredefinedConstant "\<\%(::\)\=\zs\%(RUBY_VERSION\|STDERR\|STDIN\|STDOUT\|TOPLEVEL_BINDING\|TRUE\)\>"	display
+  syn match rubyPredefinedConstant "\%(\%(\.\@<!\.\)\@<!\|::\)\_s*\zs\%(MatchingData\|ARGF\|ARGV\|ENV\)\>\%(\s*(\)\@!"
+  syn match rubyPredefinedConstant "\%(\%(\.\@<!\.\)\@<!\|::\)\_s*\zs\%(DATA\|FALSE\|NIL\|RUBY_PLATFORM\|RUBY_RELEASE_DATE\)\>\%(\s*(\)\@!"
+  syn match rubyPredefinedConstant "\%(\%(\.\@<!\.\)\@<!\|::\)\_s*\zs\%(RUBY_VERSION\|STDERR\|STDIN\|STDOUT\|TOPLEVEL_BINDING\|TRUE\)\>\%(\s*(\)\@!"
   "Obsolete Global Constants
-  "syn match rubyPredefinedConstant "\<\%(::\)\=\zs\%(PLATFORM\|RELEASE_DATE\|VERSION\)\>"
-  "syn match rubyPredefinedConstant "\<\%(::\)\=\zs\%(NotImplementError\)\>"
+  "syn match rubyPredefinedConstant "\%(::\)\=\zs\%(PLATFORM\|RELEASE_DATE\|VERSION\)\>"
+  "syn match rubyPredefinedConstant "\%(::\)\=\zs\%(NotImplementError\)\>"
 else
   syn match NONE +$['"]+
 endif


More information about the vim-ruby-devel mailing list