Mercurial > vim
annotate runtime/syntax/r.vim @ 26395:fe4bc08c1e0b
Added tag v8.2.3728 for changeset 43d196ca5e7a9972c32c03c4af08f2d50023f8fc
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Fri, 03 Dec 2021 15:00:05 +0100 |
parents | 5bda4653aced |
children | b2412874362f |
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 |
24520 | 8 " Last Change: Sun Mar 28, 2021 01:47PM |
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 | |
68 " First we match all roxygen blocks as containing only a title. In case an | |
69 " empty roxygen line ending the title or a tag is found, this will be | |
14637 | 70 " overridden later by the definitions of rOBlock. |
11347 | 71 syn match rOTitleBlock "\%^\(\s*#\{1,2}' .*\n\)\{1,}" contains=rOCommentKey,rOTitleTag |
72 syn match rOTitleBlock "^\s*\n\(\s*#\{1,2}' .*\n\)\{1,}" contains=rOCommentKey,rOTitleTag | |
73 | |
24520 | 74 " A title as part of a block is always at the beginning of the block, i.e. |
75 " either at the start of a file or after a completely empty line. | |
76 syn match rOTitle "\%^\(\s*#\{1,2}' .*\n\)\{-1,}\s*#\{1,2}'\s*$" contained contains=rOCommentKey,rOTitleTag | |
77 syn match rOTitle "^\s*\n\(\s*#\{1,2}' .*\n\)\{-1,}\s*#\{1,2}'\s*$" contained contains=rOCommentKey,rOTitleTag | |
78 syn match rOTitleTag contained "@title" | |
79 | |
11347 | 80 " When a roxygen block has a title and additional content, the title |
81 " consists of one or more roxygen lines (as little as possible are matched), | |
82 " followed either by an empty roxygen line | |
83 syn region rOBlock start="\%^\(\s*#\{1,2}' .*\n\)\{-1,}\s*#\{1,2}'\s*$" end="^\s*\(#\{1,2}'\)\@!" contains=rOTitle,rOTag,rOExamples,@Spell keepend fold | |
84 syn region rOBlock start="^\s*\n\(\s*#\{1,2}' .*\n\)\{-1,}\s*#\{1,2}'\s*$" end="^\s*\(#\{1,2}'\)\@!" contains=rOTitle,rOTag,rOExamples,@Spell keepend fold | |
7315
444efa5f5015
commit https://github.com/vim/vim/commit/2c5e8e80eacf491d4f266983f534a77776c7ae83
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
85 |
11347 | 86 " or by a roxygen tag (we match everything starting with @ but not @@ which is used as escape sequence for a literal @). |
87 syn region rOBlock start="\%^\(\s*#\{1,2}' .*\n\)\{-}\s*#\{1,2}' @\(@\)\@!" end="^\s*\(#\{1,2}'\)\@!" contains=rOTitle,rOTag,rOExamples,@Spell keepend fold | |
88 syn region rOBlock start="^\s*\n\(\s*#\{1,2}' .*\n\)\{-}\s*#\{1,2}' @\(@\)\@!" end="^\s*\(#\{1,2}'\)\@!" contains=rOTitle,rOTag,rOExamples,@Spell keepend fold | |
89 | |
90 " If a block contains an @rdname, @describeIn tag, it may have paragraph breaks, but does not have a title | |
91 syn region rOBlockNoTitle start="\%^\(\s*#\{1,2}' .*\n\)\{-1,}\s*#\{1,2}'\s*\n\(\s*#\{1,2}'.*\n\)\{-}\s*#\{1,2}' @rdname" end="^\s*\(#\{1,2}'\)\@!" contains=rOTag,rOExamples,@Spell keepend fold | |
92 syn region rOBlockNoTitle start="^\s*\n\(\s*#\{1,2}' .*\n\)\{-1,}\s*#\{1,2}'\s*\n\(\s*#\{1,2}'.*\n\)\{-}\s*#\{1,2}' @rdname" end="^\s*\(#\{1,2}'\)\@!" contains=rOTag,rOExamples,@Spell keepend fold | |
93 syn region rOBlockNoTitle start="\%^\(\s*#\{1,2}' .*\n\)\{-1,}\s*#\{1,2}'\s*\n\(\s*#\{1,2}'.*\n\)\{-}\s*#\{1,2}' @describeIn" end="^\s*\(#\{1,2}'\)\@!" contains=rOTag,rOExamples,@Spell keepend fold | |
94 syn region rOBlockNoTitle start="^\s*\n\(\s*#\{1,2}' .*\n\)\{-1,}\s*#\{1,2}'\s*\n\(\s*#\{1,2}'.*\n\)\{-}\s*#\{1,2}' @describeIn" end="^\s*\(#\{1,2}'\)\@!" contains=rOTag,rOExamples,@Spell keepend fold | |
95 | |
24520 | 96 syn match rOCommentKey "^\s*#\{1,2}'" contained |
97 syn region rOExamples start="^\s*#\{1,2}' @examples.*"rs=e+1,hs=e+1 end="^\(#\{1,2}' @.*\)\@=" end="^\(#\{1,2}'\)\@!" contained contains=rOTag fold | |
11347 | 98 |
24520 | 99 " R6 classes may contain roxygen lines independent of roxygen blocks |
100 syn region rOR6Class start=/R6Class(/ end=/)/ transparent contains=ALLBUT,rError,rBraceError,rCurlyError fold | |
101 syn match rOR6Block "#\{1,2}'.*" contains=rOTag,rOExamples,@Spell containedin=rOR6Class contained | |
102 syn match rOR6Block "^\s*#\{1,2}'.*" contains=rOTag,rOExamples,@Spell containedin=rOR6Class contained | |
11347 | 103 |
24520 | 104 " rOTag list originally generated from the lists that were available in |
11347 | 105 " https://github.com/klutometis/roxygen/R/rd.R and |
106 " https://github.com/klutometis/roxygen/R/namespace.R | |
107 " using s/^ \([A-Za-z0-9]*\) = .*/ syn match rOTag contained "@\1"/ | |
108 " Plus we need the @include tag | |
7315
444efa5f5015
commit https://github.com/vim/vim/commit/2c5e8e80eacf491d4f266983f534a77776c7ae83
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
109 |
11347 | 110 " rd.R |
111 syn match rOTag contained "@aliases" | |
112 syn match rOTag contained "@author" | |
113 syn match rOTag contained "@backref" | |
114 syn match rOTag contained "@concept" | |
115 syn match rOTag contained "@describeIn" | |
116 syn match rOTag contained "@description" | |
117 syn match rOTag contained "@details" | |
118 syn match rOTag contained "@docType" | |
119 syn match rOTag contained "@encoding" | |
120 syn match rOTag contained "@evalRd" | |
121 syn match rOTag contained "@example" | |
122 syn match rOTag contained "@examples" | |
123 syn match rOTag contained "@family" | |
124 syn match rOTag contained "@field" | |
125 syn match rOTag contained "@format" | |
126 syn match rOTag contained "@inherit" | |
127 syn match rOTag contained "@inheritParams" | |
128 syn match rOTag contained "@inheritDotParams" | |
129 syn match rOTag contained "@inheritSection" | |
130 syn match rOTag contained "@keywords" | |
131 syn match rOTag contained "@method" | |
132 syn match rOTag contained "@name" | |
133 syn match rOTag contained "@md" | |
134 syn match rOTag contained "@noMd" | |
135 syn match rOTag contained "@noRd" | |
136 syn match rOTag contained "@note" | |
137 syn match rOTag contained "@param" | |
138 syn match rOTag contained "@rdname" | |
139 syn match rOTag contained "@rawRd" | |
140 syn match rOTag contained "@references" | |
141 syn match rOTag contained "@return" | |
142 syn match rOTag contained "@section" | |
143 syn match rOTag contained "@seealso" | |
144 syn match rOTag contained "@slot" | |
145 syn match rOTag contained "@source" | |
146 syn match rOTag contained "@template" | |
147 syn match rOTag contained "@templateVar" | |
148 syn match rOTag contained "@title" | |
149 syn match rOTag contained "@usage" | |
150 " namespace.R | |
151 syn match rOTag contained "@export" | |
152 syn match rOTag contained "@exportClass" | |
153 syn match rOTag contained "@exportMethod" | |
154 syn match rOTag contained "@exportPattern" | |
155 syn match rOTag contained "@import" | |
156 syn match rOTag contained "@importClassesFrom" | |
157 syn match rOTag contained "@importFrom" | |
158 syn match rOTag contained "@importMethodsFrom" | |
159 syn match rOTag contained "@rawNamespace" | |
160 syn match rOTag contained "@S3method" | |
161 syn match rOTag contained "@useDynLib" | |
162 " other | |
24520 | 163 syn match rOTag contained "@eval" |
11347 | 164 syn match rOTag contained "@include" |
24520 | 165 syn match rOTag contained "@includeRmd" |
166 syn match rOTag contained "@order" | |
8497
da01d5da2cfa
commit https://github.com/vim/vim/commit/77cdfd10382e01cc51f4ba1a9177032351843151
Christian Brabandt <cb@256bit.org>
parents:
7315
diff
changeset
|
167 endif |
4780 | 168 |
7 | 169 |
2725 | 170 if &filetype == "rhelp" |
171 " string enclosed in double quotes | |
172 syn region rString contains=rSpecial,@Spell start=/"/ skip=/\\\\\|\\"/ end=/"/ | |
173 " string enclosed in single quotes | |
174 syn region rString contains=rSpecial,@Spell start=/'/ skip=/\\\\\|\\'/ end=/'/ | |
175 else | |
176 " string enclosed in double quotes | |
177 syn region rString contains=rSpecial,rStrError,@Spell start=/"/ skip=/\\\\\|\\"/ end=/"/ | |
178 " string enclosed in single quotes | |
179 syn region rString contains=rSpecial,rStrError,@Spell start=/'/ skip=/\\\\\|\\'/ end=/'/ | |
180 endif | |
2608
7d8af31066c8
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
856
diff
changeset
|
181 |
7d8af31066c8
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
856
diff
changeset
|
182 syn match rStrError display contained "\\." |
7d8af31066c8
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
856
diff
changeset
|
183 |
2725 | 184 |
2608
7d8af31066c8
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
856
diff
changeset
|
185 " 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
|
186 syn match rSpecial display contained "\\\(n\|r\|t\|b\|a\|f\|v\|'\|\"\)\|\\\\" |
7 | 187 |
2608
7d8af31066c8
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
856
diff
changeset
|
188 " Hexadecimal and Octal digits |
7d8af31066c8
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
856
diff
changeset
|
189 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
|
190 |
7d8af31066c8
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
856
diff
changeset
|
191 " Unicode characters |
7d8af31066c8
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
856
diff
changeset
|
192 syn match rSpecial display contained "\\u\x\{1,4}" |
7d8af31066c8
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
856
diff
changeset
|
193 syn match rSpecial display contained "\\U\x\{1,8}" |
7d8af31066c8
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
856
diff
changeset
|
194 syn match rSpecial display contained "\\u{\x\{1,4}}" |
7d8af31066c8
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
856
diff
changeset
|
195 syn match rSpecial display contained "\\U{\x\{1,8}}" |
7d8af31066c8
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
856
diff
changeset
|
196 |
24520 | 197 " Raw string |
198 syn region rRawString matchgroup=rRawStrDelim start=/[rR]\z(['"]\)\z(-*\)(/ end=/)\z2\z1/ keepend | |
199 syn region rRawString matchgroup=rRawStrDelim start=/[rR]\z(['"]\)\z(-*\){/ end=/}\z2\z1/ keepend | |
200 syn region rRawString matchgroup=rRawStrDelim start=/[rR]\z(['"]\)\z(-*\)\[/ end=/\]\z2\z1/ keepend | |
201 | |
7 | 202 " Statement |
203 syn keyword rStatement break next return | |
204 syn keyword rConditional if else | |
205 syn keyword rRepeat for in repeat while | |
206 | |
2608
7d8af31066c8
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
856
diff
changeset
|
207 " Constant (not really) |
4780 | 208 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
|
209 syn keyword rConstant R.version.string |
7d8af31066c8
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
856
diff
changeset
|
210 |
6476 | 211 syn keyword rNumber NA_integer_ NA_real_ NA_complex_ NA_character_ |
2725 | 212 |
213 " Constants | |
7 | 214 syn keyword rConstant NULL |
215 syn keyword rBoolean FALSE TRUE | |
6476 | 216 syn keyword rNumber NA Inf NaN |
2608
7d8af31066c8
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
856
diff
changeset
|
217 |
7d8af31066c8
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
856
diff
changeset
|
218 " integer |
7d8af31066c8
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
856
diff
changeset
|
219 syn match rInteger "\<\d\+L" |
7d8af31066c8
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
856
diff
changeset
|
220 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
|
221 syn match rInteger "\<\d\+[Ee]+\=\d\+L" |
7d8af31066c8
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
856
diff
changeset
|
222 |
7d8af31066c8
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
856
diff
changeset
|
223 " number with no fractional part or exponent |
7d8af31066c8
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
856
diff
changeset
|
224 syn match rNumber "\<\d\+\>" |
6476 | 225 " hexadecimal number |
2608
7d8af31066c8
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
856
diff
changeset
|
226 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
|
227 |
7d8af31066c8
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
856
diff
changeset
|
228 " 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
|
229 syn match rFloat "\<\d\+\.\d*\([Ee][-+]\=\d\+\)\=" |
7d8af31066c8
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
856
diff
changeset
|
230 " 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
|
231 syn match rFloat "\<\.\d\+\([Ee][-+]\=\d\+\)\=" |
7d8af31066c8
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
856
diff
changeset
|
232 " 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
|
233 syn match rFloat "\<\d\+[Ee][-+]\=\d\+" |
7d8af31066c8
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
856
diff
changeset
|
234 |
2725 | 235 " complex number |
236 syn match rComplex "\<\d\+i" | |
237 syn match rComplex "\<\d\++\d\+i" | |
238 syn match rComplex "\<0x\([0-9]\|[a-f]\|[A-F]\)\+i" | |
239 syn match rComplex "\<\d\+\.\d*\([Ee][-+]\=\d\+\)\=i" | |
240 syn match rComplex "\<\.\d\+\([Ee][-+]\=\d\+\)\=i" | |
241 syn match rComplex "\<\d\+[Ee][-+]\=\d\+i" | |
242 | |
6476 | 243 syn match rAssign '=' |
2725 | 244 syn match rOperator "&" |
245 syn match rOperator '-' | |
4502
605c9ce57ec3
Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents:
2725
diff
changeset
|
246 syn match rOperator '\*' |
2725 | 247 syn match rOperator '+' |
4780 | 248 if &filetype != "rmd" && &filetype != "rrst" |
249 syn match rOperator "[|!<>^~/:]" | |
250 else | |
251 syn match rOperator "[|!<>^~`/:]" | |
252 endif | |
6051 | 253 syn match rOperator "%\{2}\|%\S\{-}%" |
6476 | 254 syn match rOperator '\([!><]\)\@<==' |
255 syn match rOperator '==' | |
4780 | 256 syn match rOpError '\*\{3}' |
2725 | 257 syn match rOpError '//' |
258 syn match rOpError '&&&' | |
259 syn match rOpError '|||' | |
260 syn match rOpError '<<' | |
261 syn match rOpError '>>' | |
262 | |
6476 | 263 syn match rAssign "<\{1,2}-" |
264 syn match rAssign "->\{1,2}" | |
7 | 265 |
266 " Special | |
2608
7d8af31066c8
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
856
diff
changeset
|
267 syn match rDelimiter "[,;:]" |
7 | 268 |
269 " Error | |
2725 | 270 if exists("g:r_syntax_folding") |
271 syn region rRegion matchgroup=Delimiter start=/(/ matchgroup=Delimiter end=/)/ transparent contains=ALLBUT,rError,rBraceError,rCurlyError fold | |
272 syn region rRegion matchgroup=Delimiter start=/{/ matchgroup=Delimiter end=/}/ transparent contains=ALLBUT,rError,rBraceError,rParenError fold | |
273 syn region rRegion matchgroup=Delimiter start=/\[/ matchgroup=Delimiter end=/]/ transparent contains=ALLBUT,rError,rCurlyError,rParenError fold | |
14637 | 274 syn region rSection matchgroup=Title start=/^#.*[-=#]\{4,}/ end=/^#.*[-=#]\{4,}/ms=s-2,me=s-1 transparent contains=ALL fold |
2725 | 275 else |
276 syn region rRegion matchgroup=Delimiter start=/(/ matchgroup=Delimiter end=/)/ transparent contains=ALLBUT,rError,rBraceError,rCurlyError | |
277 syn region rRegion matchgroup=Delimiter start=/{/ matchgroup=Delimiter end=/}/ transparent contains=ALLBUT,rError,rBraceError,rParenError | |
278 syn region rRegion matchgroup=Delimiter start=/\[/ matchgroup=Delimiter end=/]/ transparent contains=ALLBUT,rError,rCurlyError,rParenError | |
279 endif | |
280 | |
2608
7d8af31066c8
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
856
diff
changeset
|
281 syn match rError "[)\]}]" |
7d8af31066c8
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
856
diff
changeset
|
282 syn match rBraceError "[)}]" contained |
7d8af31066c8
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
856
diff
changeset
|
283 syn match rCurlyError "[)\]]" contained |
7d8af31066c8
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
856
diff
changeset
|
284 syn match rParenError "[\]}]" contained |
7d8af31066c8
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
856
diff
changeset
|
285 |
11347 | 286 " Use Nvim-R to highlight functions dynamically if it is installed |
287 if !exists("g:r_syntax_fun_pattern") | |
288 let s:ff = split(substitute(globpath(&rtp, "R/functions.vim"), "functions.vim", "", "g"), "\n") | |
289 if len(s:ff) > 0 | |
290 let g:r_syntax_fun_pattern = 0 | |
291 else | |
292 let g:r_syntax_fun_pattern = 1 | |
293 endif | |
8497
da01d5da2cfa
commit https://github.com/vim/vim/commit/77cdfd10382e01cc51f4ba1a9177032351843151
Christian Brabandt <cb@256bit.org>
parents:
7315
diff
changeset
|
294 endif |
11347 | 295 |
296 " Only use Nvim-R to highlight functions if they should not be highlighted | |
297 " according to a generic pattern | |
298 if g:r_syntax_fun_pattern == 1 | |
299 syn match rFunction '[0-9a-zA-Z_\.]\+\s*\ze(' | |
300 else | |
14637 | 301 " Nvim-R: |
302 runtime R/functions.vim | |
6476 | 303 endif |
2725 | 304 |
305 syn match rDollar display contained "\$" | |
4780 | 306 syn match rDollar display contained "@" |
2725 | 307 |
308 " List elements will not be highlighted as functions: | |
309 syn match rLstElmt "\$[a-zA-Z0-9\\._]*" contains=rDollar | |
4780 | 310 syn match rLstElmt "@[a-zA-Z0-9\\._]*" contains=rDollar |
2725 | 311 |
2608
7d8af31066c8
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
856
diff
changeset
|
312 " Functions that may add new objects |
7d8af31066c8
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
856
diff
changeset
|
313 syn keyword rPreProc library require attach detach source |
7d8af31066c8
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
856
diff
changeset
|
314 |
2725 | 315 if &filetype == "rhelp" |
6051 | 316 syn match rHelpIdent '\\method' |
317 syn match rHelpIdent '\\S4method' | |
2725 | 318 endif |
319 | |
2608
7d8af31066c8
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
856
diff
changeset
|
320 " Type |
6476 | 321 syn keyword rType array category character complex double function integer list logical matrix numeric vector data.frame |
7 | 322 |
2725 | 323 " Name of object with spaces |
4780 | 324 if &filetype != "rmd" && &filetype != "rrst" |
14637 | 325 syn region rNameWSpace start="`" end="`" contains=rSpaceFun |
4780 | 326 endif |
2725 | 327 |
328 if &filetype == "rhelp" | |
6476 | 329 syn match rhPreProc "^#ifdef.*" |
330 syn match rhPreProc "^#endif.*" | |
2725 | 331 syn match rhSection "\\dontrun\>" |
332 endif | |
333 | |
11347 | 334 if exists("r_syntax_minlines") |
335 exe "syn sync minlines=" . r_syntax_minlines | |
6476 | 336 else |
337 syn sync minlines=40 | |
338 endif | |
339 | |
7 | 340 " Define the default highlighting. |
6476 | 341 hi def link rAssign Statement |
2608
7d8af31066c8
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
856
diff
changeset
|
342 hi def link rBoolean Boolean |
7d8af31066c8
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
856
diff
changeset
|
343 hi def link rBraceError Error |
7d8af31066c8
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
856
diff
changeset
|
344 hi def link rComment Comment |
14637 | 345 hi def link rTodoParen Comment |
346 hi def link rTodoInfo SpecialComment | |
6051 | 347 hi def link rCommentTodo Todo |
14637 | 348 hi def link rTodoKeyw Todo |
2608
7d8af31066c8
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
856
diff
changeset
|
349 hi def link rComplex Number |
7d8af31066c8
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
856
diff
changeset
|
350 hi def link rConditional Conditional |
7d8af31066c8
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
856
diff
changeset
|
351 hi def link rConstant Constant |
7d8af31066c8
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
856
diff
changeset
|
352 hi def link rCurlyError Error |
7d8af31066c8
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
856
diff
changeset
|
353 hi def link rDelimiter Delimiter |
7d8af31066c8
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
856
diff
changeset
|
354 hi def link rDollar SpecialChar |
7d8af31066c8
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
856
diff
changeset
|
355 hi def link rError Error |
7d8af31066c8
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
856
diff
changeset
|
356 hi def link rFloat Float |
2725 | 357 hi def link rFunction Function |
14637 | 358 hi def link rSpaceFun Function |
2725 | 359 hi def link rHelpIdent Identifier |
360 hi def link rhPreProc PreProc | |
361 hi def link rhSection PreCondit | |
2608
7d8af31066c8
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
856
diff
changeset
|
362 hi def link rInteger Number |
6476 | 363 hi def link rLstElmt Normal |
2725 | 364 hi def link rNameWSpace Normal |
2608
7d8af31066c8
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
856
diff
changeset
|
365 hi def link rNumber Number |
7d8af31066c8
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
856
diff
changeset
|
366 hi def link rOperator Operator |
2725 | 367 hi def link rOpError Error |
2608
7d8af31066c8
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
856
diff
changeset
|
368 hi def link rParenError Error |
7d8af31066c8
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
856
diff
changeset
|
369 hi def link rPreProc PreProc |
24520 | 370 hi def link rRawString String |
371 hi def link rRawStrDelim Delimiter | |
2608
7d8af31066c8
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
856
diff
changeset
|
372 hi def link rRepeat Repeat |
7d8af31066c8
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
856
diff
changeset
|
373 hi def link rSpecial SpecialChar |
7d8af31066c8
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
856
diff
changeset
|
374 hi def link rStatement Statement |
7d8af31066c8
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
856
diff
changeset
|
375 hi def link rString String |
7d8af31066c8
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
856
diff
changeset
|
376 hi def link rStrError Error |
7d8af31066c8
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
856
diff
changeset
|
377 hi def link rType Type |
11347 | 378 if g:r_syntax_hl_roxygen |
379 hi def link rOTitleTag Operator | |
380 hi def link rOTag Operator | |
381 hi def link rOTitleBlock Title | |
382 hi def link rOBlock Comment | |
383 hi def link rOBlockNoTitle Comment | |
24520 | 384 hi def link rOR6Block Comment |
8497
da01d5da2cfa
commit https://github.com/vim/vim/commit/77cdfd10382e01cc51f4ba1a9177032351843151
Christian Brabandt <cb@256bit.org>
parents:
7315
diff
changeset
|
385 hi def link rOTitle Title |
da01d5da2cfa
commit https://github.com/vim/vim/commit/77cdfd10382e01cc51f4ba1a9177032351843151
Christian Brabandt <cb@256bit.org>
parents:
7315
diff
changeset
|
386 hi def link rOCommentKey Comment |
da01d5da2cfa
commit https://github.com/vim/vim/commit/77cdfd10382e01cc51f4ba1a9177032351843151
Christian Brabandt <cb@256bit.org>
parents:
7315
diff
changeset
|
387 hi def link rOExamples SpecialComment |
da01d5da2cfa
commit https://github.com/vim/vim/commit/77cdfd10382e01cc51f4ba1a9177032351843151
Christian Brabandt <cb@256bit.org>
parents:
7315
diff
changeset
|
388 endif |
7315
444efa5f5015
commit https://github.com/vim/vim/commit/2c5e8e80eacf491d4f266983f534a77776c7ae83
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
389 |
7 | 390 let b:current_syntax="r" |
391 | |
392 " vim: ts=8 sw=2 |