summaryrefslogtreecommitdiffstats
path: root/runtime/syntax/r.vim
diff options
context:
space:
mode:
Diffstat (limited to 'runtime/syntax/r.vim')
-rw-r--r--runtime/syntax/r.vim38
1 files changed, 27 insertions, 11 deletions
diff --git a/runtime/syntax/r.vim b/runtime/syntax/r.vim
index 9e25dae363..a8100cfded 100644
--- a/runtime/syntax/r.vim
+++ b/runtime/syntax/r.vim
@@ -5,7 +5,7 @@
" Tom Payne <tom@tompayne.org>
" Contributor: Johannes Ranke <jranke@uni-bremen.de>
" Homepage: https://github.com/jalvesaq/R-Vim-runtime
-" Last Change: Wed Aug 01, 2018 10:10PM
+" Last Change: Sun Mar 28, 2021 01:47PM
" Filenames: *.R *.r *.Rhistory *.Rt
"
" NOTE: The highlighting of R functions might be defined in
@@ -53,12 +53,12 @@ syn match rCommentTodo contained "\(BUG\|FIXME\|NOTE\|TODO\):"
syn match rTodoParen contained "\(BUG\|FIXME\|NOTE\|TODO\)\s*(.\{-})\s*:" contains=rTodoKeyw,rTodoInfo transparent
syn keyword rTodoKeyw BUG FIXME NOTE TODO contained
syn match rTodoInfo "(\zs.\{-}\ze)" contained
-syn match rComment contains=@Spell,rCommentTodo,rTodoParen,rOBlock "#.*"
+syn match rComment contains=@Spell,rCommentTodo,rTodoParen "#.*"
" Roxygen
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
+ " after a blank line (second version). It ends when a line appears 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
@@ -71,6 +71,12 @@ if g:r_syntax_hl_roxygen
syn match rOTitleBlock "\%^\(\s*#\{1,2}' .*\n\)\{1,}" contains=rOCommentKey,rOTitleTag
syn match rOTitleBlock "^\s*\n\(\s*#\{1,2}' .*\n\)\{1,}" contains=rOCommentKey,rOTitleTag
+ " 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"
+
" 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
@@ -87,16 +93,15 @@ if g:r_syntax_hl_roxygen
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 "^\s*#\{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
+ syn region rOExamples start="^\s*#\{1,2}' @examples.*"rs=e+1,hs=e+1 end="^\(#\{1,2}' @.*\)\@=" end="^\(#\{1,2}'\)\@!" contained contains=rOTag fold
+
+ " R6 classes may contain roxygen lines independent of roxygen blocks
+ syn region rOR6Class start=/R6Class(/ end=/)/ transparent contains=ALLBUT,rError,rBraceError,rCurlyError fold
+ syn match rOR6Block "#\{1,2}'.*" contains=rOTag,rOExamples,@Spell containedin=rOR6Class contained
+ syn match rOR6Block "^\s*#\{1,2}'.*" contains=rOTag,rOExamples,@Spell containedin=rOR6Class contained
- " rOTag list generated from the lists in
+ " rOTag list originally generated from the lists that were available 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"/
@@ -155,7 +160,10 @@ if g:r_syntax_hl_roxygen
syn match rOTag contained "@S3method"
syn match rOTag contained "@useDynLib"
" other
+ syn match rOTag contained "@eval"
syn match rOTag contained "@include"
+ syn match rOTag contained "@includeRmd"
+ syn match rOTag contained "@order"
endif
@@ -186,6 +194,11 @@ syn match rSpecial display contained "\\U\x\{1,8}"
syn match rSpecial display contained "\\u{\x\{1,4}}"
syn match rSpecial display contained "\\U{\x\{1,8}}"
+" Raw string
+syn region rRawString matchgroup=rRawStrDelim start=/[rR]\z(['"]\)\z(-*\)(/ end=/)\z2\z1/ keepend
+syn region rRawString matchgroup=rRawStrDelim start=/[rR]\z(['"]\)\z(-*\){/ end=/}\z2\z1/ keepend
+syn region rRawString matchgroup=rRawStrDelim start=/[rR]\z(['"]\)\z(-*\)\[/ end=/\]\z2\z1/ keepend
+
" Statement
syn keyword rStatement break next return
syn keyword rConditional if else
@@ -354,6 +367,8 @@ hi def link rOperator Operator
hi def link rOpError Error
hi def link rParenError Error
hi def link rPreProc PreProc
+hi def link rRawString String
+hi def link rRawStrDelim Delimiter
hi def link rRepeat Repeat
hi def link rSpecial SpecialChar
hi def link rStatement Statement
@@ -366,6 +381,7 @@ if g:r_syntax_hl_roxygen
hi def link rOTitleBlock Title
hi def link rOBlock Comment
hi def link rOBlockNoTitle Comment
+ hi def link rOR6Block Comment
hi def link rOTitle Title
hi def link rOCommentKey Comment
hi def link rOExamples SpecialComment