diff options
author | Jakson Alves de Aquino <jalvesaq@gmail.com> | 2023-12-25 09:22:27 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-12-25 10:22:27 +0100 |
commit | 9042bd8b09bae0051fdf8eb5a57fa4b4420c92a0 (patch) | |
tree | 89b160f56a7fdcfa40958c9a6bfc62db86dbe160 /runtime/indent/r.vim | |
parent | 377372ed5ba47995f12cd31be5f6132e82ca9cf6 (diff) |
runtime(r): Update R runtime files and docs (#13757)
* Update R runtime files
- Fix indentation issue with ggplot().
- Setlocal autoindent in indent/r.vim.
- New syntax option: rmd_include_latex.
- Clear syn iskeyword to recognize _ as keyword.
- Document some options.
- remove the test has("patch-7.4.1142")
- Update changed date of doc files
Signed-off-by: Jakson Alves de Aquino <jalvesaq@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org
Diffstat (limited to 'runtime/indent/r.vim')
-rw-r--r-- | runtime/indent/r.vim | 75 |
1 files changed, 35 insertions, 40 deletions
diff --git a/runtime/indent/r.vim b/runtime/indent/r.vim index 07dfd13881..f7956e4fe0 100644 --- a/runtime/indent/r.vim +++ b/runtime/indent/r.vim @@ -2,7 +2,7 @@ " Language: R " Author: Jakson Alves de Aquino <jalvesaq@gmail.com> " Homepage: https://github.com/jalvesaq/R-Vim-runtime -" Last Change: Mon Feb 27, 2023 07:16PM +" Last Change: Sun Oct 08, 2023 10:45AM " Only load this indent file when no other was loaded. @@ -13,6 +13,7 @@ let b:did_indent = 1 setlocal indentkeys=0{,0},:,!^F,o,O,e setlocal indentexpr=GetRIndent() +setlocal autoindent let b:undo_indent = "setl inde< indk<" @@ -47,27 +48,23 @@ function s:RDelete_quotes(line) if a:line[i] == '"' let i += 1 endif - else + elseif a:line[i] == "'" + let i += 1 + let line1 = line1 . 's' + while !(a:line[i] == "'" && ((i > 1 && a:line[i-1] == '\' && a:line[i-2] == '\') || a:line[i-1] != '\')) && i < llen + let i += 1 + endwhile if a:line[i] == "'" let i += 1 - let line1 = line1 . 's' - while !(a:line[i] == "'" && ((i > 1 && a:line[i-1] == '\' && a:line[i-2] == '\') || a:line[i-1] != '\')) && i < llen - let i += 1 - endwhile - if a:line[i] == "'" - let i += 1 - endif - else - if a:line[i] == "`" - let i += 1 - let line1 = line1 . 's' - while a:line[i] != "`" && i < llen - let i += 1 - endwhile - if a:line[i] == "`" - let i += 1 - endif - endif + endif + elseif a:line[i] == "`" + let i += 1 + let line1 = line1 . 's' + while a:line[i] != "`" && i < llen + let i += 1 + endwhile + if a:line[i] == "`" + let i += 1 endif endif if i == llen @@ -97,10 +94,8 @@ function s:RDelete_parens(line) let i += 1 if a:line[i] == ')' let nop -= 1 - else - if a:line[i] == '(' - let nop += 1 - endif + elseif a:line[i] == '(' + let nop += 1 endif endwhile let line1 = line1 . a:line[i] @@ -174,10 +169,8 @@ function s:Get_last_paren_idx(line, o, c, pb) if blc == 0 let theidx = idx endif - else - if line[idx] == a:c - let blc += 1 - endif + elseif line[idx] == a:c + let blc += 1 endif let idx += 1 endwhile @@ -316,6 +309,11 @@ function GetRIndent() endif if pb < 0 && line =~ '.*[,&|\-\*+<>]$' + if line =~ '.*[\-\*+>]$' + let is_op = v:true + else + let is_op = v:false + endif let lnum = s:Get_prev_line(lnum) while pb < 1 && lnum > 0 let line = SanitizeRLine(getline(lnum)) @@ -324,9 +322,10 @@ function GetRIndent() while ind > 0 if line[ind] == ')' let pb -= 1 - else - if line[ind] == '(' - let pb += 1 + elseif line[ind] == '(' + let pb += 1 + if is_op && pb == 0 + return indent(lnum) endif endif if pb == 1 @@ -367,10 +366,8 @@ function GetRIndent() else return indent(lnum) + shiftwidth() endif - else - if substitute(oline, '#.*', '', '') =~ g:r_indent_op_pattern && s:Get_paren_balance(line, "(", ")") == 0 - return indent(lnum) - shiftwidth() - endif + elseif substitute(oline, '#.*', '', '') =~ g:r_indent_op_pattern && s:Get_paren_balance(line, "(", ")") == 0 + return indent(lnum) - shiftwidth() endif elseif substitute(line, '#.*', '', '') =~ g:r_indent_op_pattern && s:Get_paren_balance(line, "(", ")") == 0 return indent(lnum) + shiftwidth() @@ -404,12 +401,10 @@ function GetRIndent() if cline =~ '^\s*else' if line =~ '<-\s*if\s*()' return indent(lnum) + shiftwidth() + elseif line =~ '\<if\s*()' + return indent(lnum) else - if line =~ '\<if\s*()' - return indent(lnum) - else - return indent(lnum) - shiftwidth() - endif + return indent(lnum) - shiftwidth() endif endif |