Mercurial > vim
annotate runtime/syntax/r.vim @ 33380:7ba7c38a9914
Added tag v9.0.1948 for changeset 7c9124711f997a267b94de49a7051f2f3294055c
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Thu, 28 Sep 2023 22:30:04 +0200 |
parents | b2412874362f |
children | 34f6f3678cae |
rev | line source |
---|---|
7 | 1 " Vim syntax file |
2608
7d8af31066c8
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
856
diff
changeset
|
2 " Language: R (GNU S) |
7d8af31066c8
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
856
diff
changeset
|
3 " Maintainer: Jakson Aquino <jalvesaq@gmail.com> |
7d8af31066c8
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
856
diff
changeset
|
4 " Former Maintainers: Vaidotas Zemlys <zemlys@gmail.com> |
7d8af31066c8
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
856
diff
changeset
|
5 " Tom Payne <tom@tompayne.org> |
7315
444efa5f5015
commit https://github.com/vim/vim/commit/2c5e8e80eacf491d4f266983f534a77776c7ae83
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
6 " Contributor: Johannes Ranke <jranke@uni-bremen.de> |
444efa5f5015
commit https://github.com/vim/vim/commit/2c5e8e80eacf491d4f266983f534a77776c7ae83
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
7 " Homepage: https://github.com/jalvesaq/R-Vim-runtime |
32061 | 8 " Last Change: Thu Nov 17, 2022 10:13PM |
2608
7d8af31066c8
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
856
diff
changeset
|
9 " Filenames: *.R *.r *.Rhistory *.Rt |
6476 | 10 " |
11347 | 11 " NOTE: The highlighting of R functions might be defined in |
6476 | 12 " runtime files created by a filetype plugin, if installed. |
2608
7d8af31066c8
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
856
diff
changeset
|
13 " |
2725 | 14 " CONFIGURATION: |
8497
da01d5da2cfa
commit https://github.com/vim/vim/commit/77cdfd10382e01cc51f4ba1a9177032351843151
Christian Brabandt <cb@256bit.org>
parents:
7315
diff
changeset
|
15 " Syntax folding can be turned on by |
2725 | 16 " |
17 " let r_syntax_folding = 1 | |
18 " | |
8497
da01d5da2cfa
commit https://github.com/vim/vim/commit/77cdfd10382e01cc51f4ba1a9177032351843151
Christian Brabandt <cb@256bit.org>
parents:
7315
diff
changeset
|
19 " ROxygen highlighting can be turned off by |
da01d5da2cfa
commit https://github.com/vim/vim/commit/77cdfd10382e01cc51f4ba1a9177032351843151
Christian Brabandt <cb@256bit.org>
parents:
7315
diff
changeset
|
20 " |
11347 | 21 " let r_syntax_hl_roxygen = 0 |
8497
da01d5da2cfa
commit https://github.com/vim/vim/commit/77cdfd10382e01cc51f4ba1a9177032351843151
Christian Brabandt <cb@256bit.org>
parents:
7315
diff
changeset
|
22 " |
2608
7d8af31066c8
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
856
diff
changeset
|
23 " Some lines of code were borrowed from Zhuojun Chen. |
625 | 24 |
2608
7d8af31066c8
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
856
diff
changeset
|
25 if exists("b:current_syntax") |
7 | 26 finish |
27 endif | |
28 | |
11347 | 29 if has("patch-7.4.1142") |
30 syn iskeyword @,48-57,_,. | |
31 else | |
32 setlocal iskeyword=@,48-57,_,. | |
33 endif | |
34 | |
35 " The variables g:r_hl_roxygen and g:r_syn_minlines were renamed on April 8, 2017. | |
36 if exists("g:r_hl_roxygen") | |
37 let g:r_syntax_hl_roxygen = g:r_hl_roxygen | |
38 endif | |
39 if exists("g:r_syn_minlines") | |
40 let g:r_syntax_minlines = g:r_syn_minlines | |
41 endif | |
7 | 42 |
8497
da01d5da2cfa
commit https://github.com/vim/vim/commit/77cdfd10382e01cc51f4ba1a9177032351843151
Christian Brabandt <cb@256bit.org>
parents:
7315
diff
changeset
|
43 if exists("g:r_syntax_folding") && g:r_syntax_folding |
2725 | 44 setlocal foldmethod=syntax |
45 endif | |
14637 | 46 |
47 let g:r_syntax_hl_roxygen = get(g:, 'r_syntax_hl_roxygen', 1) | |
2725 | 48 |
7 | 49 syn case match |
50 | |
51 " Comment | |
6051 | 52 syn match rCommentTodo contained "\(BUG\|FIXME\|NOTE\|TODO\):" |
14637 | 53 syn match rTodoParen contained "\(BUG\|FIXME\|NOTE\|TODO\)\s*(.\{-})\s*:" contains=rTodoKeyw,rTodoInfo transparent |
54 syn keyword rTodoKeyw BUG FIXME NOTE TODO contained | |
55 syn match rTodoInfo "(\zs.\{-}\ze)" contained | |
24520 | 56 syn match rComment contains=@Spell,rCommentTodo,rTodoParen "#.*" |
4780 | 57 |
58 " Roxygen | |
11347 | 59 if g:r_syntax_hl_roxygen |
60 " A roxygen block can start at the beginning of a file (first version) and | |
24520 | 61 " after a blank line (second version). It ends when a line appears that does not |
11347 | 62 " 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. | |
67 | |
32061 | 68 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 | |
11347 | 76 " 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 | |
14637 | 78 " overridden later by the definitions of rOBlock. |
32061 | 79 syn match rOTitleBlock "\(\%^\|^\s*\n\)\@<=\(\s*#\{1,2}' .*\n\)\{1,}" contains=rOCommentKey,rOTitleTag |
11347 | 80 |
24520 | 81 " 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. | |
32061 | 83 syn match rOTitle "\(\%^\|^\s*\n\)\@<=\(\s*#\{1,2}' .*\n\)\{-1,}\s*#\{1,2}'\s*$" contained contains=rOCommentKey,rOTitleTag |
24520 | 84 syn match rOTitleTag contained "@title" |
85 | |
11347 | 86 " 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 | |
32061 | 89 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 |
7315
444efa5f5015
commit https://github.com/vim/vim/commit/2c5e8e80eacf491d4f266983f534a77776c7ae83
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
90 |
11347 | 91 " or by a roxygen tag (we match everything starting with @ but not @@ which is used as escape sequence for a literal @). |
32061 | 92 syn region rOBlock start="\(\%^\|^\s*\n\)\@<=\(\s*#\{1,2}' .*\n\)\{-}\s*#\{1,2}' @\(@\)\@!" end="^\s*\(#\{1,2}'\)\@!" contains=rOTitle,rOTag,rOExamples,@Spell keepend fold |
11347 | 93 |
94 " If a block contains an @rdname, @describeIn tag, it may have paragraph breaks, but does not have a title | |
32061 | 95 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 | |
11347 | 97 |
24520 | 98 " rOTag list originally generated from the lists that were available in |
11347 | 99 " 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 | |
7315
444efa5f5015
commit https://github.com/vim/vim/commit/2c5e8e80eacf491d4f266983f534a77776c7ae83
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
103 |
11347 | 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 | |
24520 | 157 syn match rOTag contained "@eval" |
11347 | 158 syn match rOTag contained "@include" |
24520 | 159 syn match rOTag contained "@includeRmd" |
160 syn match rOTag contained "@order" | |
8497
da01d5da2cfa
commit https://github.com/vim/vim/commit/77cdfd10382e01cc51f4ba1a9177032351843151
Christian Brabandt <cb@256bit.org>
parents:
7315
diff
changeset
|
161 endif |
4780 | 162 |
7 | 163 |
2725 | 164 if &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=/'/ | |
169 else | |
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=/'/ | |
174 endif | |
2608
7d8af31066c8
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
856
diff
changeset
|
175 |
7d8af31066c8
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
856
diff
changeset
|
176 syn match rStrError display contained "\\." |
7d8af31066c8
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
856
diff
changeset
|
177 |
2725 | 178 |
2608
7d8af31066c8
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
856
diff
changeset
|
179 " New line, carriage return, tab, backspace, bell, feed, vertical tab, backslash |
7d8af31066c8
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
856
diff
changeset
|
180 syn match rSpecial display contained "\\\(n\|r\|t\|b\|a\|f\|v\|'\|\"\)\|\\\\" |
7 | 181 |
2608
7d8af31066c8
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
856
diff
changeset
|
182 " Hexadecimal and Octal digits |
7d8af31066c8
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
856
diff
changeset
|
183 syn match rSpecial display contained "\\\(x\x\{1,2}\|[0-8]\{1,3}\)" |
7d8af31066c8
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
856
diff
changeset
|
184 |
7d8af31066c8
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
856
diff
changeset
|
185 " Unicode characters |
7d8af31066c8
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
856
diff
changeset
|
186 syn match rSpecial display contained "\\u\x\{1,4}" |
7d8af31066c8
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
856
diff
changeset
|
187 syn match rSpecial display contained "\\U\x\{1,8}" |
7d8af31066c8
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
856
diff
changeset
|
188 syn match rSpecial display contained "\\u{\x\{1,4}}" |
7d8af31066c8
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
856
diff
changeset
|
189 syn match rSpecial display contained "\\U{\x\{1,8}}" |
7d8af31066c8
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
856
diff
changeset
|
190 |
24520 | 191 " Raw string |
192 syn region rRawString matchgroup=rRawStrDelim start=/[rR]\z(['"]\)\z(-*\)(/ end=/)\z2\z1/ keepend | |
193 syn region rRawString matchgroup=rRawStrDelim start=/[rR]\z(['"]\)\z(-*\){/ end=/}\z2\z1/ keepend | |
194 syn region rRawString matchgroup=rRawStrDelim start=/[rR]\z(['"]\)\z(-*\)\[/ end=/\]\z2\z1/ keepend | |
195 | |
7 | 196 " Statement |
197 syn keyword rStatement break next return | |
198 syn keyword rConditional if else | |
199 syn keyword rRepeat for in repeat while | |
200 | |
2608
7d8af31066c8
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
856
diff
changeset
|
201 " Constant (not really) |
4780 | 202 syn keyword rConstant T F LETTERS letters month.abb month.name pi |
2608
7d8af31066c8
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
856
diff
changeset
|
203 syn keyword rConstant R.version.string |
7d8af31066c8
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
856
diff
changeset
|
204 |
6476 | 205 syn keyword rNumber NA_integer_ NA_real_ NA_complex_ NA_character_ |
2725 | 206 |
207 " Constants | |
7 | 208 syn keyword rConstant NULL |
209 syn keyword rBoolean FALSE TRUE | |
6476 | 210 syn keyword rNumber NA Inf NaN |
2608
7d8af31066c8
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
856
diff
changeset
|
211 |
7d8af31066c8
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
856
diff
changeset
|
212 " integer |
7d8af31066c8
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
856
diff
changeset
|
213 syn match rInteger "\<\d\+L" |
7d8af31066c8
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
856
diff
changeset
|
214 syn match rInteger "\<0x\([0-9]\|[a-f]\|[A-F]\)\+L" |
7d8af31066c8
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
856
diff
changeset
|
215 syn match rInteger "\<\d\+[Ee]+\=\d\+L" |
7d8af31066c8
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
856
diff
changeset
|
216 |
7d8af31066c8
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
856
diff
changeset
|
217 " number with no fractional part or exponent |
7d8af31066c8
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
856
diff
changeset
|
218 syn match rNumber "\<\d\+\>" |
6476 | 219 " hexadecimal number |
2608
7d8af31066c8
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
856
diff
changeset
|
220 syn match rNumber "\<0x\([0-9]\|[a-f]\|[A-F]\)\+" |
7d8af31066c8
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
856
diff
changeset
|
221 |
7d8af31066c8
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
856
diff
changeset
|
222 " floating point number with integer and fractional parts and optional exponent |
7d8af31066c8
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
856
diff
changeset
|
223 syn match rFloat "\<\d\+\.\d*\([Ee][-+]\=\d\+\)\=" |
7d8af31066c8
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
856
diff
changeset
|
224 " floating point number with no integer part and optional exponent |
7d8af31066c8
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
856
diff
changeset
|
225 syn match rFloat "\<\.\d\+\([Ee][-+]\=\d\+\)\=" |
7d8af31066c8
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
856
diff
changeset
|
226 " floating point number with no fractional part and optional exponent |
7d8af31066c8
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
856
diff
changeset
|
227 syn match rFloat "\<\d\+[Ee][-+]\=\d\+" |
7d8af31066c8
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
856
diff
changeset
|
228 |
2725 | 229 " complex number |
230 syn match rComplex "\<\d\+i" | |
231 syn match rComplex "\<\d\++\d\+i" | |
232 syn match rComplex "\<0x\([0-9]\|[a-f]\|[A-F]\)\+i" | |
233 syn match rComplex "\<\d\+\.\d*\([Ee][-+]\=\d\+\)\=i" | |
234 syn match rComplex "\<\.\d\+\([Ee][-+]\=\d\+\)\=i" | |
235 syn match rComplex "\<\d\+[Ee][-+]\=\d\+i" | |
236 | |
6476 | 237 syn match rAssign '=' |
2725 | 238 syn match rOperator "&" |
239 syn match rOperator '-' | |
4502
605c9ce57ec3
Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents:
2725
diff
changeset
|
240 syn match rOperator '\*' |
2725 | 241 syn match rOperator '+' |
32061 | 242 if &filetype == "quarto" || &filetype == "rmd" || &filetype == "rrst" |
243 syn match rOperator "[|!<>^~`/:]" | |
244 else | |
4780 | 245 syn match rOperator "[|!<>^~/:]" |
246 endif | |
6051 | 247 syn match rOperator "%\{2}\|%\S\{-}%" |
6476 | 248 syn match rOperator '\([!><]\)\@<==' |
249 syn match rOperator '==' | |
32061 | 250 syn match rOperator '|>' |
4780 | 251 syn match rOpError '\*\{3}' |
2725 | 252 syn match rOpError '//' |
253 syn match rOpError '&&&' | |
254 syn match rOpError '|||' | |
255 syn match rOpError '<<' | |
256 syn match rOpError '>>' | |
257 | |
6476 | 258 syn match rAssign "<\{1,2}-" |
259 syn match rAssign "->\{1,2}" | |
7 | 260 |
261 " Special | |
2608
7d8af31066c8
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
856
diff
changeset
|
262 syn match rDelimiter "[,;:]" |
7 | 263 |
264 " Error | |
2725 | 265 if 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 | |
14637 | 269 syn region rSection matchgroup=Title start=/^#.*[-=#]\{4,}/ end=/^#.*[-=#]\{4,}/ms=s-2,me=s-1 transparent contains=ALL fold |
2725 | 270 else |
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 | |
274 endif | |
275 | |
2608
7d8af31066c8
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
856
diff
changeset
|
276 syn match rError "[)\]}]" |
7d8af31066c8
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
856
diff
changeset
|
277 syn match rBraceError "[)}]" contained |
7d8af31066c8
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
856
diff
changeset
|
278 syn match rCurlyError "[)\]]" contained |
7d8af31066c8
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
856
diff
changeset
|
279 syn match rParenError "[\]}]" contained |
7d8af31066c8
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
856
diff
changeset
|
280 |
11347 | 281 " Use Nvim-R to highlight functions dynamically if it is installed |
282 if !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 | |
8497
da01d5da2cfa
commit https://github.com/vim/vim/commit/77cdfd10382e01cc51f4ba1a9177032351843151
Christian Brabandt <cb@256bit.org>
parents:
7315
diff
changeset
|
289 endif |
11347 | 290 |
291 " Only use Nvim-R to highlight functions if they should not be highlighted | |
292 " according to a generic pattern | |
293 if g:r_syntax_fun_pattern == 1 | |
294 syn match rFunction '[0-9a-zA-Z_\.]\+\s*\ze(' | |
295 else | |
14637 | 296 " Nvim-R: |
297 runtime R/functions.vim | |
6476 | 298 endif |
2725 | 299 |
300 syn match rDollar display contained "\$" | |
4780 | 301 syn match rDollar display contained "@" |
2725 | 302 |
303 " List elements will not be highlighted as functions: | |
304 syn match rLstElmt "\$[a-zA-Z0-9\\._]*" contains=rDollar | |
4780 | 305 syn match rLstElmt "@[a-zA-Z0-9\\._]*" contains=rDollar |
2725 | 306 |
2608
7d8af31066c8
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
856
diff
changeset
|
307 " Functions that may add new objects |
7d8af31066c8
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
856
diff
changeset
|
308 syn keyword rPreProc library require attach detach source |
7d8af31066c8
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
856
diff
changeset
|
309 |
2725 | 310 if &filetype == "rhelp" |
6051 | 311 syn match rHelpIdent '\\method' |
312 syn match rHelpIdent '\\S4method' | |
2725 | 313 endif |
314 | |
2608
7d8af31066c8
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
856
diff
changeset
|
315 " Type |
32061 | 316 syn match rType "\\" |
6476 | 317 syn keyword rType array category character complex double function integer list logical matrix numeric vector data.frame |
7 | 318 |
2725 | 319 " Name of object with spaces |
32061 | 320 if &filetype == "rmd" || &filetype == "rrst" || &filetype == "quarto" |
321 syn region rNameWSpace start="`" end="`" contains=rSpaceFun containedin=rmdrChunk | |
322 else | |
14637 | 323 syn region rNameWSpace start="`" end="`" contains=rSpaceFun |
4780 | 324 endif |
2725 | 325 |
326 if &filetype == "rhelp" | |
6476 | 327 syn match rhPreProc "^#ifdef.*" |
328 syn match rhPreProc "^#endif.*" | |
2725 | 329 syn match rhSection "\\dontrun\>" |
330 endif | |
331 | |
11347 | 332 if exists("r_syntax_minlines") |
333 exe "syn sync minlines=" . r_syntax_minlines | |
6476 | 334 else |
335 syn sync minlines=40 | |
336 endif | |
337 | |
7 | 338 " Define the default highlighting. |
6476 | 339 hi def link rAssign Statement |
2608
7d8af31066c8
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
856
diff
changeset
|
340 hi def link rBoolean Boolean |
7d8af31066c8
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
856
diff
changeset
|
341 hi def link rBraceError Error |
7d8af31066c8
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
856
diff
changeset
|
342 hi def link rComment Comment |
14637 | 343 hi def link rTodoParen Comment |
344 hi def link rTodoInfo SpecialComment | |
6051 | 345 hi def link rCommentTodo Todo |
14637 | 346 hi def link rTodoKeyw Todo |
2608
7d8af31066c8
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
856
diff
changeset
|
347 hi def link rComplex Number |
7d8af31066c8
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
856
diff
changeset
|
348 hi def link rConditional Conditional |
7d8af31066c8
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
856
diff
changeset
|
349 hi def link rConstant Constant |
7d8af31066c8
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
856
diff
changeset
|
350 hi def link rCurlyError Error |
7d8af31066c8
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
856
diff
changeset
|
351 hi def link rDelimiter Delimiter |
7d8af31066c8
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
856
diff
changeset
|
352 hi def link rDollar SpecialChar |
7d8af31066c8
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
856
diff
changeset
|
353 hi def link rError Error |
7d8af31066c8
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
856
diff
changeset
|
354 hi def link rFloat Float |
2725 | 355 hi def link rFunction Function |
14637 | 356 hi def link rSpaceFun Function |
2725 | 357 hi def link rHelpIdent Identifier |
358 hi def link rhPreProc PreProc | |
359 hi def link rhSection PreCondit | |
2608
7d8af31066c8
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
856
diff
changeset
|
360 hi def link rInteger Number |
6476 | 361 hi def link rLstElmt Normal |
2725 | 362 hi def link rNameWSpace Normal |
2608
7d8af31066c8
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
856
diff
changeset
|
363 hi def link rNumber Number |
7d8af31066c8
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
856
diff
changeset
|
364 hi def link rOperator Operator |
2725 | 365 hi def link rOpError Error |
2608
7d8af31066c8
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
856
diff
changeset
|
366 hi def link rParenError Error |
7d8af31066c8
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
856
diff
changeset
|
367 hi def link rPreProc PreProc |
24520 | 368 hi def link rRawString String |
369 hi def link rRawStrDelim Delimiter | |
2608
7d8af31066c8
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
856
diff
changeset
|
370 hi def link rRepeat Repeat |
7d8af31066c8
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
856
diff
changeset
|
371 hi def link rSpecial SpecialChar |
7d8af31066c8
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
856
diff
changeset
|
372 hi def link rStatement Statement |
7d8af31066c8
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
856
diff
changeset
|
373 hi def link rString String |
7d8af31066c8
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
856
diff
changeset
|
374 hi def link rStrError Error |
7d8af31066c8
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
856
diff
changeset
|
375 hi def link rType Type |
11347 | 376 if 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 | |
24520 | 382 hi def link rOR6Block Comment |
8497
da01d5da2cfa
commit https://github.com/vim/vim/commit/77cdfd10382e01cc51f4ba1a9177032351843151
Christian Brabandt <cb@256bit.org>
parents:
7315
diff
changeset
|
383 hi def link rOTitle Title |
da01d5da2cfa
commit https://github.com/vim/vim/commit/77cdfd10382e01cc51f4ba1a9177032351843151
Christian Brabandt <cb@256bit.org>
parents:
7315
diff
changeset
|
384 hi def link rOCommentKey Comment |
da01d5da2cfa
commit https://github.com/vim/vim/commit/77cdfd10382e01cc51f4ba1a9177032351843151
Christian Brabandt <cb@256bit.org>
parents:
7315
diff
changeset
|
385 hi def link rOExamples SpecialComment |
da01d5da2cfa
commit https://github.com/vim/vim/commit/77cdfd10382e01cc51f4ba1a9177032351843151
Christian Brabandt <cb@256bit.org>
parents:
7315
diff
changeset
|
386 endif |
7315
444efa5f5015
commit https://github.com/vim/vim/commit/2c5e8e80eacf491d4f266983f534a77776c7ae83
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
387 |
7 | 388 let b:current_syntax="r" |
389 | |
390 " vim: ts=8 sw=2 |