Merge pull request #2341 from jalvesaq/r-runtime-update

Update R runtime files
This commit is contained in:
Florian Walch 2015-04-05 15:55:43 +03:00
commit abf9bb63fe
5 changed files with 461 additions and 429 deletions

View File

@ -1,7 +1,7 @@
" Vim indent file
" Language: R
" Author: Jakson Alves de Aquino <jalvesaq@gmail.com>
" Last Change: Fri Feb 15, 2013 08:11PM
" Last Change: Thu Mar 26, 2015 05:36PM
" Only load this indent file when no other was loaded.
@ -31,6 +31,9 @@ endif
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 = '\(+\|-\|\*\|/\|=\|\~\|%\)$'
endif
function s:RDelete_quotes(line)
let i = 0
@ -135,8 +138,6 @@ endfunction
" This function is buggy because there 'if's without 'else'
" It must be rewritten relying more on indentation
function! s:Get_matching_if(linenr, delif)
" let filenm = expand("%")
" call writefile([filenm], "/tmp/matching_if_" . a:linenr)
let line = SanitizeRLine(getline(a:linenr))
if a:delif
let line = substitute(line, "if", "", "g")
@ -205,6 +206,9 @@ function SanitizeRLine(line)
let newline = s:RDelete_parens(newline)
let newline = substitute(newline, '#.*', "", "")
let newline = substitute(newline, '\s*$', "", "")
if &filetype == "rhelp" && newline =~ '^\\method{.*}{.*}(.*'
let newline = substitute(newline, '^\\method{\(.*\)}{.*}', '\1', "")
endif
return newline
endfunction
@ -255,9 +259,10 @@ function GetRIndent()
if line =~ '^\\examples{' || line =~ '^\\usage{' || line =~ '^\\dontshow{' || line =~ '^\\dontrun{' || line =~ '^\\donttest{' || line =~ '^\\testonly{'
return 0
endif
if line =~ '^\\method{.*}{.*}(.*'
let line = substitute(line, '^\\method{\(.*\)}{.*}', '\1', "")
endif
if &filetype == "rnoweb" && line =~ "^<<.*>>="
return 0
endif
if cline =~ '^\s*{'
@ -290,15 +295,15 @@ function GetRIndent()
return indent(lnum) + &sw
endif
let bb = s:Get_paren_balance(line, '[', ']')
let s:curtabstop = repeat(' ', &tabstop)
if g:r_indent_align_args == 1
if pb == 0 && bb == 0 && (line =~ '.*[,&|\-\*+<>]$' || cline =~ '^\s*[,&|\-\*+<>]')
return indent(lnum)
if g:r_indent_align_args == 1
if pb > 0 && line =~ '{$'
return s:Get_last_paren_idx(line, '(', ')', pb) + &sw
endif
let bb = s:Get_paren_balance(line, '[', ']')
if pb > 0
if &filetype == "rhelp"
let ind = s:Get_last_paren_idx(line, '(', ')', pb)
@ -350,6 +355,23 @@ function GetRIndent()
let post_block = 1
endif
" Indent after operator pattern
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
return indent(lnum)
else
return indent(lnum) + &sw
endif
else
if oline =~ g:r_indent_op_pattern
return indent(lnum) - &sw
endif
endif
endif
let post_fun = 0
if pb < 0 && line !~ ')\s*[,&|\-\*+<>]$'
let post_fun = 1
@ -387,6 +409,7 @@ function GetRIndent()
endif
endif
let bb = s:Get_paren_balance(line, '[', ']')
if bb < 0 && line =~ '.*]'
while bb < 0 && lnum > 0
let lnum -= 1
@ -489,4 +512,4 @@ function GetRIndent()
endfunction
" vim: sw=4
" vim: sw=2

View File

@ -1,7 +1,7 @@
" Vim indent file
" Language: R Documentation (Help), *.Rd
" Author: Jakson Alves de Aquino <jalvesaq@gmail.com>
" Last Change: Wed Jul 09, 2014 07:34PM
" Last Change: Thu Oct 16, 2014 07:07AM
" Only load this indent file when no other was loaded.
@ -12,22 +12,18 @@ runtime indent/r.vim
let s:RIndent = function(substitute(&indentexpr, "()", "", ""))
let b:did_indent = 1
setlocal indentkeys=0{,0},:,!^F,o,O,e
setlocal indentexpr=GetRHelpIndent()
" Only define the function once.
if exists("*GetRHelpIndent")
finish
endif
setlocal noautoindent
setlocal nocindent
setlocal nosmartindent
setlocal nolisp
setlocal indentkeys=0{,0},:,!^F,o,O,e
setlocal indentexpr=GetCorrectRHelpIndent()
" Only define the functions once.
if exists("*GetRHelpIndent")
finish
endif
function s:SanitizeRHelpLine(line)
let newline = substitute(a:line, '\\\\', "x", "g")
let newline = substitute(newline, '\\{', "x", "g")

View File

@ -1,7 +1,7 @@
" Vim indent file
" Language: Rmd
" Author: Jakson Alves de Aquino <jalvesaq@gmail.com>
" Last Change: Wed Jul 09, 2014 07:33PM
" Last Change: Thu Jul 10, 2014 07:11PM
" Only load this indent file when no other was loaded.
@ -33,10 +33,10 @@ function GetMdIndent()
endfunction
function GetRmdIndent()
if getline(".") =~ '^```{r .*}$' || getline(".") =~ '^```$'
if getline(".") =~ '^[ \t]*```{r .*}$' || getline(".") =~ '^[ \t]*```$'
return 0
endif
if search('^```{r', "bncW") > search('^```$', "bncW")
if search('^[ \t]*```{r', "bncW") > search('^[ \t]*```$', "bncW")
return s:RIndent()
else
return GetMdIndent()

