From dougkearns at gmail.com Mon Oct 23 10:54:09 2006 From: dougkearns at gmail.com (Doug Kearns) Date: Tue, 24 Oct 2006 00:54:09 +1000 Subject: A slight improvement to syntax/eruby.vim In-Reply-To: References: Message-ID: <20061023145409.GA24054@localhost.localdomain> On Mon, Aug 14, 2006 at 11:10:39PM +0200, Nikolai Weibull wrote: > Here's a totally lame non-patch for syntax/eruby.vim: > > syn region erubyBlock matchgroup=erubyDelimiter start="<%%\@!-\=" > end="-\=%>" contains=@rubyTop containedin=ALLBUT, at erubyRegions > syn region erubyExpression matchgroup=erubyDelimiter start="<%=" > end="-\=%>" contains=@rubyTop containedin=ALLBUT, at erubyRegions > syn region erubyComment matchgroup=erubyDelimiter start="<%#" > end="-\=%>" contains=rubyTodo, at Spell containedin=ALLBUT, at erubyRegions > keepend > > One may specify the "trim mode" to be, well, "trim" using "-" on the delimiters. Applied. Thanks! Regards, Doug From hgs at dmu.ac.uk Wed Oct 25 12:39:09 2006 From: hgs at dmu.ac.uk (Hugh Sasse) Date: Wed, 25 Oct 2006 17:39:09 +0100 (WEST) Subject: [OT] mixed lang metaprogramming w/ vim? Message-ID: I'm generating (not quite repetitive enough to refactor) C code from Ruby, so there are lots of strings with C code in them, but with Ruby 'escapes' #{@variable} in them. I can't find much about how to get vim to highlight the C bits in a more C like way, and I'm not sure how to make vim flip between languages within a file for the more general case. Does anyone have any URLs that are "Not to be missed!" on this please? I know that one's mileage will vary with such an approach, but if I can reduce the errors by better highlighting that would be good. Is there a better way to do this sort of thing which would avoid my having to torture Vim into doing this? Hugh From dougkearns at gmail.com Thu Oct 26 11:47:35 2006 From: dougkearns at gmail.com (Doug Kearns) Date: Fri, 27 Oct 2006 01:47:35 +1000 Subject: [OT] mixed lang metaprogramming w/ vim? In-Reply-To: References: Message-ID: <20061026154735.GF2760@localhost.localdomain> G'day Hugh, On Wed, Oct 25, 2006 at 05:39:09PM +0100, Hugh Sasse wrote: > I'm generating (not quite repetitive enough to refactor) C code from > Ruby, so there are lots of strings with C code in them, but with > Ruby 'escapes' #{@variable} in them. I can't find much about how to > get vim to highlight the C bits in a more C like way, and I'm not > sure how to make vim flip between languages within a file for the > more general case. Does anyone have any URLs that are "Not to be > missed!" on this please? Nope. > I know that one's mileage will vary with > such an approach, but if I can reduce the errors by better highlighting > that would be good. This is a bit of a '2 AM solution' so I wish you luck with it. :-) Add the following to your ~/.vim/after/syntax/ruby.vim -------------------------------------------------------------------------------- unlet b:current_syntax syn include @cTop syntax/c.vim let b:current_syntax = "ruby" syn region rubyCString start=+\%(\%(class\s*\|\%(\.\|::\)\)\_s*\)\@ int main(void) { printf("#{message}"); return #{exit_status}; } CSTRING end if __FILE__ == $0 generate_hello_world end -------------------------------------------------------------------------------- As you can see Ruby interpolation sequences aren't being highlighted in C strings yet but hopefully this will get you started. > Is there a better way to do this sort of thing which would avoid my > having to torture Vim into doing this? Not that I can think of... Regards, Doug From hgs at dmu.ac.uk Fri Oct 27 09:43:34 2006 From: hgs at dmu.ac.uk (Hugh Sasse) Date: Fri, 27 Oct 2006 14:43:34 +0100 (WEST) Subject: [OT] mixed lang metaprogramming w/ vim? In-Reply-To: <20061026154735.GF2760@localhost.localdomain> References: <20061026154735.GF2760@localhost.localdomain> Message-ID: On Fri, 27 Oct 2006, Doug Kearns wrote: > G'day Hugh, > > On Wed, Oct 25, 2006 at 05:39:09PM +0100, Hugh Sasse wrote: > > I'm generating (not quite repetitive enough to refactor) C code from > > Ruby, so there are lots of strings with C code in them, but with > > Ruby 'escapes' #{@variable} in them. I can't find much about how to > > get vim to highlight the C bits in a more C like way, and I'm not > > sure how to make vim flip between languages within a file for the > > more general case. Does anyone have any URLs that are "Not to be > > missed!" on this please? > > Nope. > > > I know that one's mileage will vary with > > such an approach, but if I can reduce the errors by better highlighting > > that would be good. > > This is a bit of a '2 AM solution' so I wish you luck with it. :-) That's impressive stuff for 2am! > > Add the following to your ~/.vim/after/syntax/ruby.vim > > -------------------------------------------------------------------------------- > unlet b:current_syntax > syn include @cTop syntax/c.vim > let b:current_syntax = "ruby" > > syn region rubyCString start=+\%(\%(class\s*\|\%(\.\|::\)\)\_s*\)\@ syn region rubyCString start=+\%(\%(class\s*\|\%(\.\|::\)\)\_s*\)\@ syn region rubyCString start=+\%(\%(class\s*\|\%(\.\|::\)\)\_s*\)\@ syn region rubyCString start=+\%(\%(class\s*\|\%(\.\|::\)\)\_s*\)\@ > syn region rubyCString start=+\%(\%(class\s*\|\%(\.\|::\)\)\_s*\)\@ syn region rubyCString start=+\%(\%(class\s*\|\%(\.\|::\)\)\_s*\)\@ syn region rubyCString start=+\%(\%(class\s*\|\%(\.\|::\)\)\_s*\)\@ syn region rubyCString start=+\%(\%(class\s*\|\%(\.\|::\)\)\_s*\)\@ > syn cluster cCommentGroup contains=cTodo,rubyInterpolation > -------------------------------------------------------------------------------- I've wrapped that in a function and it seems to work for me. > > and you'll be able to highlight C code and interpolated Ruby expressions > in 'heredocs' delimited with CSTRING. For example: > > -------------------------------------------------------------------------------- > puts <<-CSTRING > > /* [#{header}] */ > #include > int main(void) { > printf("#{message}"); > return #{exit_status}; > } > > CSTRING > -------------------------------------------------------------------------------- > > As you can see Ruby interpolation sequences aren't being highlighted in > C strings yet but hopefully this will get you started. It would be nice to get that as well, but I'll need to study this more to be able to do that. > > > Is there a better way to do this sort of thing which would avoid my > > having to torture Vim into doing this? > > Not that I can think of... > > Regards, > Doug Thank you, Hugh From hgs at dmu.ac.uk Tue Oct 31 15:05:48 2006 From: hgs at dmu.ac.uk (Hugh Sasse) Date: Tue, 31 Oct 2006 20:05:48 +0000 (WET) Subject: Metaprogramming, mixed languages, and Vim. In-Reply-To: <4542938B.8000603@skynet.be> References: <1ddea54e0610260839v29536bb3ke46744867efea6f1@mail.gmail.com> <45411905.9090202@skynet.be> <4542938B.8000603@skynet.be> Message-ID: Here is what I ended up using, thanks to "A.J.Mechelynck" and "A. S. Budden" on the Vim list and Doug Kearns (what he called "a bit of a '2 AM solution'" -- and it works fine!) on the Vim-Ruby list. The first function highlights the %Q{....} quotes in Ruby as C code, the second does it for here documents of the form <<-CSTRING ... CSTRING Here they are: " To MetaProgram C using Ruby function RubyMetaC1() :unlet! b:current_syntax :syntax include @CSTUFF ~/.vimrc_include_c_syn :syntax region rubyC1 matchgroup=String start=+%Q{+ end=+}+ keepend contains=@CSTUFF :syntax region rubyC2 matchgroup=String start=+%Q(+ end=+)+ keepend contains=@CSTUFF :syntax region rubyC3 matchgroup=String start=+%Q<+ end=+>+ keepend contains=@CSTUFF " :syntax on endfunction function RubyMetaC2() unlet b:current_syntax syn include @cTop syntax/c.vim let b:current_syntax = "ruby" syn region rubyCString start=+\%(\%(class\s*\|\%(\.\|::\)\)\_s*\)\@ Hi all, I have written and attached an ERuby indent plugin. It outsources most of the heavy lifting to the HTML and Ruby indent plugins, and works quite well. I would think it would be appropriate for inclusion in vim-ruby. I emailed this to Doug Kearns a bit earlier (and have not received a response), but have since decided this list would be a more appropriate place to share it. Enjoy, Tim Pope -------------- next part -------------- " Vim indent file " Language: ERuby " Author: Tim Pope " $Id: eruby.vim,v 1.1 2006/11/07 20:51:03 tpope Exp $ if exists("b:did_indent") finish endif runtime! indent/ruby.vim unlet! b:did_indent runtime! indent/html.vim unlet! b:did_indent let b:did_indent = 1 setlocal indentexpr=GetErubyIndent(v:lnum) setlocal indentkeys=o,O,*,<>>,{,},!^F,=end,=else,=elsif,=rescue,=ensure,=when " Only define the function once. if exists("*GetErubyIndent") finish endif function! GetErubyIndent(lnum) let vcol = col('.') call cursor(a:lnum,1) let inruby = searchpair('<%','','%>') call cursor(a:lnum,vcol) if inruby let ind = GetRubyIndent() else let ind = HtmlIndentGet(a:lnum) endif let lnum = prevnonblank(a:lnum-1) let line = getline(lnum) let cline = getline(a:lnum) if cline =~# '<%\s*\%(end\|else\|\%(elsif\|rescue\|ensure\|case\|when\).\{-\}\)\s*-\=%>' let ind = ind - &sw endif if line =~# '\' let ind = ind + &sw elseif line =~# '<%\s*\%(if\|unless\|for\|while\|until\|def\|class\|module\|begin\|else\|elsif\|rescue\|ensure\|when\)\>.*%>' let ind = ind + &sw endif if line =~# '^\s*<%[=#]\=\s*$' let ind = ind + &sw endif if cline =~# '^\s*-\=%>\s*$' let ind = ind - &sw endif return ind endfunction " vim:set sw=2 sts=2 et: From dougkearns at gmail.com Wed Nov 8 08:05:07 2006 From: dougkearns at gmail.com (Doug Kearns) Date: Thu, 9 Nov 2006 00:05:07 +1100 Subject: ERuby indenting In-Reply-To: <20061107205522.GQ22442@tpope.us> References: <20061107205522.GQ22442@tpope.us> Message-ID: <20061108130506.GO2833@cpe-121-209-238-6.nsw.bigpond.net.au> Thanks for this Tim! Folks, I've just added Tim as a developer to the project and he's taking ownership of the eRuby indent file. Now we'll have an indent script that actually does something useful with the Ruby code. ;-) Regards, Doug From now at bitwi.se Wed Nov 8 08:54:38 2006 From: now at bitwi.se (Nikolai Weibull) Date: Wed, 8 Nov 2006 14:54:38 +0100 Subject: ERuby indenting In-Reply-To: <20061107205522.GQ22442@tpope.us> References: <20061107205522.GQ22442@tpope.us> Message-ID: On 11/7/06, Tim Pope wrote: > Hi all, > > I have written and attached an ERuby indent plugin. It outsources > most of the heavy lifting to the HTML and Ruby indent plugins, and > works quite well. I would think it would be appropriate for inclusion > in vim-ruby. Perhaps the regular expressions used in indent/ruby.vim should be made available to the indent/eruby.vim script as well, to avoid duplication. nikolai From vim-ruby-devel at tpope.info Wed Nov 8 15:24:28 2006 From: vim-ruby-devel at tpope.info (Tim Pope) Date: Wed, 8 Nov 2006 14:24:28 -0600 Subject: ERuby indenting In-Reply-To: References: <20061107205522.GQ22442@tpope.us> Message-ID: <20061108202427.GU22442@tpope.us> Hi, thanks for the response, and your work on indent/ruby.vim! On Wed, Nov 08, 2006 at 02:54:38PM +0100, Nikolai Weibull wrote: > Perhaps the regular expressions used in indent/ruby.vim should be made > available to the indent/eruby.vim script as well, to avoid > duplication. This sounds like a good idea. At the same time, it seems like more trouble than it's worth. There are only a couple of patterns eruby.vim uses, and they don't directly match up with the patterns in ruby.vim. You'd need to factor out the differences and complicating matters this way doesn't seem prudent for a couple of short patterns that are rather unlikely to change. If eruby.vim becomes more sophisticated this is definitely worth considering. I have a couple of questions regarding your indent/ruby.vim myself. Are you particularly attached to the method of lining up parentheses? I have altered my local copy to make it possible to disable (g:rubyindent_match_parentheses) and instead use the brace/bracket behavior. Given that the indent doesn't restore properly on the line after the closing parenthesis, I'd be quite satisfied to just see the behavior eliminated altogether. I could furnish a patch for this as well (or just alter and commit directly) if you are open to it. On a related note, ) and ] probably belong in indentkeys. Cheers, Tim From thomas.adam22 at gmail.com Wed Nov 8 15:55:52 2006 From: thomas.adam22 at gmail.com (Thomas Adam) Date: Wed, 8 Nov 2006 20:55:52 +0000 Subject: ERuby indenting In-Reply-To: <20061108202427.GU22442@tpope.us> References: <20061107205522.GQ22442@tpope.us> <20061108202427.GU22442@tpope.us> Message-ID: <20061108205552.GB20437@edulinux.homeunix.org> On Wed, Nov 08, 2006 at 02:24:28PM -0600, Tim Pope wrote: > Hi, thanks for the response, and your work on indent/ruby.vim! > > I have altered my local copy to make it possible to disable > (g:rubyindent_match_parentheses) and instead use the brace/bracket > behavior. Given that the indent doesn't restore properly on the line > after the closing parenthesis, I'd be quite satisfied to just see the > behavior eliminated altogether. I could furnish a patch for this as > well (or just alter and commit directly) if you are open to it. I'd prefer this, as it does cause a lot of problem in fringe cases where there's different sets of parenthesis split over different lines. I too have a patch for that, but I'll let you do it against your own file. -- Thomas Adam -- "Wanting to feel; to know what is real. Living is a lie." -- Purpoise Song, by The Monkees. From now at bitwi.se Wed Nov 8 16:31:10 2006 From: now at bitwi.se (Nikolai Weibull) Date: Wed, 8 Nov 2006 22:31:10 +0100 Subject: ERuby indenting In-Reply-To: <20061108202427.GU22442@tpope.us> References: <20061107205522.GQ22442@tpope.us> <20061108202427.GU22442@tpope.us> Message-ID: On 11/8/06, Tim Pope wrote: > Hi, thanks for the response, and your work on indent/ruby.vim! No problem :-). > On Wed, Nov 08, 2006 at 02:54:38PM +0100, Nikolai Weibull wrote: > > Perhaps the regular expressions used in indent/ruby.vim should be made > > available to the indent/eruby.vim script as well, to avoid > > duplication. > > This sounds like a good idea. At the same time, it seems like more > trouble than it's worth. There are only a couple of patterns > eruby.vim uses, and they don't directly match up with the patterns in > ruby.vim. You'd need to factor out the differences and complicating > matters this way doesn't seem prudent for a couple of short patterns > that are rather unlikely to change. If eruby.vim becomes more > sophisticated this is definitely worth considering. Sounds like your right. > I have a couple of questions regarding your indent/ruby.vim myself. > Are you particularly attached to the method of lining up parentheses? ? Do you mean as in def some_method(param1, param2) < or what? Writing def some_method(param1, param2 ) < is bugged though, because it's assumed that the ) closes something. This is stupid, though, and the ) shouldn't be considered special. I'll check what's causing this some day or other. > I have altered my local copy to make it possible to disable > (g:rubyindent_match_parentheses) and instead use the brace/bracket > behavior. Given that the indent doesn't restore properly on the line > after the closing parenthesis, I'd be quite satisfied to just see the > behavior eliminated altogether. I could furnish a patch for this as > well (or just alter and commit directly) if you are open to it. Please show the problem and the solution. > On a related note, ) and ] probably belong in indentkeys. They already are. nikolai From vim-ruby-devel at tpope.info Wed Nov 8 19:00:20 2006 From: vim-ruby-devel at tpope.info (Tim Pope) Date: Wed, 8 Nov 2006 18:00:20 -0600 Subject: ERuby indenting In-Reply-To: References: <20061107205522.GQ22442@tpope.us> <20061108202427.GU22442@tpope.us> Message-ID: <20061109000020.GV22442@tpope.us> On Wed, Nov 08, 2006 at 10:31:10PM +0100, Nikolai Weibull wrote: > On 11/8/06, Tim Pope wrote: > > I have a couple of questions regarding your indent/ruby.vim myself. > > Are you particularly attached to the method of lining up parentheses? > > ? Do you mean as in > > def some_method(param1, > param2) > < > > or what? Writing > > def some_method(param1, > param2 > ) > < > > is bugged though, because it's assumed that the ) closes something. > This is stupid, though, and the ) shouldn't be considered special. > I'll check what's causing this some day or other. The second example is one of the problem cases. Here is another: ActiveRecord::Base.establish_connection( :adapter => 'sqlite3', :database => 'foo.sqlite3') < Notice that it also breaks if the opening parentheses ends the first line. My ideal outcome would actually be something like: ActiveRecord::Base.establish_connection( :adapter => 'sqlite3', :database => 'foo.sqlite3' ) < This is a common case I run into. With a very long method call, I want to start the arguments on a separate line so I can have more room. Instead, I am treated to being in the exact same column that I was already in. I have to manually correct for this, and then manually correct again when closing the parentheses. Very tedious with such a large indent. After seeing your example it's apparent there are two different use cases here. very_long_method_name( bar, baz ) short(foo, bar) Perhaps the ideal solution is to optimize for my case when the line ends with an opening parenthesis, and your case when it is followed with further characters. I have no idea how difficult this is to implement but I think it would leave all parties happy. (Further input from others on this is welcome.) > > I have altered my local copy to make it possible to disable > > (g:rubyindent_match_parentheses) and instead use the brace/bracket > > behavior. Given that the indent doesn't restore properly on the line > > after the closing parenthesis, I'd be quite satisfied to just see the > > behavior eliminated altogether. I could furnish a patch for this as > > well (or just alter and commit directly) if you are open to it. > > Please show the problem and the solution. I have attached a patch. While it would pacify me, I think it would probably be better to instead pursue the goal I outlined above. > > On a related note, ) and ] probably belong in indentkeys. > > They already are. Err, apparently I should be sending that to myself, as they are missing from eruby.vim, not yours. Cheers, Tim -------------- next part -------------- --- ruby.vim 2006-04-25 02:05:42.000000000 -0500 +++ ruby.vim.new 2006-08-21 14:49:52.000000000 -0500 @@ -30,6 +30,10 @@ let s:cpo_save = &cpo set cpo&vim +if !exists("g:rubyindent_match_parentheses") + let g:rubyindent_match_parentheses = 1 +endif + " 1. Variables {{{1 " ============ @@ -217,7 +221,11 @@ call cursor(v:lnum, col) let bs = strpart('(){}[]', stridx(')}]', line[col - 1]) * 2, 2) if searchpair(escape(bs[0], '\['), '', bs[1], 'bW', s:skip_expr) > 0 - let ind = line[col-1]==')' ? virtcol('.')-1 : indent(s:GetMSL(line('.'))) + if line[col-1]==')' && g:rubyindent_match_parentheses + let ind = virtcol('.')-1 + else + let ind = indent(s:GetMSL(line('.'))) + endif endif return ind endif @@ -273,10 +281,11 @@ " add indent depending on the bracket type. if line =~ '[[({]' let counts = s:LineHasOpeningBrackets(lnum) - if counts[0] == '1' && searchpair('(', '', ')', 'bW', s:skip_expr) > 0 - return virtcol('.') - elseif counts[1] == '1' || counts[2] == '1' + if counts[1] == '1' || counts[2] == '1' || + \ (counts[0] == '1' && !g:rubyindent_match_parentheses) return ind + &sw + elseif counts[0] == '1' && searchpair('(', '', ')', 'bW', s:skip_expr) > 0 + return virtcol('.') else call cursor(v:lnum, vcol) end From vim-ruby-devel at tpope.info Thu Nov 9 00:11:25 2006 From: vim-ruby-devel at tpope.info (Tim Pope) Date: Wed, 8 Nov 2006 23:11:25 -0600 Subject: ERuby indenting In-Reply-To: <20061109000020.GV22442@tpope.us> References: <20061107205522.GQ22442@tpope.us> <20061108202427.GU22442@tpope.us> <20061109000020.GV22442@tpope.us> Message-ID: <20061109051125.GX22442@tpope.us> > Perhaps the ideal solution is to optimize for my case when the line > ends with an opening parenthesis, and your case when it is followed > with further characters. I have no idea how difficult this is to > implement but I think it would leave all parties happy. (Further > input from others on this is welcome.) I have gone ahead and implemented this. Attached is a patch. Cheers, Tim -------------- next part -------------- --- ruby.vim.old 2006-11-08 23:03:33.000000000 -0600 +++ ruby.vim 2006-11-08 23:02:48.000000000 -0600 @@ -217,7 +217,11 @@ call cursor(v:lnum, col) let bs = strpart('(){}[]', stridx(')}]', line[col - 1]) * 2, 2) if searchpair(escape(bs[0], '\['), '', bs[1], 'bW', s:skip_expr) > 0 - let ind = line[col-1]==')' ? virtcol('.')-1 : indent(s:GetMSL(line('.'))) + if line[col-1]==')' && col('.') != col('$') - 1 + let ind = virtcol('.')-1 + else + let ind = indent(s:GetMSL(line('.'))) + endif endif return ind endif @@ -274,7 +278,11 @@ if line =~ '[[({]' let counts = s:LineHasOpeningBrackets(lnum) if counts[0] == '1' && searchpair('(', '', ')', 'bW', s:skip_expr) > 0 - return virtcol('.') + if col('.') + 1 == col('$') + return ind + &sw + else + return virtcol('.') + endif elseif counts[1] == '1' || counts[2] == '1' return ind + &sw else From now at bitwi.se Thu Nov 9 03:30:16 2006 From: now at bitwi.se (Nikolai Weibull) Date: Thu, 9 Nov 2006 09:30:16 +0100 Subject: ERuby indenting In-Reply-To: <20061109000020.GV22442@tpope.us> References: <20061107205522.GQ22442@tpope.us> <20061108202427.GU22442@tpope.us> <20061109000020.GV22442@tpope.us> Message-ID: On 11/9/06, Tim Pope wrote: > On Wed, Nov 08, 2006 at 10:31:10PM +0100, Nikolai Weibull wrote: > > On 11/8/06, Tim Pope wrote: > > > I have a couple of questions regarding your indent/ruby.vim myself. > > > Are you particularly attached to the method of lining up parentheses? > > > > ? Do you mean as in > > > > def some_method(param1, > > param2) > > < > > > > or what? Writing > > > > def some_method(param1, > > param2 > > ) > > < > > > > is bugged though, because it's assumed that the ) closes something. > > This is stupid, though, and the ) shouldn't be considered special. > > I'll check what's causing this some day or other. > > The second example is one of the problem cases. Here is another: > > ActiveRecord::Base.establish_connection( > :adapter => 'sqlite3', > :database => 'foo.sqlite3') > < > > Notice that it also breaks if the opening parentheses ends the first > line. > > My ideal outcome would actually be something like: > > ActiveRecord::Base.establish_connection( > :adapter => 'sqlite3', > :database => 'foo.sqlite3' > ) > < > > This is a common case I run into. With a very long method call, I > want to start the arguments on a separate line so I can have more > room. Instead, I am treated to being in the exact same column that I > was already in. I have to manually correct for this, and then > manually correct again when closing the parentheses. Very tedious > with such a large indent. > > After seeing your example it's apparent there are two different use > cases here. > > very_long_method_name( > bar, > baz > ) > > short(foo, > bar) > > Perhaps the ideal solution is to optimize for my case when the line > ends with an opening parenthesis, and your case when it is followed > with further characters. I have no idea how difficult this is to > implement but I think it would leave all parties happy. (Further > input from others on this is welcome.) Yes, that sounds reasonable. I'll add a case for when a method call ends with ( nikolai From now at bitwi.se Thu Nov 9 03:30:35 2006 From: now at bitwi.se (Nikolai Weibull) Date: Thu, 9 Nov 2006 09:30:35 +0100 Subject: ERuby indenting In-Reply-To: <20061109051125.GX22442@tpope.us> References: <20061107205522.GQ22442@tpope.us> <20061108202427.GU22442@tpope.us> <20061109000020.GV22442@tpope.us> <20061109051125.GX22442@tpope.us> Message-ID: On 11/9/06, Tim Pope wrote: > > Perhaps the ideal solution is to optimize for my case when the line > > ends with an opening parenthesis, and your case when it is followed > > with further characters. I have no idea how difficult this is to > > implement but I think it would leave all parties happy. (Further > > input from others on this is welcome.) > > I have gone ahead and implemented this. Attached is a patch. Ah, thanks. :-) nikolai From vim-ruby-devel at tpope.info Thu Nov 9 14:02:41 2006 From: vim-ruby-devel at tpope.info (Tim Pope) Date: Thu, 9 Nov 2006 13:02:41 -0600 Subject: ERuby indenting In-Reply-To: References: <20061107205522.GQ22442@tpope.us> <20061108202427.GU22442@tpope.us> <20061109000020.GV22442@tpope.us> <20061109051125.GX22442@tpope.us> Message-ID: <20061109190241.GY22442@tpope.us> On Thu, Nov 09, 2006 at 09:30:35AM +0100, Nikolai Weibull wrote: > > I have gone ahead and implemented this. Attached is a patch. > > Ah, thanks. :-) Great, I take this you approve. Doug and I were contemplating doing another release in the next few days to show off the new indent/eruby.vim. I would be thrilled if this patch could make it in. I can commit it and update the ChangeLog too if you'd like. Here's a bit of code that illustrates two cases with incorrect indenting if the current plugin has its way (try them out with gg=G). The first is tricky and the second is downright pathological, but I thought I'd share anyways. I may investigate the first at a later time. class Hash class Foo; def bar; nil; end; end alias old_writer []= unless instance_methods.include?(:old_writer) end Cheers, Tim From now at bitwi.se Thu Nov 9 15:25:24 2006 From: now at bitwi.se (Nikolai Weibull) Date: Thu, 9 Nov 2006 21:25:24 +0100 Subject: ERuby indenting In-Reply-To: <20061109190241.GY22442@tpope.us> References: <20061107205522.GQ22442@tpope.us> <20061108202427.GU22442@tpope.us> <20061109000020.GV22442@tpope.us> <20061109051125.GX22442@tpope.us> <20061109190241.GY22442@tpope.us> Message-ID: On 11/9/06, Tim Pope wrote: > On Thu, Nov 09, 2006 at 09:30:35AM +0100, Nikolai Weibull wrote: > > > I have gone ahead and implemented this. Attached is a patch. > > > > Ah, thanks. :-) > > Great, I take this you approve. Doug and I were contemplating doing > another release in the next few days to show off the new > indent/eruby.vim. I would be thrilled if this patch could make it in. > I can commit it and update the ChangeLog too if you'd like. Do so. The less I have to do the better :-). Also, someone seems to have put tabs in the script. (Or they've been there all along). You're free to replace them with the appropriate number of spaces. I've decided that tabs are a hack and I don't use them any more. Let the flame-war begin. nikolai From vim-ruby-devel at tpope.info Thu Nov 9 16:35:53 2006 From: vim-ruby-devel at tpope.info (Tim Pope) Date: Thu, 9 Nov 2006 15:35:53 -0600 Subject: ERuby indenting In-Reply-To: References: <20061107205522.GQ22442@tpope.us> <20061108202427.GU22442@tpope.us> <20061109000020.GV22442@tpope.us> <20061109051125.GX22442@tpope.us> <20061109190241.GY22442@tpope.us> Message-ID: <20061109213553.GZ22442@tpope.us> On Thu, Nov 09, 2006 at 09:25:24PM +0100, Nikolai Weibull wrote: > Do so. The less I have to do the better :-). Also, someone seems to Done. > have put tabs in the script. (Or they've been there all along). > You're free to replace them with the appropriate number of spaces. > I've decided that tabs are a hack and I don't use them any more. Let > the flame-war begin. I find tabs to be more trouble as their worth as well. However, my understanding is that Bram prefers them to help keep the size of runtime files down. While I dislike tabs, Vim makes it just easy enough that I'm willing to oblige (my biggest issues arise when having to deal with non-Vim users/environments). I have gone so far as to add a modeline specifying 'noet' to indent/ruby.vim when I committed the patch. Feel free to remove it; I have no stake in the matter. Cheers, Tim From now at bitwi.se Thu Nov 9 17:01:40 2006 From: now at bitwi.se (Nikolai Weibull) Date: Thu, 9 Nov 2006 23:01:40 +0100 Subject: ERuby indenting In-Reply-To: <20061109213553.GZ22442@tpope.us> References: <20061107205522.GQ22442@tpope.us> <20061108202427.GU22442@tpope.us> <20061109000020.GV22442@tpope.us> <20061109051125.GX22442@tpope.us> <20061109190241.GY22442@tpope.us> <20061109213553.GZ22442@tpope.us> Message-ID: On 11/9/06, Tim Pope wrote: > On Thu, Nov 09, 2006 at 09:25:24PM +0100, Nikolai Weibull wrote: > > Do so. The less I have to do the better :-). Also, someone seems to > > Done. > > > have put tabs in the script. (Or they've been there all along). > > You're free to replace them with the appropriate number of spaces. > > I've decided that tabs are a hack and I don't use them any more. Let > > the flame-war begin. > > I find tabs to be more trouble as their worth as well. However, my > understanding is that Bram prefers them to help keep the size of > runtime files down. While I dislike tabs, Vim makes it just easy > enough that I'm willing to oblige (my biggest issues arise when having > to deal with non-Vim users/environments). Bram can be a bit overzealous at times (no offense meant - he's right most of the time). I have a hard time believing that tab space-compression-scheme saves us anything over what gzip/bzip2 do. Especially considering that we're messing up the huffman coding. > I have gone so far as to add a modeline specifying 'noet' to > indent/ruby.vim when I committed the patch. Feel free to remove it; I > have no stake in the matter. Ooh, no modelines please. Modelines are bad, mkay. Hm, seems like most files in vim-ruby do have them, though... As the file seems to be tabs throughout, let's leave it at that then. nikolai From vim-ruby-devel at tpope.info Thu Nov 9 17:35:29 2006 From: vim-ruby-devel at tpope.info (Tim Pope) Date: Thu, 9 Nov 2006 16:35:29 -0600 Subject: ERuby indenting In-Reply-To: References: <20061108202427.GU22442@tpope.us> <20061109000020.GV22442@tpope.us> <20061109051125.GX22442@tpope.us> <20061109190241.GY22442@tpope.us> <20061109213553.GZ22442@tpope.us> Message-ID: <20061109223529.GA22442@tpope.us> On Thu, Nov 09, 2006 at 11:01:40PM +0100, Nikolai Weibull wrote: > Bram can be a bit overzealous at times (no offense meant - he's right > most of the time). I have a hard time believing that tab > space-compression-scheme saves us anything over what gzip/bzip2 do. > Especially considering that we're messing up the huffman coding. I think the concern is uncompressed, not compressed size. > Ooh, no modelines please. Modelines are bad, mkay. Hm, seems like > most files in vim-ruby do have them, though... While I've seen some horrible abuses of modelines (in one plugin I even saw t_vb=), This seems like an appropriate use. We both likely have expandtab set by default for the vim filetype; this modeline allows for one exception without worrying about having to remember it. Cheers, Tim From segfault at hasno.info Thu Nov 30 11:52:03 2006 From: segfault at hasno.info (Mark Guzman) Date: Thu, 30 Nov 2006 11:52:03 -0500 Subject: new rubycomplete for testing Message-ID: <456F0C33.2070100@hasno.info> I've checked in the version of rubycomplete that I've been working on. It passes my current tests. If anyone has some time, please grab it from cvs and test it out please. --mark -- sic transit gloria et adulescentia blog | http://hasno.info wiki | http://wiki.hasno.info From segfault at hasno.info Fri Dec 1 01:48:30 2006 From: segfault at hasno.info (Mark Guzman) Date: Fri, 01 Dec 2006 01:48:30 -0500 Subject: s:rubypath in ftplugin/ruby.vim Message-ID: <456FD03E.7090009@hasno.info> I've checked in a change to the ruby.vim ftplugin. Running ruby delays vim's start under windows for an annoyingly long time, so I've modified ruby.vim to use the linked-in interpreter to generate s:rubypath if it's available under windows. --mark -- sic transit gloria et adulescentia blog | http://hasno.info wiki | http://wiki.hasno.info From dougkearns at gmail.com Mon Dec 4 10:00:17 2006 From: dougkearns at gmail.com (Doug Kearns) Date: Tue, 5 Dec 2006 02:00:17 +1100 Subject: eRuby indenting capabilities Message-ID: <20061204150017.GA18282@cpe-121-209-236-2.nsw.bigpond.net.au> Tim, I was just giving the new indent script a quick test drive prior to the next release and noticed that the following example doesn't work as I'd expect. <% if true %> foobar <% end %> is indented as: <% if true %> foobar <% end %> It also appears that the Ruby code will only be indented correctly when the <%,%> delimiters are on lines by themselves? eg. the following isn't transformed at all when running the filter/indent motion over it. <% if true foobar end %> Am I misunderstanding its current capabilities? Thanks, Doug From vim-ruby-devel at tpope.info Mon Dec 4 12:05:41 2006 From: vim-ruby-devel at tpope.info (Tim Pope) Date: Mon, 4 Dec 2006 11:05:41 -0600 Subject: eRuby indenting capabilities In-Reply-To: <20061204150017.GA18282@cpe-121-209-236-2.nsw.bigpond.net.au> References: <20061204150017.GA18282@cpe-121-209-236-2.nsw.bigpond.net.au> Message-ID: <20061204170541.GR6129@tpope.us> On Tue, Dec 05, 2006 at 02:00:17AM +1100, Doug Kearns wrote: > Tim, > > I was just giving the new indent script a quick test drive prior to the > next release and noticed that the following example doesn't work as I'd > expect. > > <% > if true > %> > foobar > <% > end > %> > > is indented as: > > <% > if true > %> > foobar > <% > end > %> First, the end block should of course be <% end %> This is what I get. Do your results differ or was this a copy and paste error? > It also appears that the Ruby code will only be indented correctly when > the <%,%> delimiters are on lines by themselves? > > eg. the following isn't transformed at all when running the > filter/indent motion over it. > > <% if true > foobar > end %> > > > Am I misunderstanding its current capabilities? Pretty much :). I've supported the most common conventions. For example, your first example would work fine if written as <% if true %> foobar <% end %> It would of course be ideal to support your examples as well but implementing them would require some heavy modifications to indent/ruby.vim (and perhaps indent/html.vim as well). Since they are apparently quite rare in the code I've worked with, I'm cheerfully refraining from the task. Cheers, Tim From dougkearns at gmail.com Mon Dec 4 13:37:48 2006 From: dougkearns at gmail.com (Doug Kearns) Date: Tue, 5 Dec 2006 05:37:48 +1100 Subject: eRuby indenting capabilities In-Reply-To: <20061204170541.GR6129@tpope.us> References: <20061204150017.GA18282@cpe-121-209-236-2.nsw.bigpond.net.au> <20061204170541.GR6129@tpope.us> Message-ID: <20061204183748.GA21825@cpe-121-209-236-2.nsw.bigpond.net.au> On Mon, Dec 04, 2006 at 11:05:41AM -0600, Tim Pope wrote: > On Tue, Dec 05, 2006 at 02:00:17AM +1100, Doug Kearns wrote: > > Tim, > > > > I was just giving the new indent script a quick test drive prior to the > > next release and noticed that the following example doesn't work as I'd > > expect. > > > > <% > > if true > > %> > > foobar > > <% > > end > > %> > > > > is indented as: > > > > <% > > if true > > %> > > foobar > > <% > > end > > %> > > First, the end block should of course be > > <% > end > %> > > This is what I get. Do your results differ or was this a copy and > paste error? No, I'm seeing 2 indent levels for the "end" and one for the "%>". In fact, if I repeatedly indent this the final "%>" alternates between 1 and 0 levels of indent. > It would of course be ideal to support your examples as well but > implementing them would require some heavy modifications to > indent/ruby.vim (and perhaps indent/html.vim as well). Since they > are apparently quite rare in the code I've worked with, I'm cheerfully > refraining from the task. Fair enough...just checking. ;-) Thanks, Doug From vim-ruby-devel at tpope.info Mon Dec 4 16:36:46 2006 From: vim-ruby-devel at tpope.info (Tim Pope) Date: Mon, 4 Dec 2006 15:36:46 -0600 Subject: eRuby indenting capabilities In-Reply-To: <20061204183748.GA21825@cpe-121-209-236-2.nsw.bigpond.net.au> References: <20061204150017.GA18282@cpe-121-209-236-2.nsw.bigpond.net.au> <20061204170541.GR6129@tpope.us> <20061204183748.GA21825@cpe-121-209-236-2.nsw.bigpond.net.au> Message-ID: <20061204213645.GS6129@tpope.us> On Tue, Dec 05, 2006 at 05:37:48AM +1100, Doug Kearns wrote: > On Mon, Dec 04, 2006 at 11:05:41AM -0600, Tim Pope wrote: > > On Tue, Dec 05, 2006 at 02:00:17AM +1100, Doug Kearns wrote: > > > Tim, > > > > > > I was just giving the new indent script a quick test drive prior to the > > > next release and noticed that the following example doesn't work as I'd > > > expect. > > > > > > <% > > > if true > > > %> > > > foobar > > > <% > > > end > > > %> > > > > > > is indented as: > > > > > > <% > > > if true > > > %> > > > foobar > > > <% > > > end > > > %> > > > > First, the end block should of course be > > > > <% > > end > > %> > > > > This is what I get. Do your results differ or was this a copy and > > paste error? > > No, I'm seeing 2 indent levels for the "end" and one for the "%>". In > fact, if I repeatedly indent this the final "%>" alternates between 1 > and 0 levels of indent. Okay, after a little investigating, I found the cause, and I've had to add a special case for an eRuby block with "end" as its first line. After a couple of other minor tweaks here is the new indenting style for the above example: <% if true %> foobar <% end %> I'm not exactly sure what the correct behavior is for this example but the above was easy to implement and seems reasonable. I've kept the changes minimal to hopefulyl avoid a broken release. If anyone finds any problems let me know. Tim From dougkearns at gmail.com Mon Dec 4 16:50:53 2006 From: dougkearns at gmail.com (Doug Kearns) Date: Tue, 5 Dec 2006 08:50:53 +1100 Subject: s:rubypath in ftplugin/ruby.vim In-Reply-To: <456FD03E.7090009@hasno.info> References: <456FD03E.7090009@hasno.info> Message-ID: <20061204215053.GG3187@cpe-121-209-236-2.nsw.bigpond.net.au> On Fri, Dec 01, 2006 at 01:48:30AM -0500, Mark Guzman wrote: > I've checked in a change to the ruby.vim ftplugin. Running ruby delays > vim's start under windows for an annoyingly long time, so I've modified > ruby.vim to use the linked-in interpreter to generate s:rubypath if it's > available under windows. Thanks. Is there a reason you've limited this to Windows? I assume it would be marginally quicker to use the Ruby 'interface' for other platforms? Regards, Doug From segfault at hasno.info Wed Dec 6 16:39:26 2006 From: segfault at hasno.info (Mark Guzman) Date: Wed, 06 Dec 2006 16:39:26 -0500 Subject: s:rubypath in ftplugin/ruby.vim In-Reply-To: <20061204215053.GG3187@cpe-121-209-236-2.nsw.bigpond.net.au> References: <456FD03E.7090009@hasno.info> <20061204215053.GG3187@cpe-121-209-236-2.nsw.bigpond.net.au> Message-ID: <4577388E.10800@hasno.info> Doug Kearns wrote: > Is there a reason you've limited this to Windows? I assume it would be > marginally quicker to use the Ruby 'interface' for other platforms? > I wasn't sure how people would feel about using the 'interface' for all platforms where it was available. The only platform where it really gets under my skin happens to be windows. The load time would indeed be marginally quicker, so with your (assumed) blessing I'll modify the file again to make the change relevant to all platforms. --mark -- sic transit gloria et adulescentia blog | http://hasno.info wiki | http://wiki.hasno.info From v-nijs at kellogg.northwestern.edu Wed Dec 6 23:14:45 2006 From: v-nijs at kellogg.northwestern.edu (Vincent Nijs) Date: Wed, 06 Dec 2006 22:14:45 -0600 Subject: Ruby commands from vim to running irb session Message-ID: I am interested in finding a way to send ruby commands from a vim buffer to a running irb session. Johannes Ranke has an example of a perl script that creates a pipe, allowing the user to send commands to a running R session. While this is very similar to what I am looking for, and the perl script is nice, it would be even better if you could have a ruby function in vim that would open the pipe and manage the communication between the vim session and the running irb session. I am a ruby newbie, so if anyone has any suggestion on how to get started on this please let me know. Johannes website is at: http://www.uft.uni-bremen.de/chemie/ranke/index.php?page=vim_R_linux Best, Vincent