[PATCH] Improved iterator matching, show whitespace errors
Tilman Sauerbeck
tilman at code-monkey.de
Tue Feb 8 14:31:48 EST 2005
Hi,
I sent these two patches to Doug Kearns 1-2 weeks ago, but I didn't get
any feedback, so I'm posting them here now :)
ruby.vim-iterator.diff improves the regex for iterators, so that it now
correctly recognizes and hilights |(foo, bar)| for example.
The 2nd patch makes it possible to have vim hilight whitespace errors
such as trailing whitespace or mixed tabs/spaces.
The regular expressions were copied from c.vim.
Please comment ;)
--
Regards,
Tilman
-------------- next part --------------
Index: syntax/ruby.vim
===================================================================
RCS file: /var/cvs/vim-ruby/vim-ruby/syntax/ruby.vim,v
retrieving revision 1.39
diff -u -r1.39 ruby.vim
--- syntax/ruby.vim 27 Nov 2004 14:44:37 -0000 1.39
+++ syntax/ruby.vim 29 Jan 2005 21:13:33 -0000
@@ -59,7 +59,7 @@
syn match rubySymbol ":\@<!:\$\%(-.\|[`~<=>_,;:!?/.'"@$*\&+0]\)"
syn match rubySymbol ":\@<!:\%(\$\|@@\=\)\=\h\w*[?!=]\="
syn region rubySymbol start=":\@<!:\"" end="\"" skip="\\\\\|\\\""
- syn match rubyIterator "|[ ,a-zA-Z0-9_*]\+|" display
+ syn match rubyIterator "|[ ,a-zA-Z0-9_*()]\+|" display
syn match rubyPredefinedVariable #$[!$&"'*+,./0:;<=>?@\_`~1-9]#
syn match rubyPredefinedVariable "$-[0FIKadilpvw]" display
-------------- next part --------------
Index: syntax/ruby.vim
===================================================================
RCS file: /var/cvs/vim-ruby/vim-ruby/syntax/ruby.vim,v
retrieving revision 1.39
diff -u -r1.39 ruby.vim
--- syntax/ruby.vim 27 Nov 2004 14:44:37 -0000 1.39
+++ syntax/ruby.vim 1 Feb 2005 20:11:09 -0000
@@ -28,6 +28,15 @@
setlocal foldmethod=syntax
endif
+if exists("ruby_space_errors")
+ if !exists("ruby_no_trail_space_error")
+ syn match rubySpaceError display excludenl "\s\+$"
+ endif
+ if !exists("ruby_no_tab_space_error")
+ syn match rubySpaceError display " \+\t"me=e-1
+ endif
+endif
+
" Expression Substitution and Backslash Notation
syn match rubyEscape "\\\\\|\\[abefnrstv]\|\\\o\{1,3}\|\\x\x\{1,2}" contained display
syn match rubyEscape "\%(\\M-\\C-\|\\C-\\M-\|\\M-\\c\|\\c\\M-\|\\c\|\\C-\|\\M-\)\%(\\\o\{1,3}\|\\x\x\{1,2}\|\\\=\S\)" contained display
@@ -184,8 +193,8 @@
" Comments and Documentation
syn match rubySharpBang "\%^#!.*" display
syn keyword rubyTodo FIXME NOTE TODO XXX contained
-syn match rubyComment "#.*" contains=rubySharpBang,rubyTodo, at Spell
-syn region rubyDocumentation start="^=begin" end="^=end.*$" contains=rubyTodo, at Spell fold
+syn match rubyComment "#.*" contains=rubySharpBang,rubyTodo,rubySpaceError, at Spell
+syn region rubyDocumentation start="^=begin" end="^=end.*$" contains=rubyTodo,rubySpaceError, at Spell fold
" Note: this is a hack to prevent 'keywords' being highlighted as such when called as methods
syn match rubyKeywordAsMethod "\%(\%(\.\@<!\.\)\|::\)\_s*\%(alias\|and\|begin\|break\|case\|class\|def\|defined\|do\|else\)\>" transparent contains=NONE
@@ -254,6 +263,8 @@
HiLink rubyStringDelimiter Delimiter
HiLink rubyString String
HiLink rubyTodo Todo
+ HiLink rubySpaceError rubyError
+ HiLink rubyError Error
delcommand HiLink
endif
More information about the vim-ruby-devel
mailing list