summaryrefslogtreecommitdiffstats
path: root/indent/ruby.vim
diff options
context:
space:
mode:
authorAdam Stankiewicz <sheerun@sher.pl>2020-08-06 13:22:17 +0200
committerAdam Stankiewicz <sheerun@sher.pl>2020-08-06 13:22:17 +0200
commit1e533e5982a9c80f262b09fbe94e1ac4555ad915 (patch)
treeed573a3e399a95c2c3baeb6a1371d4753357cecc /indent/ruby.vim
parent56121b4e27cb48efb17be55a969b2f0d725266f8 (diff)
downloadvim-polyglot-1e533e5982a9c80f262b09fbe94e1ac4555ad915.tar.gz
vim-polyglot-1e533e5982a9c80f262b09fbe94e1ac4555ad915.zip
Update
Diffstat (limited to 'indent/ruby.vim')
-rw-r--r--indent/ruby.vim15
1 files changed, 13 insertions, 2 deletions
diff --git a/indent/ruby.vim b/indent/ruby.vim
index 8e72739e..1f2313cd 100644
--- a/indent/ruby.vim
+++ b/indent/ruby.vim
@@ -31,6 +31,11 @@ if !exists('g:ruby_indent_block_style')
let g:ruby_indent_block_style = 'do'
endif
+if !exists('g:ruby_indent_hanging_elements')
+ " Non-zero means hanging indents are enabled, zero means disabled
+ let g:ruby_indent_hanging_elements = 1
+endif
+
setlocal nosmartindent
" Now, set up our indentation expression and keys that trigger it.
@@ -323,7 +328,11 @@ function! s:ClosingBracketOnEmptyLine(cline_info) abort
if searchpair(escape(bracket_pair[0], '\['), '', bracket_pair[1], 'bW', s:skip_expr) > 0
if closing_bracket == ')' && col('.') != col('$') - 1
- let ind = virtcol('.') - 1
+ if g:ruby_indent_hanging_elements
+ let ind = virtcol('.') - 1
+ else
+ let ind = indent(line('.'))
+ end
elseif g:ruby_indent_block_style == 'do'
let ind = indent(line('.'))
else " g:ruby_indent_block_style == 'expression'
@@ -548,7 +557,9 @@ function! s:AfterUnbalancedBracket(pline_info) abort
let [opening, closing] = s:ExtraBrackets(info.plnum)
if opening.pos != -1
- if opening.type == '(' && searchpair('(', '', ')', 'bW', s:skip_expr) > 0
+ if !g:ruby_indent_hanging_elements
+ return indent(info.plnum) + info.sw
+ elseif opening.type == '(' && searchpair('(', '', ')', 'bW', s:skip_expr) > 0
if col('.') + 1 == col('$')
return indent(info.plnum) + info.sw
else