blob: a8100cfdededf081fd5b831e00515d7c51fd6947 [file] [log] [blame]
Bram Moolenaar071d4272004-06-13 20:20:40 +00001" Vim syntax file
Bram Moolenaar483c5d82010-10-20 18:45:33 +02002" Language: R (GNU S)
3" Maintainer: Jakson Aquino <jalvesaq@gmail.com>
4" Former Maintainers: Vaidotas Zemlys <zemlys@gmail.com>
5" Tom Payne <tom@tompayne.org>
Bram Moolenaar2c5e8e82015-12-05 20:59:21 +01006" Contributor: Johannes Ranke <jranke@uni-bremen.de>
7" Homepage: https://github.com/jalvesaq/R-Vim-runtime
Bram Moolenaar11e3c5b2021-04-21 18:09:37 +02008" Last Change: Sun Mar 28, 2021 01:47PM
Bram Moolenaar483c5d82010-10-20 18:45:33 +02009" Filenames: *.R *.r *.Rhistory *.Rt
Bram Moolenaar8feef4f2015-01-07 16:57:10 +010010"
Bram Moolenaarcd5c8f82017-04-09 20:11:58 +020011" NOTE: The highlighting of R functions might be defined in
Bram Moolenaar8feef4f2015-01-07 16:57:10 +010012" runtime files created by a filetype plugin, if installed.
Bram Moolenaar483c5d82010-10-20 18:45:33 +020013"
Bram Moolenaar662db672011-03-22 14:05:35 +010014" CONFIGURATION:
Bram Moolenaar77cdfd12016-03-12 12:57:59 +010015" Syntax folding can be turned on by
Bram Moolenaar662db672011-03-22 14:05:35 +010016"
17" let r_syntax_folding = 1
18"
Bram Moolenaar77cdfd12016-03-12 12:57:59 +010019" ROxygen highlighting can be turned off by
20"
Bram Moolenaarcd5c8f82017-04-09 20:11:58 +020021" let r_syntax_hl_roxygen = 0
Bram Moolenaar77cdfd12016-03-12 12:57:59 +010022"
Bram Moolenaar483c5d82010-10-20 18:45:33 +020023" Some lines of code were borrowed from Zhuojun Chen.
Bram Moolenaar4770d092006-01-12 23:22:24 +000024
Bram Moolenaar483c5d82010-10-20 18:45:33 +020025if exists("b:current_syntax")
Bram Moolenaar071d4272004-06-13 20:20:40 +000026 finish
27endif
28
Bram Moolenaarcd5c8f82017-04-09 20:11:58 +020029if has("patch-7.4.1142")
30 syn iskeyword @,48-57,_,.
31else
32 setlocal iskeyword=@,48-57,_,.
33endif
34
35" The variables g:r_hl_roxygen and g:r_syn_minlines were renamed on April 8, 2017.
36if exists("g:r_hl_roxygen")
37 let g:r_syntax_hl_roxygen = g:r_hl_roxygen
38endif
39if exists("g:r_syn_minlines")
40 let g:r_syntax_minlines = g:r_syn_minlines
41endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000042
Bram Moolenaar77cdfd12016-03-12 12:57:59 +010043if exists("g:r_syntax_folding") && g:r_syntax_folding
Bram Moolenaar662db672011-03-22 14:05:35 +010044 setlocal foldmethod=syntax
45endif
Bram Moolenaarfc65cab2018-08-28 22:58:02 +020046
47let g:r_syntax_hl_roxygen = get(g:, 'r_syntax_hl_roxygen', 1)
Bram Moolenaar662db672011-03-22 14:05:35 +010048
Bram Moolenaar071d4272004-06-13 20:20:40 +000049syn case match
50
51" Comment
Bram Moolenaardb6ea062014-07-10 22:01:47 +020052syn match rCommentTodo contained "\(BUG\|FIXME\|NOTE\|TODO\):"
Bram Moolenaarfc65cab2018-08-28 22:58:02 +020053syn match rTodoParen contained "\(BUG\|FIXME\|NOTE\|TODO\)\s*(.\{-})\s*:" contains=rTodoKeyw,rTodoInfo transparent
54syn keyword rTodoKeyw BUG FIXME NOTE TODO contained
55syn match rTodoInfo "(\zs.\{-}\ze)" contained
Bram Moolenaar11e3c5b2021-04-21 18:09:37 +020056syn match rComment contains=@Spell,rCommentTodo,rTodoParen "#.*"
Bram Moolenaar203d04d2013-06-06 21:36:40 +020057
58" Roxygen
Bram Moolenaarcd5c8f82017-04-09 20:11:58 +020059if g:r_syntax_hl_roxygen
60 " A roxygen block can start at the beginning of a file (first version) and
Bram Moolenaar11e3c5b2021-04-21 18:09:37 +020061 " after a blank line (second version). It ends when a line appears that does not
Bram Moolenaarcd5c8f82017-04-09 20:11:58 +020062 " contain a roxygen comment. In the following comments, any line containing
63 " a roxygen comment marker (one or two hash signs # followed by a single
64 " quote ' and preceded only by whitespace) is called a roxygen line. A
65 " roxygen line containing only a roxygen comment marker, optionally followed
66 " by whitespace is called an empty roxygen line.
Bram Moolenaar2c5e8e82015-12-05 20:59:21 +010067
Bram Moolenaarcd5c8f82017-04-09 20:11:58 +020068 " First we match all roxygen blocks as containing only a title. In case an
69 " empty roxygen line ending the title or a tag is found, this will be
Bram Moolenaarfc65cab2018-08-28 22:58:02 +020070 " overridden later by the definitions of rOBlock.
Bram Moolenaarcd5c8f82017-04-09 20:11:58 +020071 syn match rOTitleBlock "\%^\(\s*#\{1,2}' .*\n\)\{1,}" contains=rOCommentKey,rOTitleTag
72 syn match rOTitleBlock "^\s*\n\(\s*#\{1,2}' .*\n\)\{1,}" contains=rOCommentKey,rOTitleTag
Bram Moolenaar2c5e8e82015-12-05 20:59:21 +010073
Bram Moolenaar11e3c5b2021-04-21 18:09:37 +020074 " A title as part of a block is always at the beginning of the block, i.e.
75 " either at the start of a file or after a completely empty line.
76 syn match rOTitle "\%^\(\s*#\{1,2}' .*\n\)\{-1,}\s*#\{1,2}'\s*$" contained contains=rOCommentKey,rOTitleTag
77 syn match rOTitle "^\s*\n\(\s*#\{1,2}' .*\n\)\{-1,}\s*#\{1,2}'\s*$" contained contains=rOCommentKey,rOTitleTag
78 syn match rOTitleTag contained "@title"
79
Bram Moolenaarcd5c8f82017-04-09 20:11:58 +020080 " When a roxygen block has a title and additional content, the title
81 " consists of one or more roxygen lines (as little as possible are matched),
82 " followed either by an empty roxygen line
83 syn region rOBlock start="\%^\(\s*#\{1,2}' .*\n\)\{-1,}\s*#\{1,2}'\s*$" end="^\s*\(#\{1,2}'\)\@!" contains=rOTitle,rOTag,rOExamples,@Spell keepend fold
84 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
85
86 " or by a roxygen tag (we match everything starting with @ but not @@ which is used as escape sequence for a literal @).
87 syn region rOBlock start="\%^\(\s*#\{1,2}' .*\n\)\{-}\s*#\{1,2}' @\(@\)\@!" end="^\s*\(#\{1,2}'\)\@!" contains=rOTitle,rOTag,rOExamples,@Spell keepend fold
88 syn region rOBlock start="^\s*\n\(\s*#\{1,2}' .*\n\)\{-}\s*#\{1,2}' @\(@\)\@!" end="^\s*\(#\{1,2}'\)\@!" contains=rOTitle,rOTag,rOExamples,@Spell keepend fold
89
90 " If a block contains an @rdname, @describeIn tag, it may have paragraph breaks, but does not have a title
91 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
92 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
93 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
94 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
95
Bram Moolenaarfc65cab2018-08-28 22:58:02 +020096 syn match rOCommentKey "^\s*#\{1,2}'" contained
Bram Moolenaar11e3c5b2021-04-21 18:09:37 +020097 syn region rOExamples start="^\s*#\{1,2}' @examples.*"rs=e+1,hs=e+1 end="^\(#\{1,2}' @.*\)\@=" end="^\(#\{1,2}'\)\@!" contained contains=rOTag fold
Bram Moolenaarcd5c8f82017-04-09 20:11:58 +020098
Bram Moolenaar11e3c5b2021-04-21 18:09:37 +020099 " R6 classes may contain roxygen lines independent of roxygen blocks
100 syn region rOR6Class start=/R6Class(/ end=/)/ transparent contains=ALLBUT,rError,rBraceError,rCurlyError fold
101 syn match rOR6Block "#\{1,2}'.*" contains=rOTag,rOExamples,@Spell containedin=rOR6Class contained
102 syn match rOR6Block "^\s*#\{1,2}'.*" contains=rOTag,rOExamples,@Spell containedin=rOR6Class contained
103
104 " rOTag list originally generated from the lists that were available in
Bram Moolenaarcd5c8f82017-04-09 20:11:58 +0200105 " https://github.com/klutometis/roxygen/R/rd.R and
106 " https://github.com/klutometis/roxygen/R/namespace.R
107 " using s/^ \([A-Za-z0-9]*\) = .*/ syn match rOTag contained "@\1"/
108 " Plus we need the @include tag
109
110 " rd.R
111 syn match rOTag contained "@aliases"
112 syn match rOTag contained "@author"
113 syn match rOTag contained "@backref"
114 syn match rOTag contained "@concept"
115 syn match rOTag contained "@describeIn"
116 syn match rOTag contained "@description"
117 syn match rOTag contained "@details"
118 syn match rOTag contained "@docType"
119 syn match rOTag contained "@encoding"
120 syn match rOTag contained "@evalRd"
121 syn match rOTag contained "@example"
122 syn match rOTag contained "@examples"
123 syn match rOTag contained "@family"
124 syn match rOTag contained "@field"
125 syn match rOTag contained "@format"
126 syn match rOTag contained "@inherit"
127 syn match rOTag contained "@inheritParams"
128 syn match rOTag contained "@inheritDotParams"
129 syn match rOTag contained "@inheritSection"
130 syn match rOTag contained "@keywords"
131 syn match rOTag contained "@method"
132 syn match rOTag contained "@name"
133 syn match rOTag contained "@md"
134 syn match rOTag contained "@noMd"
135 syn match rOTag contained "@noRd"
136 syn match rOTag contained "@note"
137 syn match rOTag contained "@param"
138 syn match rOTag contained "@rdname"
139 syn match rOTag contained "@rawRd"
140 syn match rOTag contained "@references"
141 syn match rOTag contained "@return"
142 syn match rOTag contained "@section"
143 syn match rOTag contained "@seealso"
144 syn match rOTag contained "@slot"
145 syn match rOTag contained "@source"
146 syn match rOTag contained "@template"
147 syn match rOTag contained "@templateVar"
148 syn match rOTag contained "@title"
149 syn match rOTag contained "@usage"
150 " namespace.R
151 syn match rOTag contained "@export"
152 syn match rOTag contained "@exportClass"
153 syn match rOTag contained "@exportMethod"
154 syn match rOTag contained "@exportPattern"
155 syn match rOTag contained "@import"
156 syn match rOTag contained "@importClassesFrom"
157 syn match rOTag contained "@importFrom"
158 syn match rOTag contained "@importMethodsFrom"
159 syn match rOTag contained "@rawNamespace"
160 syn match rOTag contained "@S3method"
161 syn match rOTag contained "@useDynLib"
162 " other
Bram Moolenaar11e3c5b2021-04-21 18:09:37 +0200163 syn match rOTag contained "@eval"
Bram Moolenaarcd5c8f82017-04-09 20:11:58 +0200164 syn match rOTag contained "@include"
Bram Moolenaar11e3c5b2021-04-21 18:09:37 +0200165 syn match rOTag contained "@includeRmd"
166 syn match rOTag contained "@order"
Bram Moolenaar77cdfd12016-03-12 12:57:59 +0100167endif
Bram Moolenaar203d04d2013-06-06 21:36:40 +0200168
Bram Moolenaar071d4272004-06-13 20:20:40 +0000169
Bram Moolenaar662db672011-03-22 14:05:35 +0100170if &filetype == "rhelp"
171 " string enclosed in double quotes
172 syn region rString contains=rSpecial,@Spell start=/"/ skip=/\\\\\|\\"/ end=/"/
173 " string enclosed in single quotes
174 syn region rString contains=rSpecial,@Spell start=/'/ skip=/\\\\\|\\'/ end=/'/
175else
176 " string enclosed in double quotes
177 syn region rString contains=rSpecial,rStrError,@Spell start=/"/ skip=/\\\\\|\\"/ end=/"/
178 " string enclosed in single quotes
179 syn region rString contains=rSpecial,rStrError,@Spell start=/'/ skip=/\\\\\|\\'/ end=/'/
180endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000181
Bram Moolenaar483c5d82010-10-20 18:45:33 +0200182syn match rStrError display contained "\\."
183
Bram Moolenaar662db672011-03-22 14:05:35 +0100184
Bram Moolenaar483c5d82010-10-20 18:45:33 +0200185" New line, carriage return, tab, backspace, bell, feed, vertical tab, backslash
186syn match rSpecial display contained "\\\(n\|r\|t\|b\|a\|f\|v\|'\|\"\)\|\\\\"
187
188" Hexadecimal and Octal digits
189syn match rSpecial display contained "\\\(x\x\{1,2}\|[0-8]\{1,3}\)"
190
191" Unicode characters
192syn match rSpecial display contained "\\u\x\{1,4}"
193syn match rSpecial display contained "\\U\x\{1,8}"
194syn match rSpecial display contained "\\u{\x\{1,4}}"
195syn match rSpecial display contained "\\U{\x\{1,8}}"
196
Bram Moolenaar11e3c5b2021-04-21 18:09:37 +0200197" Raw string
198syn region rRawString matchgroup=rRawStrDelim start=/[rR]\z(['"]\)\z(-*\)(/ end=/)\z2\z1/ keepend
199syn region rRawString matchgroup=rRawStrDelim start=/[rR]\z(['"]\)\z(-*\){/ end=/}\z2\z1/ keepend
200syn region rRawString matchgroup=rRawStrDelim start=/[rR]\z(['"]\)\z(-*\)\[/ end=/\]\z2\z1/ keepend
201
Bram Moolenaar071d4272004-06-13 20:20:40 +0000202" Statement
203syn keyword rStatement break next return
204syn keyword rConditional if else
205syn keyword rRepeat for in repeat while
206
Bram Moolenaar483c5d82010-10-20 18:45:33 +0200207" Constant (not really)
Bram Moolenaar203d04d2013-06-06 21:36:40 +0200208syn keyword rConstant T F LETTERS letters month.abb month.name pi
Bram Moolenaar483c5d82010-10-20 18:45:33 +0200209syn keyword rConstant R.version.string
210
Bram Moolenaar8feef4f2015-01-07 16:57:10 +0100211syn keyword rNumber NA_integer_ NA_real_ NA_complex_ NA_character_
Bram Moolenaar662db672011-03-22 14:05:35 +0100212
213" Constants
Bram Moolenaar071d4272004-06-13 20:20:40 +0000214syn keyword rConstant NULL
215syn keyword rBoolean FALSE TRUE
Bram Moolenaar8feef4f2015-01-07 16:57:10 +0100216syn keyword rNumber NA Inf NaN
Bram Moolenaar071d4272004-06-13 20:20:40 +0000217
Bram Moolenaar483c5d82010-10-20 18:45:33 +0200218" integer
219syn match rInteger "\<\d\+L"
220syn match rInteger "\<0x\([0-9]\|[a-f]\|[A-F]\)\+L"
221syn match rInteger "\<\d\+[Ee]+\=\d\+L"
222
Bram Moolenaar483c5d82010-10-20 18:45:33 +0200223" number with no fractional part or exponent
224syn match rNumber "\<\d\+\>"
Bram Moolenaar8feef4f2015-01-07 16:57:10 +0100225" hexadecimal number
Bram Moolenaar483c5d82010-10-20 18:45:33 +0200226syn match rNumber "\<0x\([0-9]\|[a-f]\|[A-F]\)\+"
227
228" floating point number with integer and fractional parts and optional exponent
229syn match rFloat "\<\d\+\.\d*\([Ee][-+]\=\d\+\)\="
230" floating point number with no integer part and optional exponent
231syn match rFloat "\<\.\d\+\([Ee][-+]\=\d\+\)\="
232" floating point number with no fractional part and optional exponent
233syn match rFloat "\<\d\+[Ee][-+]\=\d\+"
234
Bram Moolenaar662db672011-03-22 14:05:35 +0100235" complex number
236syn match rComplex "\<\d\+i"
237syn match rComplex "\<\d\++\d\+i"
238syn match rComplex "\<0x\([0-9]\|[a-f]\|[A-F]\)\+i"
239syn match rComplex "\<\d\+\.\d*\([Ee][-+]\=\d\+\)\=i"
240syn match rComplex "\<\.\d\+\([Ee][-+]\=\d\+\)\=i"
241syn match rComplex "\<\d\+[Ee][-+]\=\d\+i"
242
Bram Moolenaar8feef4f2015-01-07 16:57:10 +0100243syn match rAssign '='
Bram Moolenaar662db672011-03-22 14:05:35 +0100244syn match rOperator "&"
245syn match rOperator '-'
Bram Moolenaare6ae6222013-05-21 21:01:10 +0200246syn match rOperator '\*'
Bram Moolenaar662db672011-03-22 14:05:35 +0100247syn match rOperator '+'
Bram Moolenaar203d04d2013-06-06 21:36:40 +0200248if &filetype != "rmd" && &filetype != "rrst"
249 syn match rOperator "[|!<>^~/:]"
250else
251 syn match rOperator "[|!<>^~`/:]"
252endif
Bram Moolenaardb6ea062014-07-10 22:01:47 +0200253syn match rOperator "%\{2}\|%\S\{-}%"
Bram Moolenaar8feef4f2015-01-07 16:57:10 +0100254syn match rOperator '\([!><]\)\@<=='
255syn match rOperator '=='
Bram Moolenaar203d04d2013-06-06 21:36:40 +0200256syn match rOpError '\*\{3}'
Bram Moolenaar662db672011-03-22 14:05:35 +0100257syn match rOpError '//'
258syn match rOpError '&&&'
259syn match rOpError '|||'
260syn match rOpError '<<'
261syn match rOpError '>>'
262
Bram Moolenaar8feef4f2015-01-07 16:57:10 +0100263syn match rAssign "<\{1,2}-"
264syn match rAssign "->\{1,2}"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000265
266" Special
Bram Moolenaar483c5d82010-10-20 18:45:33 +0200267syn match rDelimiter "[,;:]"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000268
269" Error
Bram Moolenaar662db672011-03-22 14:05:35 +0100270if exists("g:r_syntax_folding")
271 syn region rRegion matchgroup=Delimiter start=/(/ matchgroup=Delimiter end=/)/ transparent contains=ALLBUT,rError,rBraceError,rCurlyError fold
272 syn region rRegion matchgroup=Delimiter start=/{/ matchgroup=Delimiter end=/}/ transparent contains=ALLBUT,rError,rBraceError,rParenError fold
273 syn region rRegion matchgroup=Delimiter start=/\[/ matchgroup=Delimiter end=/]/ transparent contains=ALLBUT,rError,rCurlyError,rParenError fold
Bram Moolenaarfc65cab2018-08-28 22:58:02 +0200274 syn region rSection matchgroup=Title start=/^#.*[-=#]\{4,}/ end=/^#.*[-=#]\{4,}/ms=s-2,me=s-1 transparent contains=ALL fold
Bram Moolenaar662db672011-03-22 14:05:35 +0100275else
276 syn region rRegion matchgroup=Delimiter start=/(/ matchgroup=Delimiter end=/)/ transparent contains=ALLBUT,rError,rBraceError,rCurlyError
277 syn region rRegion matchgroup=Delimiter start=/{/ matchgroup=Delimiter end=/}/ transparent contains=ALLBUT,rError,rBraceError,rParenError
278 syn region rRegion matchgroup=Delimiter start=/\[/ matchgroup=Delimiter end=/]/ transparent contains=ALLBUT,rError,rCurlyError,rParenError
279endif
280
Bram Moolenaar483c5d82010-10-20 18:45:33 +0200281syn match rError "[)\]}]"
282syn match rBraceError "[)}]" contained
283syn match rCurlyError "[)\]]" contained
284syn match rParenError "[\]}]" contained
285
Bram Moolenaarcd5c8f82017-04-09 20:11:58 +0200286" Use Nvim-R to highlight functions dynamically if it is installed
287if !exists("g:r_syntax_fun_pattern")
288 let s:ff = split(substitute(globpath(&rtp, "R/functions.vim"), "functions.vim", "", "g"), "\n")
289 if len(s:ff) > 0
290 let g:r_syntax_fun_pattern = 0
291 else
292 let g:r_syntax_fun_pattern = 1
293 endif
Bram Moolenaar77cdfd12016-03-12 12:57:59 +0100294endif
Bram Moolenaarcd5c8f82017-04-09 20:11:58 +0200295
296" Only use Nvim-R to highlight functions if they should not be highlighted
297" according to a generic pattern
298if g:r_syntax_fun_pattern == 1
299 syn match rFunction '[0-9a-zA-Z_\.]\+\s*\ze('
300else
Bram Moolenaarfc65cab2018-08-28 22:58:02 +0200301 " Nvim-R:
302 runtime R/functions.vim
Bram Moolenaar8feef4f2015-01-07 16:57:10 +0100303endif
Bram Moolenaar662db672011-03-22 14:05:35 +0100304
305syn match rDollar display contained "\$"
Bram Moolenaar203d04d2013-06-06 21:36:40 +0200306syn match rDollar display contained "@"
Bram Moolenaar662db672011-03-22 14:05:35 +0100307
308" List elements will not be highlighted as functions:
309syn match rLstElmt "\$[a-zA-Z0-9\\._]*" contains=rDollar
Bram Moolenaar203d04d2013-06-06 21:36:40 +0200310syn match rLstElmt "@[a-zA-Z0-9\\._]*" contains=rDollar
Bram Moolenaar662db672011-03-22 14:05:35 +0100311
Bram Moolenaar483c5d82010-10-20 18:45:33 +0200312" Functions that may add new objects
313syn keyword rPreProc library require attach detach source
314
Bram Moolenaar662db672011-03-22 14:05:35 +0100315if &filetype == "rhelp"
Bram Moolenaardb6ea062014-07-10 22:01:47 +0200316 syn match rHelpIdent '\\method'
317 syn match rHelpIdent '\\S4method'
Bram Moolenaar662db672011-03-22 14:05:35 +0100318endif
319
Bram Moolenaar483c5d82010-10-20 18:45:33 +0200320" Type
Bram Moolenaar8feef4f2015-01-07 16:57:10 +0100321syn keyword rType array category character complex double function integer list logical matrix numeric vector data.frame
Bram Moolenaar071d4272004-06-13 20:20:40 +0000322
Bram Moolenaar662db672011-03-22 14:05:35 +0100323" Name of object with spaces
Bram Moolenaar203d04d2013-06-06 21:36:40 +0200324if &filetype != "rmd" && &filetype != "rrst"
Bram Moolenaarfc65cab2018-08-28 22:58:02 +0200325 syn region rNameWSpace start="`" end="`" contains=rSpaceFun
Bram Moolenaar203d04d2013-06-06 21:36:40 +0200326endif
Bram Moolenaar662db672011-03-22 14:05:35 +0100327
328if &filetype == "rhelp"
Bram Moolenaar8feef4f2015-01-07 16:57:10 +0100329 syn match rhPreProc "^#ifdef.*"
330 syn match rhPreProc "^#endif.*"
Bram Moolenaar662db672011-03-22 14:05:35 +0100331 syn match rhSection "\\dontrun\>"
332endif
333
Bram Moolenaarcd5c8f82017-04-09 20:11:58 +0200334if exists("r_syntax_minlines")
335 exe "syn sync minlines=" . r_syntax_minlines
Bram Moolenaar8feef4f2015-01-07 16:57:10 +0100336else
337 syn sync minlines=40
338endif
339
Bram Moolenaar071d4272004-06-13 20:20:40 +0000340" Define the default highlighting.
Bram Moolenaar8feef4f2015-01-07 16:57:10 +0100341hi def link rAssign Statement
Bram Moolenaar483c5d82010-10-20 18:45:33 +0200342hi def link rBoolean Boolean
343hi def link rBraceError Error
344hi def link rComment Comment
Bram Moolenaarfc65cab2018-08-28 22:58:02 +0200345hi def link rTodoParen Comment
346hi def link rTodoInfo SpecialComment
Bram Moolenaardb6ea062014-07-10 22:01:47 +0200347hi def link rCommentTodo Todo
Bram Moolenaarfc65cab2018-08-28 22:58:02 +0200348hi def link rTodoKeyw Todo
Bram Moolenaar483c5d82010-10-20 18:45:33 +0200349hi def link rComplex Number
350hi def link rConditional Conditional
351hi def link rConstant Constant
352hi def link rCurlyError Error
353hi def link rDelimiter Delimiter
354hi def link rDollar SpecialChar
355hi def link rError Error
356hi def link rFloat Float
Bram Moolenaar662db672011-03-22 14:05:35 +0100357hi def link rFunction Function
Bram Moolenaarfc65cab2018-08-28 22:58:02 +0200358hi def link rSpaceFun Function
Bram Moolenaar662db672011-03-22 14:05:35 +0100359hi def link rHelpIdent Identifier
360hi def link rhPreProc PreProc
361hi def link rhSection PreCondit
Bram Moolenaar483c5d82010-10-20 18:45:33 +0200362hi def link rInteger Number
Bram Moolenaar8feef4f2015-01-07 16:57:10 +0100363hi def link rLstElmt Normal
Bram Moolenaar662db672011-03-22 14:05:35 +0100364hi def link rNameWSpace Normal
Bram Moolenaar483c5d82010-10-20 18:45:33 +0200365hi def link rNumber Number
366hi def link rOperator Operator
Bram Moolenaar662db672011-03-22 14:05:35 +0100367hi def link rOpError Error
Bram Moolenaar483c5d82010-10-20 18:45:33 +0200368hi def link rParenError Error
369hi def link rPreProc PreProc
Bram Moolenaar11e3c5b2021-04-21 18:09:37 +0200370hi def link rRawString String
371hi def link rRawStrDelim Delimiter
Bram Moolenaar483c5d82010-10-20 18:45:33 +0200372hi def link rRepeat Repeat
373hi def link rSpecial SpecialChar
374hi def link rStatement Statement
375hi def link rString String
376hi def link rStrError Error
377hi def link rType Type
Bram Moolenaarcd5c8f82017-04-09 20:11:58 +0200378if g:r_syntax_hl_roxygen
379 hi def link rOTitleTag Operator
380 hi def link rOTag Operator
381 hi def link rOTitleBlock Title
382 hi def link rOBlock Comment
383 hi def link rOBlockNoTitle Comment
Bram Moolenaar11e3c5b2021-04-21 18:09:37 +0200384 hi def link rOR6Block Comment
Bram Moolenaar77cdfd12016-03-12 12:57:59 +0100385 hi def link rOTitle Title
386 hi def link rOCommentKey Comment
387 hi def link rOExamples SpecialComment
388endif
Bram Moolenaar2c5e8e82015-12-05 20:59:21 +0100389
Bram Moolenaar071d4272004-06-13 20:20:40 +0000390let b:current_syntax="r"
391
392" vim: ts=8 sw=2