blob: 9b3754ae23b3ae5504319217ac98e00c543e6411 [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 Moolenaardd60c362023-02-27 15:49:53 +00008" Last Change: Thu Nov 17, 2022 10:13PM
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 Moolenaardd60c362023-02-27 15:49:53 +000068 syn match rOCommentKey "^\s*#\{1,2}'" contained
69 syn region rOExamples start="^\s*#\{1,2}' @examples.*"rs=e+1,hs=e+1 end="^\(#\{1,2}' @.*\)\@=" end="^\(#\{1,2}'\)\@!" contained contains=rOTag fold
70
71 " R6 classes may contain roxygen lines independent of roxygen blocks
72 syn region rOR6Class start=/R6Class(/ end=/)/ transparent contains=ALLBUT,rError,rBraceError,rCurlyError fold
73 syn match rOR6Block "#\{1,2}'.*" contains=rOTag,rOExamples,@Spell containedin=rOR6Class contained
74 syn match rOR6Block "^\s*#\{1,2}'.*" contains=rOTag,rOExamples,@Spell containedin=rOR6Class contained
75
Bram Moolenaarcd5c8f82017-04-09 20:11:58 +020076 " First we match all roxygen blocks as containing only a title. In case an
77 " empty roxygen line ending the title or a tag is found, this will be
Bram Moolenaarfc65cab2018-08-28 22:58:02 +020078 " overridden later by the definitions of rOBlock.
Bram Moolenaardd60c362023-02-27 15:49:53 +000079 syn match rOTitleBlock "\(\%^\|^\s*\n\)\@<=\(\s*#\{1,2}' .*\n\)\{1,}" contains=rOCommentKey,rOTitleTag
Bram Moolenaar2c5e8e82015-12-05 20:59:21 +010080
Bram Moolenaar11e3c5b2021-04-21 18:09:37 +020081 " A title as part of a block is always at the beginning of the block, i.e.
82 " either at the start of a file or after a completely empty line.
Bram Moolenaardd60c362023-02-27 15:49:53 +000083 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 +020084 syn match rOTitleTag contained "@title"
85
Bram Moolenaarcd5c8f82017-04-09 20:11:58 +020086 " When a roxygen block has a title and additional content, the title
87 " consists of one or more roxygen lines (as little as possible are matched),
88 " followed either by an empty roxygen line
Bram Moolenaardd60c362023-02-27 15:49:53 +000089 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 +020090
91 " 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 +000092 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 +020093
94 " 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 +000095 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
96 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 +020097
98 " rOTag list originally generated from the lists that were available in
Bram Moolenaarcd5c8f82017-04-09 20:11:58 +020099 " https://github.com/klutometis/roxygen/R/rd.R and
100 " https://github.com/klutometis/roxygen/R/namespace.R
101 " using s/^ \([A-Za-z0-9]*\) = .*/ syn match rOTag contained "@\1"/
102 " Plus we need the @include tag
103
104 " rd.R
105 syn match rOTag contained "@aliases"
106 syn match rOTag contained "@author"
107 syn match rOTag contained "@backref"
108 syn match rOTag contained "@concept"
109 syn match rOTag contained "@describeIn"
110 syn match rOTag contained "@description"
111 syn match rOTag contained "@details"
112 syn match rOTag contained "@docType"
113 syn match rOTag contained "@encoding"
114 syn match rOTag contained "@evalRd"
115 syn match rOTag contained "@example"
116 syn match rOTag contained "@examples"
117 syn match rOTag contained "@family"
118 syn match rOTag contained "@field"
119 syn match rOTag contained "@format"
120 syn match rOTag contained "@inherit"
121 syn match rOTag contained "@inheritParams"
122 syn match rOTag contained "@inheritDotParams"
123 syn match rOTag contained "@inheritSection"
124 syn match rOTag contained "@keywords"
125 syn match rOTag contained "@method"
126 syn match rOTag contained "@name"
127 syn match rOTag contained "@md"
128 syn match rOTag contained "@noMd"
129 syn match rOTag contained "@noRd"
130 syn match rOTag contained "@note"
131 syn match rOTag contained "@param"
132 syn match rOTag contained "@rdname"
133 syn match rOTag contained "@rawRd"
134 syn match rOTag contained "@references"
135 syn match rOTag contained "@return"
136 syn match rOTag contained "@section"
137 syn match rOTag contained "@seealso"
138 syn match rOTag contained "@slot"
139 syn match rOTag contained "@source"
140 syn match rOTag contained "@template"
141 syn match rOTag contained "@templateVar"
142 syn match rOTag contained "@title"
143 syn match rOTag contained "@usage"
144 " namespace.R
145 syn match rOTag contained "@export"
146 syn match rOTag contained "@exportClass"
147 syn match rOTag contained "@exportMethod"
148 syn match rOTag contained "@exportPattern"
149 syn match rOTag contained "@import"
150 syn match rOTag contained "@importClassesFrom"
151 syn match rOTag contained "@importFrom"
152 syn match rOTag contained "@importMethodsFrom"
153 syn match rOTag contained "@rawNamespace"
154 syn match rOTag contained "@S3method"
155 syn match rOTag contained "@useDynLib"
156 " other
Bram Moolenaar11e3c5b2021-04-21 18:09:37 +0200157 syn match rOTag contained "@eval"
Bram Moolenaarcd5c8f82017-04-09 20:11:58 +0200158 syn match rOTag contained "@include"
Bram Moolenaar11e3c5b2021-04-21 18:09:37 +0200159 syn match rOTag contained "@includeRmd"
160 syn match rOTag contained "@order"
Bram Moolenaar77cdfd12016-03-12 12:57:59 +0100161endif
Bram Moolenaar203d04d2013-06-06 21:36:40 +0200162
Bram Moolenaar071d4272004-06-13 20:20:40 +0000163
Bram Moolenaar662db672011-03-22 14:05:35 +0100164if &filetype == "rhelp"
165 " string enclosed in double quotes
166 syn region rString contains=rSpecial,@Spell start=/"/ skip=/\\\\\|\\"/ end=/"/
167 " string enclosed in single quotes
168 syn region rString contains=rSpecial,@Spell start=/'/ skip=/\\\\\|\\'/ end=/'/
169else
170 " string enclosed in double quotes
171 syn region rString contains=rSpecial,rStrError,@Spell start=/"/ skip=/\\\\\|\\"/ end=/"/
172 " string enclosed in single quotes
173 syn region rString contains=rSpecial,rStrError,@Spell start=/'/ skip=/\\\\\|\\'/ end=/'/
174endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000175
Bram Moolenaar483c5d82010-10-20 18:45:33 +0200176syn match rStrError display contained "\\."
177
Bram Moolenaar662db672011-03-22 14:05:35 +0100178
Bram Moolenaar483c5d82010-10-20 18:45:33 +0200179" New line, carriage return, tab, backspace, bell, feed, vertical tab, backslash
180syn match rSpecial display contained "\\\(n\|r\|t\|b\|a\|f\|v\|'\|\"\)\|\\\\"
181
182" Hexadecimal and Octal digits
183syn match rSpecial display contained "\\\(x\x\{1,2}\|[0-8]\{1,3}\)"
184
185" Unicode characters
186syn match rSpecial display contained "\\u\x\{1,4}"
187syn match rSpecial display contained "\\U\x\{1,8}"
188syn match rSpecial display contained "\\u{\x\{1,4}}"
189syn match rSpecial display contained "\\U{\x\{1,8}}"
190
Bram Moolenaar11e3c5b2021-04-21 18:09:37 +0200191" Raw string
192syn region rRawString matchgroup=rRawStrDelim start=/[rR]\z(['"]\)\z(-*\)(/ end=/)\z2\z1/ keepend
193syn region rRawString matchgroup=rRawStrDelim start=/[rR]\z(['"]\)\z(-*\){/ end=/}\z2\z1/ keepend
194syn region rRawString matchgroup=rRawStrDelim start=/[rR]\z(['"]\)\z(-*\)\[/ end=/\]\z2\z1/ keepend
195
Bram Moolenaar071d4272004-06-13 20:20:40 +0000196" Statement
197syn keyword rStatement break next return
198syn keyword rConditional if else
199syn keyword rRepeat for in repeat while
200
Bram Moolenaar483c5d82010-10-20 18:45:33 +0200201" Constant (not really)
Bram Moolenaar203d04d2013-06-06 21:36:40 +0200202syn keyword rConstant T F LETTERS letters month.abb month.name pi
Bram Moolenaar483c5d82010-10-20 18:45:33 +0200203syn keyword rConstant R.version.string
204
Bram Moolenaar8feef4f2015-01-07 16:57:10 +0100205syn keyword rNumber NA_integer_ NA_real_ NA_complex_ NA_character_
Bram Moolenaar662db672011-03-22 14:05:35 +0100206
207" Constants
Bram Moolenaar071d4272004-06-13 20:20:40 +0000208syn keyword rConstant NULL
209syn keyword rBoolean FALSE TRUE
Bram Moolenaar8feef4f2015-01-07 16:57:10 +0100210syn keyword rNumber NA Inf NaN
Bram Moolenaar071d4272004-06-13 20:20:40 +0000211
Bram Moolenaar483c5d82010-10-20 18:45:33 +0200212" integer
213syn match rInteger "\<\d\+L"
214syn match rInteger "\<0x\([0-9]\|[a-f]\|[A-F]\)\+L"
215syn match rInteger "\<\d\+[Ee]+\=\d\+L"
216
Bram Moolenaar483c5d82010-10-20 18:45:33 +0200217" number with no fractional part or exponent
218syn match rNumber "\<\d\+\>"
Bram Moolenaar8feef4f2015-01-07 16:57:10 +0100219" hexadecimal number
Bram Moolenaar483c5d82010-10-20 18:45:33 +0200220syn match rNumber "\<0x\([0-9]\|[a-f]\|[A-F]\)\+"
221
222" floating point number with integer and fractional parts and optional exponent
223syn match rFloat "\<\d\+\.\d*\([Ee][-+]\=\d\+\)\="
224" floating point number with no integer part and optional exponent
225syn match rFloat "\<\.\d\+\([Ee][-+]\=\d\+\)\="
226" floating point number with no fractional part and optional exponent
227syn match rFloat "\<\d\+[Ee][-+]\=\d\+"
228
Bram Moolenaar662db672011-03-22 14:05:35 +0100229" complex number
230syn match rComplex "\<\d\+i"
231syn match rComplex "\<\d\++\d\+i"
232syn match rComplex "\<0x\([0-9]\|[a-f]\|[A-F]\)\+i"
233syn match rComplex "\<\d\+\.\d*\([Ee][-+]\=\d\+\)\=i"
234syn match rComplex "\<\.\d\+\([Ee][-+]\=\d\+\)\=i"
235syn match rComplex "\<\d\+[Ee][-+]\=\d\+i"
236
Bram Moolenaar8feef4f2015-01-07 16:57:10 +0100237syn match rAssign '='
Bram Moolenaar662db672011-03-22 14:05:35 +0100238syn match rOperator "&"
239syn match rOperator '-'
Bram Moolenaare6ae6222013-05-21 21:01:10 +0200240syn match rOperator '\*'
Bram Moolenaar662db672011-03-22 14:05:35 +0100241syn match rOperator '+'
Bram Moolenaardd60c362023-02-27 15:49:53 +0000242if &filetype == "quarto" || &filetype == "rmd" || &filetype == "rrst"
Bram Moolenaar203d04d2013-06-06 21:36:40 +0200243 syn match rOperator "[|!<>^~`/:]"
Bram Moolenaardd60c362023-02-27 15:49:53 +0000244else
245 syn match rOperator "[|!<>^~/:]"
Bram Moolenaar203d04d2013-06-06 21:36:40 +0200246endif
Bram Moolenaardb6ea062014-07-10 22:01:47 +0200247syn match rOperator "%\{2}\|%\S\{-}%"
Bram Moolenaar8feef4f2015-01-07 16:57:10 +0100248syn match rOperator '\([!><]\)\@<=='
249syn match rOperator '=='
Bram Moolenaardd60c362023-02-27 15:49:53 +0000250syn match rOperator '|>'
Bram Moolenaar203d04d2013-06-06 21:36:40 +0200251syn match rOpError '\*\{3}'
Bram Moolenaar662db672011-03-22 14:05:35 +0100252syn match rOpError '//'
253syn match rOpError '&&&'
254syn match rOpError '|||'
255syn match rOpError '<<'
256syn match rOpError '>>'
257
Bram Moolenaar8feef4f2015-01-07 16:57:10 +0100258syn match rAssign "<\{1,2}-"
259syn match rAssign "->\{1,2}"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000260
261" Special
Bram Moolenaar483c5d82010-10-20 18:45:33 +0200262syn match rDelimiter "[,;:]"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000263
264" Error
Bram Moolenaar662db672011-03-22 14:05:35 +0100265if exists("g:r_syntax_folding")
266 syn region rRegion matchgroup=Delimiter start=/(/ matchgroup=Delimiter end=/)/ transparent contains=ALLBUT,rError,rBraceError,rCurlyError fold
267 syn region rRegion matchgroup=Delimiter start=/{/ matchgroup=Delimiter end=/}/ transparent contains=ALLBUT,rError,rBraceError,rParenError fold
268 syn region rRegion matchgroup=Delimiter start=/\[/ matchgroup=Delimiter end=/]/ transparent contains=ALLBUT,rError,rCurlyError,rParenError fold
Bram Moolenaarfc65cab2018-08-28 22:58:02 +0200269 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 +0100270else
271 syn region rRegion matchgroup=Delimiter start=/(/ matchgroup=Delimiter end=/)/ transparent contains=ALLBUT,rError,rBraceError,rCurlyError
272 syn region rRegion matchgroup=Delimiter start=/{/ matchgroup=Delimiter end=/}/ transparent contains=ALLBUT,rError,rBraceError,rParenError
273 syn region rRegion matchgroup=Delimiter start=/\[/ matchgroup=Delimiter end=/]/ transparent contains=ALLBUT,rError,rCurlyError,rParenError
274endif
275
Bram Moolenaar483c5d82010-10-20 18:45:33 +0200276syn match rError "[)\]}]"
277syn match rBraceError "[)}]" contained
278syn match rCurlyError "[)\]]" contained
279syn match rParenError "[\]}]" contained
280
Bram Moolenaarcd5c8f82017-04-09 20:11:58 +0200281" Use Nvim-R to highlight functions dynamically if it is installed
282if !exists("g:r_syntax_fun_pattern")
283 let s:ff = split(substitute(globpath(&rtp, "R/functions.vim"), "functions.vim", "", "g"), "\n")
284 if len(s:ff) > 0
285 let g:r_syntax_fun_pattern = 0
286 else
287 let g:r_syntax_fun_pattern = 1
288 endif
Bram Moolenaar77cdfd12016-03-12 12:57:59 +0100289endif
Bram Moolenaarcd5c8f82017-04-09 20:11:58 +0200290
291" Only use Nvim-R to highlight functions if they should not be highlighted
292" according to a generic pattern
293if g:r_syntax_fun_pattern == 1
294 syn match rFunction '[0-9a-zA-Z_\.]\+\s*\ze('
295else
Bram Moolenaarfc65cab2018-08-28 22:58:02 +0200296 " Nvim-R:
297 runtime R/functions.vim
Bram Moolenaar8feef4f2015-01-07 16:57:10 +0100298endif
Bram Moolenaar662db672011-03-22 14:05:35 +0100299
300syn match rDollar display contained "\$"
Bram Moolenaar203d04d2013-06-06 21:36:40 +0200301syn match rDollar display contained "@"
Bram Moolenaar662db672011-03-22 14:05:35 +0100302
303" List elements will not be highlighted as functions:
304syn match rLstElmt "\$[a-zA-Z0-9\\._]*" contains=rDollar
Bram Moolenaar203d04d2013-06-06 21:36:40 +0200305syn match rLstElmt "@[a-zA-Z0-9\\._]*" contains=rDollar
Bram Moolenaar662db672011-03-22 14:05:35 +0100306
Bram Moolenaar483c5d82010-10-20 18:45:33 +0200307" Functions that may add new objects
308syn keyword rPreProc library require attach detach source
309
Bram Moolenaar662db672011-03-22 14:05:35 +0100310if &filetype == "rhelp"
Bram Moolenaardb6ea062014-07-10 22:01:47 +0200311 syn match rHelpIdent '\\method'
312 syn match rHelpIdent '\\S4method'
Bram Moolenaar662db672011-03-22 14:05:35 +0100313endif
314
Bram Moolenaar483c5d82010-10-20 18:45:33 +0200315" Type
Bram Moolenaardd60c362023-02-27 15:49:53 +0000316syn match rType "\\"
Bram Moolenaar8feef4f2015-01-07 16:57:10 +0100317syn keyword rType array category character complex double function integer list logical matrix numeric vector data.frame
Bram Moolenaar071d4272004-06-13 20:20:40 +0000318
Bram Moolenaar662db672011-03-22 14:05:35 +0100319" Name of object with spaces
Bram Moolenaardd60c362023-02-27 15:49:53 +0000320if &filetype == "rmd" || &filetype == "rrst" || &filetype == "quarto"
321 syn region rNameWSpace start="`" end="`" contains=rSpaceFun containedin=rmdrChunk
322else
Bram Moolenaarfc65cab2018-08-28 22:58:02 +0200323 syn region rNameWSpace start="`" end="`" contains=rSpaceFun
Bram Moolenaar203d04d2013-06-06 21:36:40 +0200324endif
Bram Moolenaar662db672011-03-22 14:05:35 +0100325
326if &filetype == "rhelp"
Bram Moolenaar8feef4f2015-01-07 16:57:10 +0100327 syn match rhPreProc "^#ifdef.*"
328 syn match rhPreProc "^#endif.*"
Bram Moolenaar662db672011-03-22 14:05:35 +0100329 syn match rhSection "\\dontrun\>"
330endif
331
Bram Moolenaarcd5c8f82017-04-09 20:11:58 +0200332if exists("r_syntax_minlines")
333 exe "syn sync minlines=" . r_syntax_minlines
Bram Moolenaar8feef4f2015-01-07 16:57:10 +0100334else
335 syn sync minlines=40
336endif
337
Bram Moolenaar071d4272004-06-13 20:20:40 +0000338" Define the default highlighting.
Bram Moolenaar8feef4f2015-01-07 16:57:10 +0100339hi def link rAssign Statement
Bram Moolenaar483c5d82010-10-20 18:45:33 +0200340hi def link rBoolean Boolean
341hi def link rBraceError Error
342hi def link rComment Comment
Bram Moolenaarfc65cab2018-08-28 22:58:02 +0200343hi def link rTodoParen Comment
344hi def link rTodoInfo SpecialComment
Bram Moolenaardb6ea062014-07-10 22:01:47 +0200345hi def link rCommentTodo Todo
Bram Moolenaarfc65cab2018-08-28 22:58:02 +0200346hi def link rTodoKeyw Todo
Bram Moolenaar483c5d82010-10-20 18:45:33 +0200347hi def link rComplex Number
348hi def link rConditional Conditional
349hi def link rConstant Constant
350hi def link rCurlyError Error
351hi def link rDelimiter Delimiter
352hi def link rDollar SpecialChar
353hi def link rError Error
354hi def link rFloat Float
Bram Moolenaar662db672011-03-22 14:05:35 +0100355hi def link rFunction Function
Bram Moolenaarfc65cab2018-08-28 22:58:02 +0200356hi def link rSpaceFun Function
Bram Moolenaar662db672011-03-22 14:05:35 +0100357hi def link rHelpIdent Identifier
358hi def link rhPreProc PreProc
359hi def link rhSection PreCondit
Bram Moolenaar483c5d82010-10-20 18:45:33 +0200360hi def link rInteger Number
Bram Moolenaar8feef4f2015-01-07 16:57:10 +0100361hi def link rLstElmt Normal
Bram Moolenaar662db672011-03-22 14:05:35 +0100362hi def link rNameWSpace Normal
Bram Moolenaar483c5d82010-10-20 18:45:33 +0200363hi def link rNumber Number
364hi def link rOperator Operator
Bram Moolenaar662db672011-03-22 14:05:35 +0100365hi def link rOpError Error
Bram Moolenaar483c5d82010-10-20 18:45:33 +0200366hi def link rParenError Error
367hi def link rPreProc PreProc
Bram Moolenaar11e3c5b2021-04-21 18:09:37 +0200368hi def link rRawString String
369hi def link rRawStrDelim Delimiter
Bram Moolenaar483c5d82010-10-20 18:45:33 +0200370hi def link rRepeat Repeat
371hi def link rSpecial SpecialChar
372hi def link rStatement Statement
373hi def link rString String
374hi def link rStrError Error
375hi def link rType Type
Bram Moolenaarcd5c8f82017-04-09 20:11:58 +0200376if g:r_syntax_hl_roxygen
377 hi def link rOTitleTag Operator
378 hi def link rOTag Operator
379 hi def link rOTitleBlock Title
380 hi def link rOBlock Comment
381 hi def link rOBlockNoTitle Comment
Bram Moolenaar11e3c5b2021-04-21 18:09:37 +0200382 hi def link rOR6Block Comment
Bram Moolenaar77cdfd12016-03-12 12:57:59 +0100383 hi def link rOTitle Title
384 hi def link rOCommentKey Comment
385 hi def link rOExamples SpecialComment
386endif
Bram Moolenaar2c5e8e82015-12-05 20:59:21 +0100387
Bram Moolenaar071d4272004-06-13 20:20:40 +0000388let b:current_syntax="r"
389
390" vim: ts=8 sw=2