ERuby indenting

Nikolai Weibull now at bitwi.se
Thu Nov 9 03:30:16 EST 2006


On 11/9/06, Tim Pope <vim-ruby-devel at tpope.info> wrote:
> On Wed, Nov 08, 2006 at 10:31:10PM +0100, Nikolai Weibull wrote:
> > On 11/8/06, Tim Pope <vim-ruby-devel at tpope.info> 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


More information about the vim-ruby-devel mailing list