I’m trying to get vim to indent continuation lines starting on a new line this way:
def foo
open_paren_at_EOL(
100, 200)
a = {
:foo => 1,
}
end
Vim 7.3’s default indentation [1] for those lines looks like this:
def foo
open_paren_at_EOL(
100, 200)
a = {
:foo => 1,
}
end
I have tried multiple cino= values and I even tried adapting the .vim script from [2] but with no success.
My .vimrc is here:
https://github.com/slnc/dotfiles/blob/master/.vimrc
Thanks!
What you could do to get this kind of indenting is to find out which areas of the
GetRubyIndentfunction are relevant to these continuations and increase the return values. For the example you gave, this seems to do the job:I’m not entirely sure if this won’t break anything else, but it seems like a safe change to me. If you find cases that don’t indent the way you want, you could just fix it the hard way: search for
returnwithin the limits of the function, then increase the indentation that is returned by one more&shiftwidth(or&sw). Check if it works, and if it doesn’t, undo and then move on to the nextreturn, until you actually find it.You could fork
vim-ruby, or you could just copy theindent/ruby.vimfile to~/.vim/indent/ruby.vimand change it as you wish. It should have priority over the bundledindent/ruby.vim.If you’re looking for a completely unobtrusive solution, that would be difficult. Theoretically, you could
override the
GetRubyIndentfunction as an indenter by usingsetlocal indentexpr=CustomGetRubyIndent(v:lnum), and then define aCustomGetRubyIndentfunction, which implements your behaviour in particular cases only and delegates toGetRubyIndent. I wouldn’t recommend going that far, though, it could get rather messy.