blob: fa731943326cfc252a6a6de398c55f375818edc5 [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)
Christian Brabandtf9ca1392024-02-19 20:37:11 +01003" Maintainer: This runtime file is looking for a new maintainer.
4" Former Maintainers: Jakson Aquino <jalvesaq@gmail.com>
5" Vaidotas Zemlys <zemlys@gmail.com>
6" Tom Payne <tom@tompayne.org>
Bram Moolenaar2c5e8e82015-12-05 20:59:21 +01007" Contributor: Johannes Ranke <jranke@uni-bremen.de>
Christian Brabandtf9ca1392024-02-19 20:37:11 +01008" Former Repository: https://github.com/jalvesaq/R-Vim-runtime
9" Filenames: *.R *.r *.Rhistory *.Rt
10" Last Change: 2023 Dec 24 08:05AM
11" 2024 Feb 19 by Vim Project (announce adoption)
Bram Moolenaar8feef4f2015-01-07 16:57:10 +010012"
Bram Moolenaarcd5c8f82017-04-09 20:11:58 +020013" NOTE: The highlighting of R functions might be defined in
Bram Moolenaar8feef4f2015-01-07 16:57:10 +010014" runtime files created by a filetype plugin, if installed.
Bram Moolenaar483c5d82010-10-20 18:45:33 +020015"
Bram Moolenaar662db672011-03-22 14:05:35 +010016" CONFIGURATION:
Bram Moolenaar77cdfd12016-03-12 12:57:59 +010017" Syntax folding can be turned on by
Bram Moolenaar662db672011-03-22 14:05:35 +010018"
19" let r_syntax_folding = 1
20"
Bram Moolenaar77cdfd12016-03-12 12:57:59 +010021" ROxygen highlighting can be turned off by
22"
Bram Moolenaarcd5c8f82017-04-09 20:11:58 +020023" let r_syntax_hl_roxygen = 0
Bram Moolenaar77cdfd12016-03-12 12:57:59 +010024"
Bram Moolenaar483c5d82010-10-20 18:45:33 +020025" Some lines of code were borrowed from Zhuojun Chen.
Bram Moolenaar4770d092006-01-12 23:22:24 +000026
Bram Moolenaar483c5d82010-10-20 18:45:33 +020027if exists("b:current_syntax")
Bram Moolenaar071d4272004-06-13 20:20:40 +000028 finish
29endif
30
Jakson Alves de Aquino9042bd82023-12-25 09:22:27 +000031syn iskeyword @,48-57,_,.
Bram Moolenaarcd5c8f82017-04-09 20:11:58 +020032
33" The variables g:r_hl_roxygen and g:r_syn_minlines were renamed on April 8, 2017.
34if exists("g:r_hl_roxygen")
35 let g:r_syntax_hl_roxygen = g:r_hl_roxygen
36endif
37if exists("g:r_syn_minlines")
38 let g:r_syntax_minlines = g:r_syn_minlines
39endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000040
Bram Moolenaar77cdfd12016-03-12 12:57:59 +010041if exists("g:r_syntax_folding") && g:r_syntax_folding
Bram Moolenaar662db672011-03-22 14:05:35 +010042 setlocal foldmethod=syntax
43endif
Bram Moolenaarfc65cab2018-08-28 22:58:02 +020044
45let g:r_syntax_hl_roxygen = get(g:, 'r_syntax_hl_roxygen', 1)
Bram Moolenaar662db672011-03-22 14:05:35 +010046
Bram Moolenaar071d4272004-06-13 20:20:40 +000047syn case match
48
49" Comment
Bram Moolenaardb6ea062014-07-10 22:01:47 +020050syn match rCommentTodo contained "\(BUG\|FIXME\|NOTE\|TODO\):"
Bram Moolenaarfc65cab2018-08-28 22:58:02 +020051syn match rTodoParen contained "\(BUG\|FIXME\|NOTE\|TODO\)\s*(.\{-})\s*:" contains=rTodoKeyw,rTodoInfo transparent
52syn keyword rTodoKeyw BUG FIXME NOTE TODO contained
53syn match rTodoInfo "(\zs.\{-}\ze)" contained
Bram Moolenaar11e3c5b2021-04-21 18:09:37 +020054syn match rComment contains=@Spell,rCommentTodo,rTodoParen "#.*"
Bram Moolenaar203d04d2013-06-06 21:36:40 +020055
56" Roxygen
Bram Moolenaarcd5c8f82017-04-09 20:11:58 +020057if g:r_syntax_hl_roxygen
58 " A roxygen block can start at the beginning of a file (first version) and
Bram Moolenaar11e3c5b2021-04-21 18:09:37 +020059 " after a blank line (second version). It ends when a line appears that does not
Bram Moolenaarcd5c8f82017-04-09 20:11:58 +020060 " contain a roxygen comment. In the following comments, any line containing
61 " a roxygen comment marker (one or two hash signs # followed by a single
62 " quote ' and preceded only by whitespace) is called a roxygen line. A
63 " roxygen line containing only a roxygen comment marker, optionally followed
64 " by whitespace is called an empty roxygen line.
Bram Moolenaar2c5e8e82015-12-05 20:59:21 +010065
Bram Moolenaardd60c362023-02-27 15:49:53 +000066 syn match rOCommentKey "^\s*#\{1,2}'" contained
67 syn region rOExamples start="^\s*#\{1,2}' @examples.*"rs=e+1,hs=e+1 end="^\(#\{1,2}' @.*\)\@=" end="^\(#\{1,2}'\)\@!" contained contains=rOTag fold
68
69 " R6 classes may contain roxygen lines independent of roxygen blocks
70 syn region rOR6Class start=/R6Class(/ end=/)/ transparent contains=ALLBUT,rError,rBraceError,rCurlyError fold
71 syn match rOR6Block "#\{1,2}'.*" contains=rOTag,rOExamples,@Spell containedin=rOR6Class contained
72 syn match rOR6Block "^\s*#\{1,2}'.*" contains=rOTag,rOExamples,@Spell containedin=rOR6Class contained
73
Bram Moolenaarcd5c8f82017-04-09 20:11:58 +020074 " First we match all roxygen blocks as containing only a title. In case an
75 " empty roxygen line ending the title or a tag is found, this will be
Bram Moolenaarfc65cab2018-08-28 22:58:02 +020076 " overridden later by the definitions of rOBlock.
Bram Moolenaardd60c362023-02-27 15:49:53 +000077 syn match rOTitleBlock "\(\%^\|^\s*\n\)\@<=\(\s*#\{1,2}' .*\n\)\{1,}" contains=rOCommentKey,rOTitleTag
Bram Moolenaar2c5e8e82015-12-05 20:59:21 +010078
Bram Moolenaar11e3c5b2021-04-21 18:09:37 +020079 " A title as part of a block is always at the beginning of the block, i.e.
80 " either at the start of a file or after a completely empty line.
Bram Moolenaardd60c362023-02-27 15:49:53 +000081 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 +020082 syn match rOTitleTag contained "@title"
83
Bram Moolenaarcd5c8f82017-04-09 20:11:58 +020084 " When a roxygen block has a title and additional content, the title
85 " consists of one or more roxygen lines (as little as possible are matched),
86 " followed either by an empty roxygen line
Bram Moolenaardd60c362023-02-27 15:49:53 +000087 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 +020088
89 " 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 +000090 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 +020091
92 " 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 +000093 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
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
Bram Moolenaar11e3c5b2021-04-21 18:09:37 +020095
96 " rOTag list originally generated from the lists that were available in
Bram Moolenaarcd5c8f82017-04-09 20:11:58 +020097 " https://github.com/klutometis/roxygen/R/rd.R and
98 " https://github.com/klutometis/roxygen/R/namespace.R
99 " using s/^ \([A-Za-z0-9]*\) = .*/ syn match rOTag contained "@\1"/
100 " Plus we need the @include tag
101
102 " rd.R
103 syn match rOTag contained "@aliases"
104 syn match rOTag contained "@author"
105 syn match rOTag contained "@backref"
106 syn match rOTag contained "@concept"
107 syn match rOTag contained "@describeIn"
108 syn match rOTag contained "@description"
109 syn match rOTag contained "@details"
110 syn match rOTag contained "@docType"
111 syn match rOTag contained "@encoding"
112 syn match rOTag contained "@evalRd"
113 syn match rOTag contained "@example"
114 syn match rOTag contained "@examples"
115 syn match rOTag contained "@family"
116 syn match rOTag contained "@field"
117 syn match rOTag contained "@format"
118 syn match rOTag contained "@inherit"
119 syn match rOTag contained "@inheritParams"
120 syn match rOTag contained "@inheritDotParams"
121 syn match rOTag contained "@inheritSection"
122 syn match rOTag contained "@keywords"
123 syn match rOTag contained "@method"
124 syn match rOTag contained "@name"
125 syn match rOTag contained "@md"
126 syn match rOTag contained "@noMd"
127 syn match rOTag contained "@noRd"
128 syn match rOTag contained "@note"
129 syn match rOTag contained "@param"
130 syn match rOTag contained "@rdname"
131 syn match rOTag contained "@rawRd"
132 syn match rOTag contained "@references"
133 syn match rOTag contained "@return"
134 syn match rOTag contained "@section"
135 syn match rOTag contained "@seealso"
136 syn match rOTag contained "@slot"
137 syn match rOTag contained "@source"
138 syn match rOTag contained "@template"
139 syn match rOTag contained "@templateVar"
140 syn match rOTag contained "@title"
141 syn match rOTag contained "@usage"
142 " namespace.R
143 syn match rOTag contained "@export"
144 syn match rOTag contained "@exportClass"
145 syn match rOTag contained "@exportMethod"
146 syn match rOTag contained "@exportPattern"
147 syn match rOTag contained "@import"
148 syn match rOTag contained "@importClassesFrom"
149 syn match rOTag contained "@importFrom"
150 syn match rOTag contained "@importMethodsFrom"
151 syn match rOTag contained "@rawNamespace"
152 syn match rOTag contained "@S3method"
153 syn match rOTag contained "@useDynLib"
154 " other
Bram Moolenaar11e3c5b2021-04-21 18:09:37 +0200155 syn match rOTag contained "@eval"
Bram Moolenaarcd5c8f82017-04-09 20:11:58 +0200156 syn match rOTag contained "@include"
Bram Moolenaar11e3c5b2021-04-21 18:09:37 +0200157 syn match rOTag contained "@includeRmd"
158 syn match rOTag contained "@order"
Bram Moolenaar77cdfd12016-03-12 12:57:59 +0100159endif
Bram Moolenaar203d04d2013-06-06 21:36:40 +0200160
Bram Moolenaar071d4272004-06-13 20:20:40 +0000161
Bram Moolenaar662db672011-03-22 14:05:35 +0100162if &filetype == "rhelp"
163 " string enclosed in double quotes
164 syn region rString contains=rSpecial,@Spell start=/"/ skip=/\\\\\|\\"/ end=/"/
165 " string enclosed in single quotes
166 syn region rString contains=rSpecial,@Spell start=/'/ skip=/\\\\\|\\'/ end=/'/
167else
168 " string enclosed in double quotes
169 syn region rString contains=rSpecial,rStrError,@Spell start=/"/ skip=/\\\\\|\\"/ end=/"/
170 " string enclosed in single quotes
171 syn region rString contains=rSpecial,rStrError,@Spell start=/'/ skip=/\\\\\|\\'/ end=/'/
172endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000173
Bram Moolenaar483c5d82010-10-20 18:45:33 +0200174syn match rStrError display contained "\\."
175
Bram Moolenaar662db672011-03-22 14:05:35 +0100176
Bram Moolenaar483c5d82010-10-20 18:45:33 +0200177" New line, carriage return, tab, backspace, bell, feed, vertical tab, backslash
178syn match rSpecial display contained "\\\(n\|r\|t\|b\|a\|f\|v\|'\|\"\)\|\\\\"
179
180" Hexadecimal and Octal digits
181syn match rSpecial display contained "\\\(x\x\{1,2}\|[0-8]\{1,3}\)"
182
183" Unicode characters
184syn match rSpecial display contained "\\u\x\{1,4}"
185syn match rSpecial display contained "\\U\x\{1,8}"
186syn match rSpecial display contained "\\u{\x\{1,4}}"
187syn match rSpecial display contained "\\U{\x\{1,8}}"
188
Bram Moolenaar11e3c5b2021-04-21 18:09:37 +0200189" Raw string
190syn region rRawString matchgroup=rRawStrDelim start=/[rR]\z(['"]\)\z(-*\)(/ end=/)\z2\z1/ keepend
191syn region rRawString matchgroup=rRawStrDelim start=/[rR]\z(['"]\)\z(-*\){/ end=/}\z2\z1/ keepend
192syn region rRawString matchgroup=rRawStrDelim start=/[rR]\z(['"]\)\z(-*\)\[/ end=/\]\z2\z1/ keepend
193
Bram Moolenaar071d4272004-06-13 20:20:40 +0000194" Statement
195syn keyword rStatement break next return
196syn keyword rConditional if else
197syn keyword rRepeat for in repeat while
198
Bram Moolenaar483c5d82010-10-20 18:45:33 +0200199" Constant (not really)
Bram Moolenaar203d04d2013-06-06 21:36:40 +0200200syn keyword rConstant T F LETTERS letters month.abb month.name pi
Bram Moolenaar483c5d82010-10-20 18:45:33 +0200201syn keyword rConstant R.version.string
202
Bram Moolenaar8feef4f2015-01-07 16:57:10 +0100203syn keyword rNumber NA_integer_ NA_real_ NA_complex_ NA_character_
Bram Moolenaar662db672011-03-22 14:05:35 +0100204
205" Constants
Bram Moolenaar071d4272004-06-13 20:20:40 +0000206syn keyword rConstant NULL
207syn keyword rBoolean FALSE TRUE
Bram Moolenaar8feef4f2015-01-07 16:57:10 +0100208syn keyword rNumber NA Inf NaN
Bram Moolenaar071d4272004-06-13 20:20:40 +0000209
Bram Moolenaar483c5d82010-10-20 18:45:33 +0200210" integer
211syn match rInteger "\<\d\+L"
212syn match rInteger "\<0x\([0-9]\|[a-f]\|[A-F]\)\+L"
213syn match rInteger "\<\d\+[Ee]+\=\d\+L"
214
Bram Moolenaar483c5d82010-10-20 18:45:33 +0200215" number with no fractional part or exponent
216syn match rNumber "\<\d\+\>"
Bram Moolenaar8feef4f2015-01-07 16:57:10 +0100217" hexadecimal number
Bram Moolenaar483c5d82010-10-20 18:45:33 +0200218syn match rNumber "\<0x\([0-9]\|[a-f]\|[A-F]\)\+"
219
220" floating point number with integer and fractional parts and optional exponent
221syn match rFloat "\<\d\+\.\d*\([Ee][-+]\=\d\+\)\="
222" floating point number with no integer part and optional exponent
223syn match rFloat "\<\.\d\+\([Ee][-+]\=\d\+\)\="
224" floating point number with no fractional part and optional exponent
225syn match rFloat "\<\d\+[Ee][-+]\=\d\+"
226
Bram Moolenaar662db672011-03-22 14:05:35 +0100227" complex number
228syn match rComplex "\<\d\+i"
229syn match rComplex "\<\d\++\d\+i"
230syn match rComplex "\<0x\([0-9]\|[a-f]\|[A-F]\)\+i"
231syn match rComplex "\<\d\+\.\d*\([Ee][-+]\=\d\+\)\=i"
232syn match rComplex "\<\.\d\+\([Ee][-+]\=\d\+\)\=i"
233syn match rComplex "\<\d\+[Ee][-+]\=\d\+i"
234
Bram Moolenaar8feef4f2015-01-07 16:57:10 +0100235syn match rAssign '='
Bram Moolenaar662db672011-03-22 14:05:35 +0100236syn match rOperator "&"
237syn match rOperator '-'
Bram Moolenaare6ae6222013-05-21 21:01:10 +0200238syn match rOperator '\*'
Bram Moolenaar662db672011-03-22 14:05:35 +0100239syn match rOperator '+'
Bram Moolenaardd60c362023-02-27 15:49:53 +0000240if &filetype == "quarto" || &filetype == "rmd" || &filetype == "rrst"
Bram Moolenaar203d04d2013-06-06 21:36:40 +0200241 syn match rOperator "[|!<>^~`/:]"
Bram Moolenaardd60c362023-02-27 15:49:53 +0000242else
243 syn match rOperator "[|!<>^~/:]"
Bram Moolenaar203d04d2013-06-06 21:36:40 +0200244endif
Bram Moolenaardb6ea062014-07-10 22:01:47 +0200245syn match rOperator "%\{2}\|%\S\{-}%"
Bram Moolenaar8feef4f2015-01-07 16:57:10 +0100246syn match rOperator '\([!><]\)\@<=='
247syn match rOperator '=='
Bram Moolenaardd60c362023-02-27 15:49:53 +0000248syn match rOperator '|>'
Bram Moolenaar203d04d2013-06-06 21:36:40 +0200249syn match rOpError '\*\{3}'
Bram Moolenaar662db672011-03-22 14:05:35 +0100250syn match rOpError '//'
251syn match rOpError '&&&'
252syn match rOpError '|||'
253syn match rOpError '<<'
254syn match rOpError '>>'
255
Bram Moolenaar8feef4f2015-01-07 16:57:10 +0100256syn match rAssign "<\{1,2}-"
257syn match rAssign "->\{1,2}"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000258
259" Special
Bram Moolenaar483c5d82010-10-20 18:45:33 +0200260syn match rDelimiter "[,;:]"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000261
262" Error
Bram Moolenaar662db672011-03-22 14:05:35 +0100263if exists("g:r_syntax_folding")
264 syn region rRegion matchgroup=Delimiter start=/(/ matchgroup=Delimiter end=/)/ transparent contains=ALLBUT,rError,rBraceError,rCurlyError fold
265 syn region rRegion matchgroup=Delimiter start=/{/ matchgroup=Delimiter end=/}/ transparent contains=ALLBUT,rError,rBraceError,rParenError fold
266 syn region rRegion matchgroup=Delimiter start=/\[/ matchgroup=Delimiter end=/]/ transparent contains=ALLBUT,rError,rCurlyError,rParenError fold
Bram Moolenaarfc65cab2018-08-28 22:58:02 +0200267 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 +0100268else
269 syn region rRegion matchgroup=Delimiter start=/(/ matchgroup=Delimiter end=/)/ transparent contains=ALLBUT,rError,rBraceError,rCurlyError
270 syn region rRegion matchgroup=Delimiter start=/{/ matchgroup=Delimiter end=/}/ transparent contains=ALLBUT,rError,rBraceError,rParenError
271 syn region rRegion matchgroup=Delimiter start=/\[/ matchgroup=Delimiter end=/]/ transparent contains=ALLBUT,rError,rCurlyError,rParenError
272endif
273
Bram Moolenaar483c5d82010-10-20 18:45:33 +0200274syn match rError "[)\]}]"
275syn match rBraceError "[)}]" contained
276syn match rCurlyError "[)\]]" contained
277syn match rParenError "[\]}]" contained
278
Bram Moolenaarcd5c8f82017-04-09 20:11:58 +0200279" Use Nvim-R to highlight functions dynamically if it is installed
280if !exists("g:r_syntax_fun_pattern")
281 let s:ff = split(substitute(globpath(&rtp, "R/functions.vim"), "functions.vim", "", "g"), "\n")
282 if len(s:ff) > 0
283 let g:r_syntax_fun_pattern = 0
284 else
285 let g:r_syntax_fun_pattern = 1
286 endif
Bram Moolenaar77cdfd12016-03-12 12:57:59 +0100287endif
Bram Moolenaarcd5c8f82017-04-09 20:11:58 +0200288
289" Only use Nvim-R to highlight functions if they should not be highlighted
290" according to a generic pattern
291if g:r_syntax_fun_pattern == 1
292 syn match rFunction '[0-9a-zA-Z_\.]\+\s*\ze('
293else
Bram Moolenaarfc65cab2018-08-28 22:58:02 +0200294 " Nvim-R:
295 runtime R/functions.vim
Bram Moolenaar8feef4f2015-01-07 16:57:10 +0100296endif
Bram Moolenaar662db672011-03-22 14:05:35 +0100297
298syn match rDollar display contained "\$"
Bram Moolenaar203d04d2013-06-06 21:36:40 +0200299syn match rDollar display contained "@"
Bram Moolenaar662db672011-03-22 14:05:35 +0100300
301" List elements will not be highlighted as functions:
302syn match rLstElmt "\$[a-zA-Z0-9\\._]*" contains=rDollar
Bram Moolenaar203d04d2013-06-06 21:36:40 +0200303syn match rLstElmt "@[a-zA-Z0-9\\._]*" contains=rDollar
Bram Moolenaar662db672011-03-22 14:05:35 +0100304
Bram Moolenaar483c5d82010-10-20 18:45:33 +0200305" Functions that may add new objects
306syn keyword rPreProc library require attach detach source
307
Bram Moolenaar662db672011-03-22 14:05:35 +0100308if &filetype == "rhelp"
Bram Moolenaardb6ea062014-07-10 22:01:47 +0200309 syn match rHelpIdent '\\method'
310 syn match rHelpIdent '\\S4method'
Bram Moolenaar662db672011-03-22 14:05:35 +0100311endif
312
Bram Moolenaar483c5d82010-10-20 18:45:33 +0200313" Type
Bram Moolenaardd60c362023-02-27 15:49:53 +0000314syn match rType "\\"
Bram Moolenaar8feef4f2015-01-07 16:57:10 +0100315syn keyword rType array category character complex double function integer list logical matrix numeric vector data.frame
Bram Moolenaar071d4272004-06-13 20:20:40 +0000316
Bram Moolenaar662db672011-03-22 14:05:35 +0100317" Name of object with spaces
Bram Moolenaardd60c362023-02-27 15:49:53 +0000318if &filetype == "rmd" || &filetype == "rrst" || &filetype == "quarto"
319 syn region rNameWSpace start="`" end="`" contains=rSpaceFun containedin=rmdrChunk
320else
Bram Moolenaarfc65cab2018-08-28 22:58:02 +0200321 syn region rNameWSpace start="`" end="`" contains=rSpaceFun
Bram Moolenaar203d04d2013-06-06 21:36:40 +0200322endif
Bram Moolenaar662db672011-03-22 14:05:35 +0100323
324if &filetype == "rhelp"
Bram Moolenaar8feef4f2015-01-07 16:57:10 +0100325 syn match rhPreProc "^#ifdef.*"
326 syn match rhPreProc "^#endif.*"
Bram Moolenaar662db672011-03-22 14:05:35 +0100327 syn match rhSection "\\dontrun\>"
328endif
329
Bram Moolenaarcd5c8f82017-04-09 20:11:58 +0200330if exists("r_syntax_minlines")
331 exe "syn sync minlines=" . r_syntax_minlines
Bram Moolenaar8feef4f2015-01-07 16:57:10 +0100332else
333 syn sync minlines=40
334endif
335
Bram Moolenaar071d4272004-06-13 20:20:40 +0000336" Define the default highlighting.
Bram Moolenaar8feef4f2015-01-07 16:57:10 +0100337hi def link rAssign Statement
Bram Moolenaar483c5d82010-10-20 18:45:33 +0200338hi def link rBoolean Boolean
339hi def link rBraceError Error
340hi def link rComment Comment
Bram Moolenaarfc65cab2018-08-28 22:58:02 +0200341hi def link rTodoParen Comment
342hi def link rTodoInfo SpecialComment
Bram Moolenaardb6ea062014-07-10 22:01:47 +0200343hi def link rCommentTodo Todo
Bram Moolenaarfc65cab2018-08-28 22:58:02 +0200344hi def link rTodoKeyw Todo
Bram Moolenaar483c5d82010-10-20 18:45:33 +0200345hi def link rComplex Number
346hi def link rConditional Conditional
347hi def link rConstant Constant
348hi def link rCurlyError Error
349hi def link rDelimiter Delimiter
350hi def link rDollar SpecialChar
351hi def link rError Error
352hi def link rFloat Float
Bram Moolenaar662db672011-03-22 14:05:35 +0100353hi def link rFunction Function
Bram Moolenaarfc65cab2018-08-28 22:58:02 +0200354hi def link rSpaceFun Function
Bram Moolenaar662db672011-03-22 14:05:35 +0100355hi def link rHelpIdent Identifier
356hi def link rhPreProc PreProc
357hi def link rhSection PreCondit
Bram Moolenaar483c5d82010-10-20 18:45:33 +0200358hi def link rInteger Number
Bram Moolenaar8feef4f2015-01-07 16:57:10 +0100359hi def link rLstElmt Normal
Bram Moolenaar662db672011-03-22 14:05:35 +0100360hi def link rNameWSpace Normal
Bram Moolenaar483c5d82010-10-20 18:45:33 +0200361hi def link rNumber Number
362hi def link rOperator Operator
Bram Moolenaar662db672011-03-22 14:05:35 +0100363hi def link rOpError Error
Bram Moolenaar483c5d82010-10-20 18:45:33 +0200364hi def link rParenError Error
365hi def link rPreProc PreProc
Bram Moolenaar11e3c5b2021-04-21 18:09:37 +0200366hi def link rRawString String
367hi def link rRawStrDelim Delimiter
Bram Moolenaar483c5d82010-10-20 18:45:33 +0200368hi def link rRepeat Repeat
369hi def link rSpecial SpecialChar
370hi def link rStatement Statement
371hi def link rString String
372hi def link rStrError Error
373hi def link rType Type
Bram Moolenaarcd5c8f82017-04-09 20:11:58 +0200374if g:r_syntax_hl_roxygen
375 hi def link rOTitleTag Operator
376 hi def link rOTag Operator
377 hi def link rOTitleBlock Title
378 hi def link rOBlock Comment
379 hi def link rOBlockNoTitle Comment
Bram Moolenaar11e3c5b2021-04-21 18:09:37 +0200380 hi def link rOR6Block Comment
Bram Moolenaar77cdfd12016-03-12 12:57:59 +0100381 hi def link rOTitle Title
382 hi def link rOCommentKey Comment
383 hi def link rOExamples SpecialComment
384endif
Bram Moolenaar2c5e8e82015-12-05 20:59:21 +0100385
Bram Moolenaar071d4272004-06-13 20:20:40 +0000386let b:current_syntax="r"
387
388" vim: ts=8 sw=2