View File

@ -1,7 +1,7 @@
" Vim indent file
" Language: Rnoweb
" Author: Jakson Alves de Aquino <jalvesaq@gmail.com>
" Last Change: Wed Jul 09, 2014 07:28PM
" Last Change: Sun Mar 22, 2015 09:28AM
" Only load this indent file when no other was loaded.
@ -23,7 +23,8 @@ if exists("*GetRnowebIndent")
endif
function GetRnowebIndent()
if getline(".") =~ "^<<.*>>=$"
let curline = getline(".")
if curline =~ '^<<.*>>=$' || curline =~ '^\s*@$'
return 0
endif
if search("^<<", "bncW") > search("^@", "bncW")

View File

@ -3,12 +3,11 @@
" Maintainer: Jakson Aquino <jalvesaq@gmail.com>
" Former Maintainers: Vaidotas Zemlys <zemlys@gmail.com>
" Tom Payne <tom@tompayne.org>
" Last Change: Wed Jul 09, 2014 10:29PM
" Last Change: Wed Dec 31, 2014 12:36AM
" Filenames: *.R *.r *.Rhistory *.Rt
"
" NOTE: The highlighting of R functions is defined in the
" r-plugin/functions.vim, which is part of vim-r-plugin2:
" http://www.vim.org/scripts/script.php?script_id=2628
" NOTE: The highlighting of R functions is defined in
" runtime files created by a filetype plugin, if installed.
"
" CONFIGURATION:
" syntax folding can be turned on by
@ -37,9 +36,9 @@ syn match rComment contains=@Spell,rCommentTodo "#.*"
syn match rOKeyword contained "@\(param\|return\|name\|rdname\|examples\|include\|docType\)"
syn match rOKeyword contained "@\(S3method\|TODO\|aliases\|alias\|assignee\|author\|callGraphDepth\|callGraph\)"
syn match rOKeyword contained "@\(callGraphPrimitives\|concept\|exportClass\|exportMethod\|exportPattern\|export\|formals\)"
syn match rOKeyword contained "@\(format\|importClassesFrom\|importFrom\|importMethodsFrom\|import\|keywords\)"
syn match rOKeyword contained "@\(format\|importClassesFrom\|importFrom\|importMethodsFrom\|import\|keywords\|useDynLib\)"
syn match rOKeyword contained "@\(method\|noRd\|note\|references\|seealso\|setClass\|slot\|source\|title\|usage\)"
syn match rOKeyword contained "@\(family\|template\|templateVar\|description\|details\|inheritsParams\)"
syn match rOKeyword contained "@\(family\|template\|templateVar\|description\|details\|inheritParams\)"
syn match rOComment contains=@Spell,rOKeyword "#'.*"
@ -111,17 +110,19 @@ syn match rComplex "\<\d\+\.\d*\([Ee][-+]\=\d\+\)\=i"
syn match rComplex "\<\.\d\+\([Ee][-+]\=\d\+\)\=i"
syn match rComplex "\<\d\+[Ee][-+]\=\d\+i"
syn match rAssign '='
syn match rOperator "&"
syn match rOperator '-'
syn match rOperator '\*'
syn match rOperator '+'
syn match rOperator '='
if &filetype != "rmd" && &filetype != "rrst"
syn match rOperator "[|!<>^~/:]"
else
syn match rOperator "[|!<>^~`/:]"
endif
syn match rOperator "%\{2}\|%\S\{-}%"
syn match rOperator '\([!><]\)\@<=='
syn match rOperator '=='
syn match rOpError '\*\{3}'
syn match rOpError '//'
syn match rOpError '&&&'
@ -129,8 +130,8 @@ syn match rOpError '|||'
syn match rOpError '<<'
syn match rOpError '>>'
syn match rArrow "<\{1,2}-"
syn match rArrow "->\{1,2}"
syn match rAssign "<\{1,2}-"
syn match rAssign "->\{1,2}"
" Special
syn match rDelimiter "[,;:]"
@ -151,9 +152,14 @@ syn match rBraceError "[)}]" contained
syn match rCurlyError "[)\]]" contained
syn match rParenError "[\]}]" contained
" Source list of R functions. The list is produced by the Vim-R-plugin
" http://www.vim.org/scripts/script.php?script_id=2628
" Source list of R functions produced by a filetype plugin (if installed)
if has("nvim")
" Nvim-R
runtime R/functions.vim
else
" Vim-R-plugin
runtime r-plugin/functions.vim
endif
syn match rDollar display contained "\$"
syn match rDollar display contained "@"
@ -184,8 +190,14 @@ if &filetype == "rhelp"
syn match rhSection "\\dontrun\>"
endif
if exists("r_syn_minlines")
exe "syn sync minlines=" . r_syn_minlines
else
syn sync minlines=40
endif
" Define the default highlighting.
hi def link rArrow Statement
hi def link rAssign Statement
hi def link rBoolean Boolean
hi def link rBraceError Error
hi def link rComment Comment