PATCH: highlight comment blocks

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

PATCH: highlight comment blocks

Doug Kearns
This enables folding of multiline comment blocks and is enabled by
default. It can be disabled by defining the ruby_no_comment_fold
variable.

I'm going to have a look at simplifying the syntax based folding. It
seems to me that it might be best to reduce it to simply folding
module/class/method definitions, comment blocks, and __END__ data
blocks.

Would anyone object to longer having the rest folded? If so, that too
could be configurable. ;-)

Any thoughts?

Thanks,
Doug


Index: syntax/ruby.vim
===================================================================
RCS file: /var/cvs/vim-ruby/vim-ruby/syntax/ruby.vim,v
retrieving revision 1.87
retrieving revision 1.89
diff -u -r1.87 -r1.89
--- syntax/ruby.vim 8 May 2006 15:25:57 -0000 1.87
+++ syntax/ruby.vim 9 May 2006 11:39:41 -0000 1.89
@@ -1,7 +1,7 @@
 " Vim syntax file
 " Language: Ruby
 " Maintainer: Doug Kearns <[hidden email]>
-" Info: $Id: ruby.vim,v 1.87 2006/05/08 15:25:57 dkearns Exp $
+" Info: $Id: ruby.vim,v 1.89 2006/05/09 11:39:41 dkearns Exp $
 " URL: http://vim-ruby.rubyforge.org
 " Anon CVS: See above site
 " Release Coordinator: Doug Kearns <[hidden email]>
@@ -211,7 +211,10 @@
 syn match   rubySharpBang     "\%^#!.*" display
 syn keyword rubyTodo      FIXME NOTE TODO XXX contained
 syn match   rubyComment       "#.*" contains=rubySharpBang,rubySpaceError,rubyTodo,@Spell
-syn region  rubyDocumentation start="^=begin" end="^=end.*$" contains=rubySpaceError,rubyTodo,@Spell fold
+if !exists("ruby_no_comment_fold")
+  syn match   rubyMultiLineComment "\(^\s*#.*\n\)\{2,}" contains=rubyComment transparent fold
+  syn region  rubyDocumentation start="^=begin" end="^=end.*$" contains=rubySpaceError,rubyTodo,@Spell fold
+endif
 
 " Note: this is a hack to prevent 'keywords' being highlighted as such when called as methods with an explicit receiver
 syn match rubyKeywordAsMethod "\%(\%(\.\@<!\.\)\|::\)\_s*\%(alias\|and\|begin\|break\|case\|class\|def\|defined\|do\|else\)\>" transparent contains=NONE
_______________________________________________
vim-ruby-devel mailing list
[hidden email]
http://rubyforge.org/mailman/listinfo/vim-ruby-devel
Reply | Threaded
Open this post in threaded view
|

Re: PATCH: highlight comment blocks

Gavin Sinclair
On 5/9/06, Doug Kearns <[hidden email]> wrote:

> This enables folding of multiline comment blocks and is enabled by
> default. It can be disabled by defining the ruby_no_comment_fold
> variable.
>
> I'm going to have a look at simplifying the syntax based folding. It
> seems to me that it might be best to reduce it to simply folding
> module/class/method definitions, comment blocks, and __END__ data
> blocks.
>
> Would anyone object to longer having the rest folded? If so, that too
> could be configurable. ;-)
>
> Any thoughts?

I don't use folding much, but I like the word "simplify" and
variations thereof :)

I also think that in Ruby, a little folding is better than a lot.
Most loops, etc. are only a few lines long, so it would be a pain to
unfold them.

So I like the gist of what you're doing, without being able to comment
on specifics.

Gavin

BTW, multiline comments should only be folded if they have at least,
say, 4 lines?  Just a hunch.

_______________________________________________
vim-ruby-devel mailing list
[hidden email]
http://rubyforge.org/mailman/listinfo/vim-ruby-devel
Reply | Threaded
Open this post in threaded view
|

Re: PATCH: highlight comment blocks

Doug Kearns
On Thu, May 11, 2006 at 05:37:01PM +1000, Gavin Sinclair wrote:

<snip>

> I also think that in Ruby, a little folding is better than a lot.
> Most loops, etc. are only a few lines long, so it would be a pain to
> unfold them.

Well there seem to be some folding 'fiends' out there that actually want
more, not less, by default.
 
> So I like the gist of what you're doing, without being able to comment
> on specifics.
>
> Gavin
>
> BTW, multiline comments should only be folded if they have at least,
> say, 4 lines?  Just a hunch.

Yes. I was thinking three lines but I'm not sure... Oooh, more options?

Regards,
Doug
_______________________________________________
vim-ruby-devel mailing list
[hidden email]
http://rubyforge.org/mailman/listinfo/vim-ruby-devel