summaryrefslogtreecommitdiffstats
path: root/indent/ruby.vim
diff options
context:
space:
mode:
Diffstat (limited to 'indent/ruby.vim')
-rw-r--r--indent/ruby.vim15
1 files changed, 14 insertions, 1 deletions
diff --git a/indent/ruby.vim b/indent/ruby.vim
index 1acde808..f0dde6fa 100644
--- a/indent/ruby.vim
+++ b/indent/ruby.vim
@@ -440,10 +440,14 @@ function GetRubyIndent(...)
if strpart(line, 0, col('.') - 1) =~ '=\s*$' &&
\ strpart(line, col('.') - 1, 2) !~ 'do'
+ " assignment to case/begin/etc, on the same line, hanging indent
let ind = virtcol('.') - 1
elseif getline(msl) =~ '=\s*\(#.*\)\=$'
+ " in the case of assignment to the msl, align to the starting line,
+ " not to the msl
let ind = indent(line('.'))
else
+ " align to the msl
let ind = indent(msl)
endif
endif
@@ -508,7 +512,16 @@ function GetRubyIndent(...)
" If the previous line ended with a block opening, add a level of indent.
if s:Match(lnum, s:block_regex)
- return indent(s:GetMSL(lnum)) + sw
+ let msl = s:GetMSL(lnum)
+
+ if getline(msl) =~ '=\s*\(#.*\)\=$'
+ " in the case of assignment to the msl, align to the starting line,
+ " not to the msl
+ let ind = indent(lnum) + sw
+ else
+ let ind = indent(msl) + sw
+ endif
+ return ind
endif
" If the previous line started with a leading operator, use its MSL's level