blob: 1932d2479a316ad605319f2d2cbe97f196cd0012 [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
Jakson Alves de Aquino9042bd82023-12-25 09:22:27 +00008" Last Change: Sun Dec 24, 2023 08:05AM
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
Jakson Alves de Aquino9042bd82023-12-25 09:22:27 +000029syn iskeyword @,48-57,_,.
Bram Moolenaarcd5c8f82017-04-09 20:11:58 +020030
31" The variables g:r_hl_roxygen and g:r_syn_minlines were renamed on April 8, 2017.
32if exists("g:r_hl_roxygen")
33 let g:r_syntax_hl_roxygen = g:r_hl_roxygen
34endif
35if exists("g:r_syn_minlines")
36 let g:r_syntax_minlines = g:r_syn_minlines
37endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000038
Bram Moolenaar77cdfd12016-03-12 12:57:59 +010039if exists("g:r_syntax_folding") && g:r_syntax_folding
Bram Moolenaar662db672011-03-22 14:05:35 +010040 setlocal foldmethod=syntax
41endif
Bram Moolenaarfc65cab2018-08-28 22:58:02 +020042
43let g:r_syntax_hl_roxygen = get(g:, 'r_syntax_hl_roxygen', 1)
Bram Moolenaar662db672011-03-22 14:05:35 +010044
Bram Moolenaar071d4272004-06-13 20:20:40 +000045syn case match
46
47" Comment
Bram Moolenaardb6ea062014-07-10 22:01:47 +020048syn match rCommentTodo contained "\(BUG\|FIXME\|NOTE\|TODO\):"
Bram Moolenaarfc65cab2018-08-28 22:58:02 +020049syn match rTodoParen contained "\(BUG\|FIXME\|NOTE\|TODO\)\s*(.\{-})\s*:" contains=rTodoKeyw,rTodoInfo transparent
50syn keyword rTodoKeyw BUG FIXME NOTE TODO contained
51syn match rTodoInfo "(\zs.\{-}\ze)" contained
Bram Moolenaar11e3c5b2021-04-21 18:09:37 +020052syn match rComment contains=@Spell,rCommentTodo,rTodoParen "#.*"
Bram Moolenaar203d04d2013-06-06 21:36:40 +020053
54" Roxygen
Bram Moolenaarcd5c8f82017-04-09 20:11:58 +020055if g:r_syntax_hl_roxygen
56 " A roxygen block can start at the beginning of a file (first version) and
Bram Moolenaar11e3c5b2021-04-21 18:09:37 +020057 " after a blank line (second version). It ends when a line appears that does not
Bram Moolenaarcd5c8f82017-04-09 20:11:58 +020058 " contain a roxygen comment. In the following comments, any line containing
59 " a roxygen comment marker (one or two hash signs # followed by a single
60 " quote ' and preceded only by whitespace) is called a roxygen line. A
61 " roxygen line containing only a roxygen comment marker, optionally followed
62 " by whitespace is called an empty roxygen line.
Bram Moolenaar2c5e8e82015-12-05 20:59:21 +010063
Bram Moolenaardd60c362023-02-27 15:49:53 +000064 syn match rOCommentKey "^\s*#\{1,2}'" contained
65 syn region rOExamples start="^\s*#\{1,2}' @examples.*"rs=e+1,hs=e+1 end="^\(#\{1,2}' @.*\)\@=" end="^\(#\{1,2}'\)\@!" contained contains=rOTag fold
66
67 " R6 classes may contain roxygen lines independent of roxygen blocks
68 syn region rOR6Class start=/R6Class(/ end=/)/ transparent contains=ALLBUT,rError,rBraceError,rCurlyError fold
69 syn match rOR6Block "#\{1,2}'.*" contains=rOTag,rOExamples,@Spell containedin=rOR6Class contained
70 syn match rOR6Block "^\s*#\{1,2}'.*" contains=rOTag,rOExamples,@Spell containedin=rOR6Class contained
71
Bram Moolenaarcd5c8f82017-04-09 20:11:58 +020072 " First we match all roxygen blocks as containing only a title. In case an
73 " empty roxygen line ending the title or a tag is found, this will be
Bram Moolenaarfc65cab2018-08-28 22:58:02 +020074 " overridden later by the definitions of rOBlock.
Bram Moolenaardd60c362023-02-27 15:49:53 +000075 syn match rOTitleBlock "\(\%^\|^\s*\n\)\@<=\(\s*#\{1,2}' .*\n\)\{1,}" contains=rOCommentKey,rOTitleTag
Bram Moolenaar2c5e8e82015-12-05 20:59:21 +010076
Bram Moolenaar11e3c5b2021-04-21 18:09:37 +020077 " A title as part of a block is always at the beginning of the block, i.e.
78 " either at the start of a file or after a completely empty line.
Bram Moolenaardd60c362023-02-27 15:49:53 +000079 syn match rOTitle "\(\%^\|^\s*\n\)\@<=\(\s*#\{1,2}' .*\n\)\{-1,}\s*#\{1,2}'\s*$" contained contains=rOCommentKey,rOTitleTag
Bram Moolenaar11e3c5b2021-04-21 18:09:37 +020080 syn match rOTitleTag contained "@title"
81
Bram Moolenaarcd5c8f82017-04-09 20:11:58 +020082 " When a roxygen block has a title and additional content, the title
83 " consists of one or more roxygen lines (as little as possible are matched),
84 " followed either by an empty roxygen line
Bram Moolenaardd60c362023-02-27 15:49:53 +000085 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
Bram Moolenaarcd5c8f82017-04-09 20:11:58 +020086
87 " or by a roxygen tag (we match everything starting with @ but not @@ which is used as escape sequence for a literal @).
Bram Moolenaardd60c362023-02-27 15:49:53 +000088 syn region rOBlock start="\(\%^\|^\s*\n\)\@<=\(\s*#\{1,2}' .*\n\)\{-}\s*#\{1,2}' @\(@\)\@!" end="^\s*\(#\{1,2}'\)\@!" contains=rOTitle,rOTag,rOExamples,@Spell keepend fold
Bram Moolenaarcd5c8f82017-04-09 20:11:58 +020089
90 " If a block contains an @rdname, @describeIn tag, it may have paragraph breaks, but does not have a title
Bram Moolenaardd60c362023-02-27 15:49:53 +000091 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
92 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
Bram Moolenaar11e3c5b2021-04-21 18:09:37 +020093
94 " rOTag list originally generated from the lists that were available in
Bram Moolenaarcd5c8f82017-04-09 20:11:58 +020095 " https://github.com/klutometis/roxygen/R/rd.R and
96 " https://github.com/klutometis/roxygen/R/namespace.R
97 " using s/^ \([A-Za-z0-9]*\) = .*/ syn match rOTag contained "@\1"/
98 " Plus we need the @include tag
99
100 " rd.R
101 syn match rOTag contained "@aliases"
102 syn match rOTag contained "@author"
103 syn match rOTag contained "@backref"
104 syn match rOTag contained "@concept"
105 syn match rOTag contained "@describeIn"
106 syn match rOTag contained "@description"
107 syn match rOTag contained "@details"
108 syn match rOTag contained "@docType"
109 syn match rOTag contained "@encoding"
110 syn match rOTag contained "@evalRd"
111 syn match rOTag contained "@example"
112 syn match rOTag contained "@examples"
113 syn match rOTag contained "@family"
114 syn match rOTag contained "@field"
115 syn match rOTag contained "@format"
116 syn match rOTag contained "@inherit"
117 syn match rOTag contained "@inheritParams"
118 syn match rOTag contained "@inheritDotParams"
119 syn match rOTag contained "@inheritSection"
120 syn match rOTag contained "@keywords"
121 syn match rOTag contained "@method"
122 syn match rOTag contained "@name"
123 syn match rOTag contained "@md"
124 syn match rOTag contained "@noMd"
125 syn match rOTag contained "@noRd"
126 syn match rOTag contained "@note"
127 syn match rOTag contained "@param"
128 syn match rOTag contained "@rdname"
129 syn match rOTag contained "@rawRd"
130 syn match rOTag contained "@references"
131 syn match rOTag contained "@return"
132 syn match rOTag contained "@section"
133 syn match rOTag contained "@seealso"
134 syn match rOTag contained "@slot"
135 syn match rOTag contained "@source"
136 syn match rOTag contained "@template"
137 syn match rOTag contained "@templateVar"
138 syn match rOTag contained "@title"
139 syn match rOTag contained "@usage"
140 " namespace.R
141 syn match rOTag contained "@export"
142 syn match rOTag contained "@exportClass"
143 syn match rOTag contained "@exportMethod"
144 syn match rOTag contained "@exportPattern"
145 syn match rOTag contained "@import"
146 syn match rOTag contained "@importClassesFrom"
147 syn match rOTag contained "@importFrom"
148 syn match rOTag contained "@importMethodsFrom"
149 syn match rOTag contained "@rawNamespace"
150 syn match rOTag contained "@S3method"
151 syn match rOTag contained "@useDynLib"
152 " other
Bram Moolenaar11e3c5b2021-04-21 18:09:37 +0200153 syn match rOTag contained "@eval"
Bram Moolenaarcd5c8f82017-04-09 20:11:58 +0200154 syn match rOTag contained "@include"
Bram Moolenaar11e3c5b2021-04-21 18:09:37 +0200155 syn match rOTag contained "@includeRmd"
156 syn match rOTag contained "@order"
Bram Moolenaar77cdfd12016-03-12 12:57:59 +0100157endif
Bram Moolenaar203d04d2013-06-06 21:36:40 +0200158
Bram Moolenaar071d4272004-06-13 20:20:40 +0000159
Bram Moolenaar662db672011-03-22 14:05:35 +0100160if &filetype == "rhelp"
161 " string enclosed in double quotes
162 syn region rString contains=rSpecial,@Spell start=/"/ skip=/\\\\\|\\"/ end=/"/
163 " string enclosed in single quotes
164 syn region rString contains=rSpecial,@Spell start=/'/ skip=/\\\\\|\\'/ end=/'/
165else
166 " string enclosed in double quotes
167 syn region rString contains=rSpecial,rStrError,@Spell start=/"/ skip=/\\\\\|\\"/ end=/"/
168 " string enclosed in single quotes
169 syn region rString contains=rSpecial,rStrError,@Spell start=/'/ skip=/\\\\\|\\'/ end=/'/
170endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000171
Bram Moolenaar483c5d82010-10-20 18:45:33 +0200172syn match rStrError display contained "\\."
173
Bram Moolenaar662db672011-03-22 14:05:35 +0100174
Bram Moolenaar483c5d82010-10-20 18:45:33 +0200175" New line, carriage return, tab, backspace, bell, feed, vertical tab, backslash
176syn match rSpecial display contained "\\\(n\|r\|t\|b\|a\|f\|v\|'\|\"\)\|\\\\"
177
178" Hexadecimal and Octal digits
179syn match rSpecial display contained "\\\(x\x\{1,2}\|[0-8]\{1,3}\)"
180
181" Unicode characters
182syn match rSpecial display contained "\\u\x\{1,4}"
183syn match rSpecial display contained "\\U\x\{1,8}"
184syn match rSpecial display contained "\\u{\x\{1,4}}"
185syn match rSpecial display contained "\\U{\x\{1,8}}"
186
Bram Moolenaar11e3c5b2021-04-21 18:09:37 +0200187" Raw string
188syn region rRawString matchgroup=rRawStrDelim start=/[rR]\z(['"]\)\z(-*\)(/ end=/)\z2\z1/ keepend
189syn region rRawString matchgroup=rRawStrDelim start=/[rR]\z(['"]\)\z(-*\){/ end=/}\z2\z1/ keepend
190syn region rRawString matchgroup=rRawStrDelim start=/[rR]\z(['"]\)\z(-*\)\[/ end=/\]\z2\z1/ keepend
191
Bram Moolenaar071d4272004-06-13 20:20:40 +0000192" Statement
193syn keyword rStatement break next return
194syn keyword rConditional if else
195syn keyword rRepeat for in repeat while
196
Bram Moolenaar483c5d82010-10-20 18:45:33 +0200197" Constant (not really)
Bram Moolenaar203d04d2013-06-06 21:36:40 +0200198syn keyword rConstant T F LETTERS letters month.abb month.name pi
Bram Moolenaar483c5d82010-10-20 18:45:33 +0200199syn keyword rConstant R.version.string
200
Bram Moolenaar8feef4f2015-01-07 16:57:10 +0100201syn keyword rNumber NA_integer_ NA_real_ NA_complex_ NA_character_
Bram Moolenaar662db672011-03-22 14:05:35 +0100202
203" Constants
Bram Moolenaar071d4272004-06-13 20:20:40 +0000204syn keyword rConstant NULL
205syn keyword rBoolean FALSE TRUE
Bram Moolenaar8feef4f2015-01-07 16:57:10 +0100206syn keyword rNumber NA Inf NaN
Bram Moolenaar071d4272004-06-13 20:20:40 +0000207
Bram Moolenaar483c5d82010-10-20 18:45:33 +0200208" integer
209syn match rInteger "\<\d\+L"
210syn match rInteger "\<0x\([0-9]\|[a-f]\|[A-F]\)\+L"
211syn match rInteger "\<\d\+[Ee]+\=\d\+L"
212
Bram Moolenaar483c5d82010-10-20 18:45:33 +0200213" number with no fractional part or exponent
214syn match rNumber "\<\d\+\>"
Bram Moolenaar8feef4f2015-01-07 16:57:10 +0100215" hexadecimal number
Bram Moolenaar483c5d82010-10-20 18:45:33 +0200216syn match rNumber "\<0x\([0-9]\|[a-f]\|[A-F]\)\+"
217
218" floating point number with integer and fractional parts and optional exponent
219syn match rFloat "\<\d\+\.\d*\([Ee][-+]\=\d\+\)\="
220" floating point number with no integer part and optional exponent
221syn match rFloat "\<\.\d\+\([Ee][-+]\=\d\+\)\="
222" floating point number with no fractional part and optional exponent
223syn match rFloat "\<\d\+[Ee][-+]\=\d\+"
224
Bram Moolenaar662db672011-03-22 14:05:35 +0100225" complex number
226syn match rComplex "\<\d\+i"
227syn match rComplex "\<\d\++\d\+i"
228syn match rComplex "\<0x\([0-9]\|[a-f]\|[A-F]\)\+i"
229syn match rComplex "\<\d\+\.\d*\([Ee][-+]\=\d\+\)\=i"
230syn match rComplex "\<\.\d\+\([Ee][-+]\=\d\+\)\=i"
231syn match rComplex "\<\d\+[Ee][-+]\=\d\+i"
232
Bram Moolenaar8feef4f2015-01-07 16:57:10 +0100233syn match rAssign '='
Bram Moolenaar662db672011-03-22 14:05:35 +0100234syn match rOperator "&"
235syn match rOperator '-'
Bram Moolenaare6ae6222013-05-21 21:01:10 +0200236syn match rOperator '\*'
Bram Moolenaar662db672011-03-22 14:05:35 +0100237syn match rOperator '+'
Bram Moolenaardd60c362023-02-27 15:49:53 +0000238if &filetype == "quarto" || &filetype == "rmd" || &filetype == "rrst"
Bram Moolenaar203d04d2013-06-06 21:36:40 +0200239 syn match rOperator "[|!<>^~`/:]"
Bram Moolenaardd60c362023-02-27 15:49:53 +0000240else
241 syn match rOperator "[|!<>^~/:]"
Bram Moolenaar203d04d2013-06-06 21:36:40 +0200242endif
Bram Moolenaardb6ea062014-07-10 22:01:47 +0200243syn match rOperator "%\{2}\|%\S\{-}%"
Bram Moolenaar8feef4f2015-01-07 16:57:10 +0100244syn match rOperator '\([!><]\)\@<=='
245syn match rOperator '=='
Bram Moolenaardd60c362023-02-27 15:49:53 +0000246syn match rOperator '|>'
Bram Moolenaar203d04d2013-06-06 21:36:40 +0200247syn match rOpError '\*\{3}'
Bram Moolenaar662db672011-03-22 14:05:35 +0100248syn match rOpError '//'
249syn match rOpError '&&&'
250syn match rOpError '|||'
251syn match rOpError '<<'
252syn match rOpError '>>'
253
Bram Moolenaar8feef4f2015-01-07 16:57:10 +0100254syn match rAssign "<\{1,2}-"
255syn match rAssign "->\{1,2}"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000256
257" Special
Bram Moolenaar483c5d82010-10-20 18:45:33 +0200258syn match rDelimiter "[,;:]"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000259
260" Error
Bram Moolenaar662db672011-03-22 14:05:35 +0100261if exists("g:r_syntax_folding")
262 syn region rRegion matchgroup=Delimiter start=/(/ matchgroup=Delimiter end=/)/ transparent contains=ALLBUT,rError,rBraceError,rCurlyError fold
263 syn region rRegion matchgroup=Delimiter start=/{/ matchgroup=Delimiter end=/}/ transparent contains=ALLBUT,rError,rBraceError,rParenError fold
264 syn region rRegion matchgroup=Delimiter start=/\[/ matchgroup=Delimiter end=/]/ transparent contains=ALLBUT,rError,rCurlyError,rParenError fold
Bram Moolenaarfc65cab2018-08-28 22:58:02 +0200265 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 +0100266else
267 syn region rRegion matchgroup=Delimiter start=/(/ matchgroup=Delimiter end=/)/ transparent contains=ALLBUT,rError,rBraceError,rCurlyError
268 syn region rRegion matchgroup=Delimiter start=/{/ matchgroup=Delimiter end=/}/ transparent contains=ALLBUT,rError,rBraceError,rParenError
269 syn region rRegion matchgroup=Delimiter start=/\[/ matchgroup=Delimiter end=/]/ transparent contains=ALLBUT,rError,rCurlyError,rParenError
270endif
271
Bram Moolenaar483c5d82010-10-20 18:45:33 +0200272syn match rError "[)\]}]"
273syn match rBraceError "[)}]" contained
274syn match rCurlyError "[)\]]" contained
275syn match rParenError "[\]}]" contained
276
Bram Moolenaarcd5c8f82017-04-09 20:11:58 +0200277" Use Nvim-R to highlight functions dynamically if it is installed
278if !exists("g:r_syntax_fun_pattern")
279 let s:ff = split(substitute(globpath(&rtp, "R/functions.vim"), "functions.vim", "", "g"), "\n")
280 if len(s:ff) > 0
281 let g:r_syntax_fun_pattern = 0
282 else
283 let g:r_syntax_fun_pattern = 1
284 endif
Bram Moolenaar77cdfd12016-03-12 12:57:59 +0100285endif
Bram Moolenaarcd5c8f82017-04-09 20:11:58 +0200286
287" Only use Nvim-R to highlight functions if they should not be highlighted
288" according to a generic pattern
289if g:r_syntax_fun_pattern == 1
290 syn match rFunction '[0-9a-zA-Z_\.]\+\s*\ze('
291else
Bram Moolenaarfc65cab2018-08-28 22:58:02 +0200292 " Nvim-R:
293 runtime R/functions.vim
Bram Moolenaar8feef4f2015-01-07 16:57:10 +0100294endif
Bram Moolenaar662db672011-03-22 14:05:35 +0100295
296syn match rDollar display contained "\$"
Bram Moolenaar203d04d2013-06-06 21:36:40 +0200297syn match rDollar display contained "@"
Bram Moolenaar662db672011-03-22 14:05:35 +0100298
299" List elements will not be highlighted as functions:
300syn match rLstElmt "\$[a-zA-Z0-9\\._]*" contains=rDollar
Bram Moolenaar203d04d2013-06-06 21:36:40 +0200301syn match rLstElmt "@[a-zA-Z0-9\\._]*" contains=rDollar
Bram Moolenaar662db672011-03-22 14:05:35 +0100302
Bram Moolenaar483c5d82010-10-20 18:45:33 +0200303" Functions that may add new objects
304syn keyword rPreProc library require attach detach source
305
Bram Moolenaar662db672011-03-22 14:05:35 +0100306if &filetype == "rhelp"
Bram Moolenaardb6ea062014-07-10 22:01:47 +0200307 syn match rHelpIdent '\\method'
308 syn match rHelpIdent '\\S4method'
Bram Moolenaar662db672011-03-22 14:05:35 +0100309endif
310
Bram Moolenaar483c5d82010-10-20 18:45:33 +0200311" Type
Bram Moolenaardd60c362023-02-27 15:49:53 +0000312syn match rType "\\"
Bram Moolenaar8feef4f2015-01-07 16:57:10 +0100313syn keyword rType array category character complex double function integer list logical matrix numeric vector data.frame
Bram Moolenaar071d4272004-06-13 20:20:40 +0000314
Bram Moolenaar662db672011-03-22 14:05:35 +0100315" Name of object with spaces
Bram Moolenaardd60c362023-02-27 15:49:53 +0000316if &filetype == "rmd" || &filetype == "rrst" || &filetype == "quarto"
317 syn region rNameWSpace start="`" end="`" contains=rSpaceFun containedin=rmdrChunk
318else
Bram Moolenaarfc65cab2018-08-28 22:58:02 +0200319 syn region rNameWSpace start="`" end="`" contains=rSpaceFun
Bram Moolenaar203d04d2013-06-06 21:36:40 +0200320endif
Bram Moolenaar662db672011-03-22 14:05:35 +0100321
322if &filetype == "rhelp"
Bram Moolenaar8feef4f2015-01-07 16:57:10 +0100323 syn match rhPreProc "^#ifdef.*"
324 syn match rhPreProc "^#endif.*"
Bram Moolenaar662db672011-03-22 14:05:35 +0100325 syn match rhSection "\\dontrun\>"
326endif
327
Bram Moolenaarcd5c8f82017-04-09 20:11:58 +0200328if exists("r_syntax_minlines")
329 exe "syn sync minlines=" . r_syntax_minlines
Bram Moolenaar8feef4f2015-01-07 16:57:10 +0100330else
331 syn sync minlines=40
332endif
333
Bram Moolenaar071d4272004-06-13 20:20:40 +0000334" Define the default highlighting.
Bram Moolenaar8feef4f2015-01-07 16:57:10 +0100335hi def link rAssign Statement
Bram Moolenaar483c5d82010-10-20 18:45:33 +0200336hi def link rBoolean Boolean
337hi def link rBraceError Error
338hi def link rComment Comment
Bram Moolenaarfc65cab2018-08-28 22:58:02 +0200339hi def link rTodoParen Comment
340hi def link rTodoInfo SpecialComment
Bram Moolenaardb6ea062014-07-10 22:01:47 +0200341hi def link rCommentTodo Todo
Bram Moolenaarfc65cab2018-08-28 22:58:02 +0200342hi def link rTodoKeyw Todo
Bram Moolenaar483c5d82010-10-20 18:45:33 +0200343hi def link rComplex Number
344hi def link rConditional Conditional
345hi def link rConstant Constant
346hi def link rCurlyError Error
347hi def link rDelimiter Delimiter
348hi def link rDollar SpecialChar
349hi def link rError Error
350hi def link rFloat Float
Bram Moolenaar662db672011-03-22 14:05:35 +0100351hi def link rFunction Function
Bram Moolenaarfc65cab2018-08-28 22:58:02 +0200352hi def link rSpaceFun Function
Bram Moolenaar662db672011-03-22 14:05:35 +0100353hi def link rHelpIdent Identifier
354hi def link rhPreProc PreProc
355hi def link rhSection PreCondit
Bram Moolenaar483c5d82010-10-20 18:45:33 +0200356hi def link rInteger Number
Bram Moolenaar8feef4f2015-01-07 16:57:10 +0100357hi def link rLstElmt Normal
Bram Moolenaar662db672011-03-22 14:05:35 +0100358hi def link rNameWSpace Normal
Bram Moolenaar483c5d82010-10-20 18:45:33 +0200359hi def link rNumber Number
360hi def link rOperator Operator
Bram Moolenaar662db672011-03-22 14:05:35 +0100361hi def link rOpError Error
Bram Moolenaar483c5d82010-10-20 18:45:33 +0200362hi def link rParenError Error
363hi def link rPreProc PreProc
Bram Moolenaar11e3c5b2021-04-21 18:09:37 +0200364hi def link rRawString String
365hi def link rRawStrDelim Delimiter
Bram Moolenaar483c5d82010-10-20 18:45:33 +0200366hi def link rRepeat Repeat
367hi def link rSpecial SpecialChar
368hi def link rStatement Statement
369hi def link rString String
370hi def link rStrError Error
371hi def link rType Type
Bram Moolenaarcd5c8f82017-04-09 20:11:58 +0200372if g:r_syntax_hl_roxygen
373 hi def link rOTitleTag Operator
374 hi def link rOTag Operator
375 hi def link rOTitleBlock Title
376 hi def link rOBlock Comment
377 hi def link rOBlockNoTitle Comment
Bram Moolenaar11e3c5b2021-04-21 18:09:37 +0200378 hi def link rOR6Block Comment
Bram Moolenaar77cdfd12016-03-12 12:57:59 +0100379 hi def link rOTitle Title
380 hi def link rOCommentKey Comment
381 hi def link rOExamples SpecialComment
382endif
Bram Moolenaar2c5e8e82015-12-05 20:59:21 +0100383
Bram Moolenaar071d4272004-06-13 20:20:40 +0000384let b:current_syntax="r"
385
386" vim: ts=8 sw=2