ERuby indenting

Tim Pope vim-ruby-devel at tpope.info
Thu Nov 9 00:11:25 EST 2006


> 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


More information about the vim-ruby-devel mailing list