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

View File

@ -1,7 +1,7 @@
" Vim indent file " Vim indent file
" Language: R Documentation (Help), *.Rd " Language: R Documentation (Help), *.Rd
" Author: Jakson Alves de Aquino <jalvesaq@gmail.com> " 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. " 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 s:RIndent = function(substitute(&indentexpr, "()", "", ""))
let b:did_indent = 1 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 noautoindent
setlocal nocindent setlocal nocindent
setlocal nosmartindent setlocal nosmartindent
setlocal nolisp setlocal nolisp
setlocal indentkeys=0{,0},:,!^F,o,O,e setlocal indentkeys=0{,0},:,!^F,o,O,e
setlocal indentexpr=GetCorrectRHelpIndent() setlocal indentexpr=GetCorrectRHelpIndent()
" Only define the functions once.
if exists("*GetRHelpIndent")
finish
endif
function s:SanitizeRHelpLine(line) function s:SanitizeRHelpLine(line)
let newline = substitute(a:line, '\\\\', "x", "g") let newline = substitute(a:line, '\\\\', "x", "g")
let newline = substitute(newline, '\\{', "x", "g") let newline = substitute(newline, '\\{', "x", "g")

View File

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

View File

@ -1,7 +1,7 @@
" Vim indent file " Vim indent file
" Language: Rnoweb " Language: Rnoweb
" Author: Jakson Alves de Aquino <jalvesaq@gmail.com> " 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. " Only load this indent file when no other was loaded.
@ -23,7 +23,8 @@ if exists("*GetRnowebIndent")
endif endif
function GetRnowebIndent() function GetRnowebIndent()
if getline(".") =~ "^<<.*>>=$" let curline = getline(".")
if curline =~ '^<<.*>>=$' || curline =~ '^\s*@$'
return 0 return 0
endif endif
if search("^<<", "bncW") > search("^@", "bncW") if search("^<<", "bncW") > search("^@", "bncW")

View File

@ -3,12 +3,11 @@
" Maintainer: Jakson Aquino <jalvesaq@gmail.com> " Maintainer: Jakson Aquino <jalvesaq@gmail.com>
" Former Maintainers: Vaidotas Zemlys <zemlys@gmail.com> " Former Maintainers: Vaidotas Zemlys <zemlys@gmail.com>
" Tom Payne <tom@tompayne.org> " 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 " Filenames: *.R *.r *.Rhistory *.Rt
" "
" NOTE: The highlighting of R functions is defined in the " NOTE: The highlighting of R functions is defined in
" r-plugin/functions.vim, which is part of vim-r-plugin2: " runtime files created by a filetype plugin, if installed.
" http://www.vim.org/scripts/script.php?script_id=2628
" "
" CONFIGURATION: " CONFIGURATION:
" syntax folding can be turned on by " 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 "@\(param\|return\|name\|rdname\|examples\|include\|docType\)"
syn match rOKeyword contained "@\(S3method\|TODO\|aliases\|alias\|assignee\|author\|callGraphDepth\|callGraph\)" 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 "@\(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 "@\(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 "#'.*" 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 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 '\*' syn match rOperator '\*'
syn match rOperator '+' syn match rOperator '+'
syn match rOperator '='
if &filetype != "rmd" && &filetype != "rrst" if &filetype != "rmd" && &filetype != "rrst"
syn match rOperator "[|!<>^~/:]" syn match rOperator "[|!<>^~/:]"
else else
syn match rOperator "[|!<>^~`/:]" syn match rOperator "[|!<>^~`/:]"
endif endif
syn match rOperator "%\{2}\|%\S\{-}%" syn match rOperator "%\{2}\|%\S\{-}%"
syn match rOperator '\([!><]\)\@<=='
syn match rOperator '=='
syn match rOpError '\*\{3}' syn match rOpError '\*\{3}'
syn match rOpError '//' syn match rOpError '//'
syn match rOpError '&&&' syn match rOpError '&&&'
@ -129,8 +130,8 @@ syn match rOpError '|||'
syn match rOpError '<<' syn match rOpError '<<'
syn match rOpError '>>' syn match rOpError '>>'
syn match rArrow "<\{1,2}-" syn match rAssign "<\{1,2}-"
syn match rArrow "->\{1,2}" syn match rAssign "->\{1,2}"
" Special " Special
syn match rDelimiter "[,;:]" syn match rDelimiter "[,;:]"
@ -151,9 +152,14 @@ syn match rBraceError "[)}]" contained
syn match rCurlyError "[)\]]" contained syn match rCurlyError "[)\]]" contained
syn match rParenError "[\]}]" contained syn match rParenError "[\]}]" contained
" Source list of R functions. The list is produced by the Vim-R-plugin " Source list of R functions produced by a filetype plugin (if installed)
" http://www.vim.org/scripts/script.php?script_id=2628 if has("nvim")
" Nvim-R
runtime R/functions.vim
else
" Vim-R-plugin
runtime r-plugin/functions.vim runtime r-plugin/functions.vim
endif
syn match rDollar display contained "\$" syn match rDollar display contained "\$"
syn match rDollar display contained "@" syn match rDollar display contained "@"
@ -184,8 +190,14 @@ if &filetype == "rhelp"
syn match rhSection "\\dontrun\>" syn match rhSection "\\dontrun\>"
endif endif
if exists("r_syn_minlines")
exe "syn sync minlines=" . r_syn_minlines
else
syn sync minlines=40
endif
" Define the default highlighting. " Define the default highlighting.
hi def link rArrow Statement hi def link rAssign Statement
hi def link rBoolean Boolean hi def link rBoolean Boolean
hi def link rBraceError Error hi def link rBraceError Error
hi def link rComment Comment hi def link rComment Comment