diff options
author | Bram Moolenaar <Bram@vim.org> | 2016-03-12 12:57:59 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2016-03-12 12:57:59 +0100 |
commit | 77cdfd10382e01cc51f4ba1a9177032351843151 (patch) | |
tree | 9d9e20ee5c80d402d8f853ca0d88b6db6a53e5ed /runtime/indent/r.vim | |
parent | 4fc563b397949ce23190045112fa08c0776a56e6 (diff) |
Updated runtime files.
Diffstat (limited to 'runtime/indent/r.vim')
-rw-r--r-- | runtime/indent/r.vim | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/runtime/indent/r.vim b/runtime/indent/r.vim index 105f0cd7ad..01f3812ed2 100644 --- a/runtime/indent/r.vim +++ b/runtime/indent/r.vim @@ -1,7 +1,8 @@ " Vim indent file " Language: R " Author: Jakson Alves de Aquino <jalvesaq@gmail.com> -" Last Change: Thu Mar 26, 2015 05:36PM +" Homepage: https://github.com/jalvesaq/R-Vim-runtime +" Last Change: Thu Feb 18, 2016 06:32AM " Only load this indent file when no other was loaded. @@ -32,7 +33,7 @@ if ! exists("g:r_indent_ess_compatible") let g:r_indent_ess_compatible = 0 endif if ! exists("g:r_indent_op_pattern") - let g:r_indent_op_pattern = '\(+\|-\|\*\|/\|=\|\~\|%\)$' + let g:r_indent_op_pattern = '\(&\||\|+\|-\|\*\|/\|=\|\~\|%\|->\)\s*$' endif function s:RDelete_quotes(line) @@ -265,7 +266,7 @@ function GetRIndent() return 0 endif - if cline =~ '^\s*{' + if cline =~ '^\s*{' && s:Get_paren_balance(cline, '{', '}') > 0 if g:r_indent_ess_compatible && line =~ ')$' let nlnum = lnum let nline = line @@ -283,7 +284,7 @@ function GetRIndent() endif " line is an incomplete command: - if line =~ '\<\(if\|while\|for\|function\)\s*()$' || line =~ '\<else$' || line =~ '<-$' + if line =~ '\<\(if\|while\|for\|function\)\s*()$' || line =~ '\<else$' || line =~ '<-$' || line =~ '->$' return indent(lnum) + &sw endif @@ -344,7 +345,7 @@ function GetRIndent() endif let post_block = 0 - if line =~ '}$' + if line =~ '}$' && s:Get_paren_balance(line, '{', '}') < 0 let lnum = s:Get_matching_brace(lnum, '{', '}', 0) let line = SanitizeRLine(getline(lnum)) if lnum > 0 && line =~ '^\s*{' @@ -359,14 +360,14 @@ function GetRIndent() let olnum = s:Get_prev_line(lnum) let oline = getline(olnum) if olnum > 0 - if line =~ g:r_indent_op_pattern - if oline =~ g:r_indent_op_pattern + if line =~ g:r_indent_op_pattern && s:Get_paren_balance(line, "(", ")") == 0 + if oline =~ g:r_indent_op_pattern && s:Get_paren_balance(line, "(", ")") == 0 return indent(lnum) else return indent(lnum) + &sw endif else - if oline =~ g:r_indent_op_pattern + if oline =~ g:r_indent_op_pattern && s:Get_paren_balance(line, "(", ")") == 0 return indent(lnum) - &sw endif endif @@ -471,7 +472,6 @@ function GetRIndent() endif let ind = indent(lnum) - let pind = indent(plnum) if g:r_indent_align_args == 0 && pb != 0 let ind += pb * &sw @@ -483,6 +483,12 @@ function GetRIndent() return ind endif + if plnum > 0 + let pind = indent(plnum) + else + let pind = 0 + endif + if ind == pind || (ind == (pind + &sw) && pline =~ '{$' && ppost_else == 0) return ind endif |