forked from aniani/vim
Update runtime files.
This commit is contained in:
@@ -5,10 +5,10 @@
|
||||
" Tom Payne <tom@tompayne.org>
|
||||
" Contributor: Johannes Ranke <jranke@uni-bremen.de>
|
||||
" Homepage: https://github.com/jalvesaq/R-Vim-runtime
|
||||
" Last Change: Thu Aug 25, 2016 08:52PM
|
||||
" Last Change: Sat Apr 08, 2017 07:01PM
|
||||
" Filenames: *.R *.r *.Rhistory *.Rt
|
||||
"
|
||||
" NOTE: The highlighting of R functions is defined in
|
||||
" NOTE: The highlighting of R functions might be defined in
|
||||
" runtime files created by a filetype plugin, if installed.
|
||||
"
|
||||
" CONFIGURATION:
|
||||
@@ -18,7 +18,7 @@
|
||||
"
|
||||
" ROxygen highlighting can be turned off by
|
||||
"
|
||||
" let r_hl_roxygen = 0
|
||||
" let r_syntax_hl_roxygen = 0
|
||||
"
|
||||
" Some lines of code were borrowed from Zhuojun Chen.
|
||||
|
||||
@@ -26,13 +26,25 @@ if exists("b:current_syntax")
|
||||
finish
|
||||
endif
|
||||
|
||||
syn iskeyword @,48-57,_,.
|
||||
if has("patch-7.4.1142")
|
||||
syn iskeyword @,48-57,_,.
|
||||
else
|
||||
setlocal iskeyword=@,48-57,_,.
|
||||
endif
|
||||
|
||||
" The variables g:r_hl_roxygen and g:r_syn_minlines were renamed on April 8, 2017.
|
||||
if exists("g:r_hl_roxygen")
|
||||
let g:r_syntax_hl_roxygen = g:r_hl_roxygen
|
||||
endif
|
||||
if exists("g:r_syn_minlines")
|
||||
let g:r_syntax_minlines = g:r_syn_minlines
|
||||
endif
|
||||
|
||||
if exists("g:r_syntax_folding") && g:r_syntax_folding
|
||||
setlocal foldmethod=syntax
|
||||
endif
|
||||
if !exists("g:r_hl_roxygen")
|
||||
let g:r_hl_roxygen = 1
|
||||
if !exists("g:r_syntax_hl_roxygen")
|
||||
let g:r_syntax_hl_roxygen = 1
|
||||
endif
|
||||
|
||||
syn case match
|
||||
@@ -42,19 +54,106 @@ syn match rCommentTodo contained "\(BUG\|FIXME\|NOTE\|TODO\):"
|
||||
syn match rComment contains=@Spell,rCommentTodo,rOBlock "#.*"
|
||||
|
||||
" Roxygen
|
||||
if g:r_hl_roxygen
|
||||
syn region rOBlock start="^\s*\n#\{1,2}' " start="\%^#\{1,2}' " end="^\(#\{1,2}'\)\@!" contains=rOTitle,rOKeyword,rOExamples,@Spell keepend
|
||||
syn region rOTitle start="^\s*\n#\{1,2}' " start="\%^#\{1,2}' " end="^\(#\{1,2}'\s*$\)\@=" contained contains=rOCommentKey
|
||||
syn match rOCommentKey "#\{1,2}'" containedin=rOTitle contained
|
||||
if g:r_syntax_hl_roxygen
|
||||
" A roxygen block can start at the beginning of a file (first version) and
|
||||
" after a blank line (second version). It ends when a line that does not
|
||||
" contain a roxygen comment. In the following comments, any line containing
|
||||
" a roxygen comment marker (one or two hash signs # followed by a single
|
||||
" quote ' and preceded only by whitespace) is called a roxygen line. A
|
||||
" roxygen line containing only a roxygen comment marker, optionally followed
|
||||
" by whitespace is called an empty roxygen line.
|
||||
|
||||
syn region rOExamples start="^#\{1,2}' @examples.*"rs=e+1,hs=e+1 end="^\(#\{1,2}' @.*\)\@=" end="^\(#\{1,2}'\)\@!" contained contains=rOKeyword
|
||||
" First we match all roxygen blocks as containing only a title. In case an
|
||||
" empty roxygen line ending the title or a tag is found, this will be
|
||||
" overriden later by the definitions of rOBlock.
|
||||
syn match rOTitleBlock "\%^\(\s*#\{1,2}' .*\n\)\{1,}" contains=rOCommentKey,rOTitleTag
|
||||
syn match rOTitleBlock "^\s*\n\(\s*#\{1,2}' .*\n\)\{1,}" contains=rOCommentKey,rOTitleTag
|
||||
|
||||
syn match rOKeyword contained "@\(param\|return\|name\|rdname\|examples\|example\|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\|useDynLib\)"
|
||||
syn match rOKeyword contained "@\(method\|noRd\|note\|references\|seealso\|setClass\|slot\|source\|title\|usage\)"
|
||||
syn match rOKeyword contained "@\(family\|template\|templateVar\|description\|details\|inheritParams\|field\)"
|
||||
" When a roxygen block has a title and additional content, the title
|
||||
" consists of one or more roxygen lines (as little as possible are matched),
|
||||
" followed either by an empty roxygen line
|
||||
syn region rOBlock start="\%^\(\s*#\{1,2}' .*\n\)\{-1,}\s*#\{1,2}'\s*$" end="^\s*\(#\{1,2}'\)\@!" contains=rOTitle,rOTag,rOExamples,@Spell keepend fold
|
||||
syn region rOBlock start="^\s*\n\(\s*#\{1,2}' .*\n\)\{-1,}\s*#\{1,2}'\s*$" end="^\s*\(#\{1,2}'\)\@!" contains=rOTitle,rOTag,rOExamples,@Spell keepend fold
|
||||
|
||||
" or by a roxygen tag (we match everything starting with @ but not @@ which is used as escape sequence for a literal @).
|
||||
syn region rOBlock start="\%^\(\s*#\{1,2}' .*\n\)\{-}\s*#\{1,2}' @\(@\)\@!" end="^\s*\(#\{1,2}'\)\@!" contains=rOTitle,rOTag,rOExamples,@Spell keepend fold
|
||||
syn region rOBlock start="^\s*\n\(\s*#\{1,2}' .*\n\)\{-}\s*#\{1,2}' @\(@\)\@!" end="^\s*\(#\{1,2}'\)\@!" contains=rOTitle,rOTag,rOExamples,@Spell keepend fold
|
||||
|
||||
" If a block contains an @rdname, @describeIn tag, it may have paragraph breaks, but does not have a title
|
||||
syn region rOBlockNoTitle start="\%^\(\s*#\{1,2}' .*\n\)\{-1,}\s*#\{1,2}'\s*\n\(\s*#\{1,2}'.*\n\)\{-}\s*#\{1,2}' @rdname" end="^\s*\(#\{1,2}'\)\@!" contains=rOTag,rOExamples,@Spell keepend fold
|
||||
syn region rOBlockNoTitle start="^\s*\n\(\s*#\{1,2}' .*\n\)\{-1,}\s*#\{1,2}'\s*\n\(\s*#\{1,2}'.*\n\)\{-}\s*#\{1,2}' @rdname" end="^\s*\(#\{1,2}'\)\@!" contains=rOTag,rOExamples,@Spell keepend fold
|
||||
syn region rOBlockNoTitle start="\%^\(\s*#\{1,2}' .*\n\)\{-1,}\s*#\{1,2}'\s*\n\(\s*#\{1,2}'.*\n\)\{-}\s*#\{1,2}' @describeIn" end="^\s*\(#\{1,2}'\)\@!" contains=rOTag,rOExamples,@Spell keepend fold
|
||||
syn region rOBlockNoTitle start="^\s*\n\(\s*#\{1,2}' .*\n\)\{-1,}\s*#\{1,2}'\s*\n\(\s*#\{1,2}'.*\n\)\{-}\s*#\{1,2}' @describeIn" end="^\s*\(#\{1,2}'\)\@!" contains=rOTag,rOExamples,@Spell keepend fold
|
||||
|
||||
" A title as part of a block is always at the beginning of the block, i.e.
|
||||
" either at the start of a file or after a completely empty line.
|
||||
syn match rOTitle "\%^\(\s*#\{1,2}' .*\n\)\{-1,}\s*#\{1,2}'\s*$" contained contains=rOCommentKey,rOTitleTag
|
||||
syn match rOTitle "^\s*\n\(\s*#\{1,2}' .*\n\)\{-1,}\s*#\{1,2}'\s*$" contained contains=rOCommentKey,rOTitleTag
|
||||
syn match rOTitleTag contained "@title"
|
||||
|
||||
syn match rOCommentKey "#\{1,2}'" contained
|
||||
syn region rOExamples start="^#\{1,2}' @examples.*"rs=e+1,hs=e+1 end="^\(#\{1,2}' @.*\)\@=" end="^\(#\{1,2}'\)\@!" contained contains=rOTag fold
|
||||
|
||||
" rOTag list generated from the lists in
|
||||
" https://github.com/klutometis/roxygen/R/rd.R and
|
||||
" https://github.com/klutometis/roxygen/R/namespace.R
|
||||
" using s/^ \([A-Za-z0-9]*\) = .*/ syn match rOTag contained "@\1"/
|
||||
" Plus we need the @include tag
|
||||
|
||||
" rd.R
|
||||
syn match rOTag contained "@aliases"
|
||||
syn match rOTag contained "@author"
|
||||
syn match rOTag contained "@backref"
|
||||
syn match rOTag contained "@concept"
|
||||
syn match rOTag contained "@describeIn"
|
||||
syn match rOTag contained "@description"
|
||||
syn match rOTag contained "@details"
|
||||
syn match rOTag contained "@docType"
|
||||
syn match rOTag contained "@encoding"
|
||||
syn match rOTag contained "@evalRd"
|
||||
syn match rOTag contained "@example"
|
||||
syn match rOTag contained "@examples"
|
||||
syn match rOTag contained "@family"
|
||||
syn match rOTag contained "@field"
|
||||
syn match rOTag contained "@format"
|
||||
syn match rOTag contained "@inherit"
|
||||
syn match rOTag contained "@inheritParams"
|
||||
syn match rOTag contained "@inheritDotParams"
|
||||
syn match rOTag contained "@inheritSection"
|
||||
syn match rOTag contained "@keywords"
|
||||
syn match rOTag contained "@method"
|
||||
syn match rOTag contained "@name"
|
||||
syn match rOTag contained "@md"
|
||||
syn match rOTag contained "@noMd"
|
||||
syn match rOTag contained "@noRd"
|
||||
syn match rOTag contained "@note"
|
||||
syn match rOTag contained "@param"
|
||||
syn match rOTag contained "@rdname"
|
||||
syn match rOTag contained "@rawRd"
|
||||
syn match rOTag contained "@references"
|
||||
syn match rOTag contained "@return"
|
||||
syn match rOTag contained "@section"
|
||||
syn match rOTag contained "@seealso"
|
||||
syn match rOTag contained "@slot"
|
||||
syn match rOTag contained "@source"
|
||||
syn match rOTag contained "@template"
|
||||
syn match rOTag contained "@templateVar"
|
||||
syn match rOTag contained "@title"
|
||||
syn match rOTag contained "@usage"
|
||||
" namespace.R
|
||||
syn match rOTag contained "@export"
|
||||
syn match rOTag contained "@exportClass"
|
||||
syn match rOTag contained "@exportMethod"
|
||||
syn match rOTag contained "@exportPattern"
|
||||
syn match rOTag contained "@import"
|
||||
syn match rOTag contained "@importClassesFrom"
|
||||
syn match rOTag contained "@importFrom"
|
||||
syn match rOTag contained "@importMethodsFrom"
|
||||
syn match rOTag contained "@rawNamespace"
|
||||
syn match rOTag contained "@S3method"
|
||||
syn match rOTag contained "@useDynLib"
|
||||
" other
|
||||
syn match rOTag contained "@include"
|
||||
endif
|
||||
|
||||
|
||||
@@ -168,12 +267,28 @@ syn match rBraceError "[)}]" contained
|
||||
syn match rCurlyError "[)\]]" contained
|
||||
syn match rParenError "[\]}]" contained
|
||||
|
||||
if !exists("g:R_hi_fun")
|
||||
let g:R_hi_fun = 1
|
||||
" Use Nvim-R to highlight functions dynamically if it is installed
|
||||
if !exists("g:r_syntax_fun_pattern")
|
||||
let s:ff = split(substitute(globpath(&rtp, "R/functions.vim"), "functions.vim", "", "g"), "\n")
|
||||
if len(s:ff) > 0
|
||||
let g:r_syntax_fun_pattern = 0
|
||||
else
|
||||
let g:r_syntax_fun_pattern = 1
|
||||
endif
|
||||
endif
|
||||
if g:R_hi_fun
|
||||
" Nvim-R:
|
||||
runtime R/functions.vim
|
||||
|
||||
" Only use Nvim-R to highlight functions if they should not be highlighted
|
||||
" according to a generic pattern
|
||||
if g:r_syntax_fun_pattern == 1
|
||||
syn match rFunction '[0-9a-zA-Z_\.]\+\s*\ze('
|
||||
else
|
||||
if !exists("g:R_hi_fun")
|
||||
let g:R_hi_fun = 1
|
||||
endif
|
||||
if g:R_hi_fun
|
||||
" Nvim-R:
|
||||
runtime R/functions.vim
|
||||
endif
|
||||
endif
|
||||
|
||||
syn match rDollar display contained "\$"
|
||||
@@ -205,8 +320,8 @@ if &filetype == "rhelp"
|
||||
syn match rhSection "\\dontrun\>"
|
||||
endif
|
||||
|
||||
if exists("r_syn_minlines")
|
||||
exe "syn sync minlines=" . r_syn_minlines
|
||||
if exists("r_syntax_minlines")
|
||||
exe "syn sync minlines=" . r_syntax_minlines
|
||||
else
|
||||
syn sync minlines=40
|
||||
endif
|
||||
@@ -243,15 +358,17 @@ hi def link rStatement Statement
|
||||
hi def link rString String
|
||||
hi def link rStrError Error
|
||||
hi def link rType Type
|
||||
if g:r_hl_roxygen
|
||||
hi def link rOKeyword Title
|
||||
hi def link rOBlock Comment
|
||||
if g:r_syntax_hl_roxygen
|
||||
hi def link rOTitleTag Operator
|
||||
hi def link rOTag Operator
|
||||
hi def link rOTitleBlock Title
|
||||
hi def link rOBlock Comment
|
||||
hi def link rOBlockNoTitle Comment
|
||||
hi def link rOTitle Title
|
||||
hi def link rOCommentKey Comment
|
||||
hi def link rOExamples SpecialComment
|
||||
endif
|
||||
|
||||
|
||||
let b:current_syntax="r"
|
||||
|
||||
" vim: ts=8 sw=2
|
||||
|
||||
Reference in New Issue
Block a user