From ce31cd1d2f4e8eee9fd91325e4599f15cb9566fd Mon Sep 17 00:00:00 2001 From: Adam Stankiewicz Date: Wed, 28 Jul 2021 17:54:35 +0200 Subject: Update --- indent/ruby.vim | 36 ++++++++++++++++++++++++++++++------ 1 file changed, 30 insertions(+), 6 deletions(-) (limited to 'indent/ruby.vim') diff --git a/indent/ruby.vim b/indent/ruby.vim index afa72995..e4a295fd 100644 --- a/indent/ruby.vim +++ b/indent/ruby.vim @@ -93,6 +93,9 @@ let s:ruby_indent_keywords = \ '\|\%([=,*/%+-]\|<<\|>>\|:\s\)\s*\zs' . \ '\<\%(if\|for\|while\|until\|case\|unless\|begin\):\@!\>' +" Def without an end clause: def method_call(...) = +let s:ruby_endless_def = '\' @@ -112,10 +115,26 @@ let s:end_middle_regex = '\<\%(ensure\|else\|\%(\%(^\|;\)\s*\)\@<=\ " Regex that defines the end-match for the 'end' keyword. let s:end_end_regex = '\%(^\|[^.:@$]\)\@<=\' -" Expression used for searchpair() call for finding match for 'end' keyword. -let s:end_skip_expr = s:skip_expr . - \ ' || (expand("") == "do"' . - \ ' && getline(".") =~ "^\\s*\\<\\(while\\|until\\|for\\):\\@!\\>")' +" Expression used for searchpair() call for finding a match for an 'end' keyword. +function! s:EndSkipExpr() + if eval(s:skip_expr) + return 1 + elseif expand('') == 'do' + \ && getline(".") =~ '^\s*\<\(while\|until\|for\):\@!\>' + return 1 + elseif getline('.') =~ s:ruby_endless_def + return 1 + elseif getline('.') =~ '\ 0 + if col > 0 && s:Match(info.plnum, s:ruby_endless_def) <= 0 call cursor(info.plnum, col) let ind = virtcol('.') - 1 + info.sw " TODO: make this better (we need to count them) (or, if a searchpair @@ -660,7 +684,7 @@ function! s:IndentingKeywordInMSL(msl_info) abort " TODO: this does not take into account contrived things such as " module Foo; class Bar; end let col = s:Match(info.plnum_msl, s:ruby_indent_keywords) - if col > 0 + if col > 0 && s:Match(info.plnum_msl, s:ruby_endless_def) <= 0 let ind = indent(info.plnum_msl) + info.sw if s:Match(info.plnum_msl, s:end_end_regex) let ind = ind - info.sw -- cgit v1.2.3