Mercurial > vim
annotate runtime/syntax/r.vim @ 7052:9ec3329823f9 v7.4.838
commit https://github.com/vim/vim/commit/8060687905bdadc46abb68ee6d40e5660e352297
Author: Bram Moolenaar <Bram@vim.org>
Date: Tue Aug 25 21:27:35 2015 +0200
patch 7.4.838
Problem: Can't compile without the crypt feature. (John Marriott)
Solution: Add #ifdef.
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Tue, 25 Aug 2015 21:30:04 +0200 |
parents | 11d78e58a487 |
children | 444efa5f5015 |
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> |
6476 | 6 " Last Change: Wed Dec 31, 2014 12:36AM |
2608
7d8af31066c8
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
856
diff
changeset
|
7 " Filenames: *.R *.r *.Rhistory *.Rt |
6476 | 8 " |
9 " NOTE: The highlighting of R functions is defined in | |
10 " 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
|
11 " |
2725 | 12 " CONFIGURATION: |
13 " syntax folding can be turned on by | |
14 " | |
15 " let r_syntax_folding = 1 | |
16 " | |
2608
7d8af31066c8
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
856
diff
changeset
|
17 " Some lines of code were borrowed from Zhuojun Chen. |
625 | 18 |
2608
7d8af31066c8
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
856
diff
changeset
|
19 if exists("b:current_syntax") |
7 | 20 finish |
21 endif | |
22 | |
2608
7d8af31066c8
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
856
diff
changeset
|
23 setlocal iskeyword=@,48-57,_,. |
7 | 24 |
2725 | 25 if exists("g:r_syntax_folding") |
26 setlocal foldmethod=syntax | |
27 endif | |
28 | |
7 | 29 syn case match |
30 | |
31 " Comment | |
6051 | 32 syn match rCommentTodo contained "\(BUG\|FIXME\|NOTE\|TODO\):" |
33 syn match rComment contains=@Spell,rCommentTodo "#.*" | |
4780 | 34 |
35 " Roxygen | |
36 syn match rOKeyword contained "@\(param\|return\|name\|rdname\|examples\|include\|docType\)" | |
37 syn match rOKeyword contained "@\(S3method\|TODO\|aliases\|alias\|assignee\|author\|callGraphDepth\|callGraph\)" | |
38 syn match rOKeyword contained "@\(callGraphPrimitives\|concept\|exportClass\|exportMethod\|exportPattern\|export\|formals\)" | |
6476 | 39 syn match rOKeyword contained "@\(format\|importClassesFrom\|importFrom\|importMethodsFrom\|import\|keywords\|useDynLib\)" |
6051 | 40 syn match rOKeyword contained "@\(method\|noRd\|note\|references\|seealso\|setClass\|slot\|source\|title\|usage\)" |
6476 | 41 syn match rOKeyword contained "@\(family\|template\|templateVar\|description\|details\|inheritParams\)" |
4780 | 42 syn match rOComment contains=@Spell,rOKeyword "#'.*" |
43 | |
7 | 44 |
2725 | 45 if &filetype == "rhelp" |
46 " string enclosed in double quotes | |
47 syn region rString contains=rSpecial,@Spell start=/"/ skip=/\\\\\|\\"/ end=/"/ | |
48 " string enclosed in single quotes | |
49 syn region rString contains=rSpecial,@Spell start=/'/ skip=/\\\\\|\\'/ end=/'/ | |
50 else | |
51 " string enclosed in double quotes | |
52 syn region rString contains=rSpecial,rStrError,@Spell start=/"/ skip=/\\\\\|\\"/ end=/"/ | |
53 " string enclosed in single quotes | |
54 syn region rString contains=rSpecial,rStrError,@Spell start=/'/ skip=/\\\\\|\\'/ end=/'/ | |
55 endif | |
2608
7d8af31066c8
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
856
diff
changeset
|
56 |
7d8af31066c8
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
856
diff
changeset
|
57 syn match rStrError display contained "\\." |
7d8af31066c8
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
856
diff
changeset
|
58 |
2725 | 59 |
2608
7d8af31066c8
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
856
diff
changeset
|
60 " 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
|
61 syn match rSpecial display contained "\\\(n\|r\|t\|b\|a\|f\|v\|'\|\"\)\|\\\\" |
7 | 62 |
2608
7d8af31066c8
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
856
diff
changeset
|
63 " Hexadecimal and Octal digits |
7d8af31066c8
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
856
diff
changeset
|
64 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
|
65 |
7d8af31066c8
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
856
diff
changeset
|
66 " Unicode characters |
7d8af31066c8
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
856
diff
changeset
|
67 syn match rSpecial display contained "\\u\x\{1,4}" |
7d8af31066c8
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
856
diff
changeset
|
68 syn match rSpecial display contained "\\U\x\{1,8}" |
7d8af31066c8
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
856
diff
changeset
|
69 syn match rSpecial display contained "\\u{\x\{1,4}}" |
7d8af31066c8
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
856
diff
changeset
|
70 syn match rSpecial display contained "\\U{\x\{1,8}}" |
7d8af31066c8
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
856
diff
changeset
|
71 |
7 | 72 " Statement |
73 syn keyword rStatement break next return | |
74 syn keyword rConditional if else | |
75 syn keyword rRepeat for in repeat while | |
76 | |
2608
7d8af31066c8
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
856
diff
changeset
|
77 " Constant (not really) |
4780 | 78 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
|
79 syn keyword rConstant R.version.string |
7d8af31066c8
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
856
diff
changeset
|
80 |
6476 | 81 syn keyword rNumber NA_integer_ NA_real_ NA_complex_ NA_character_ |
2725 | 82 |
83 " Constants | |
7 | 84 syn keyword rConstant NULL |
85 syn keyword rBoolean FALSE TRUE | |
6476 | 86 syn keyword rNumber NA Inf NaN |
2608
7d8af31066c8
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
856
diff
changeset
|
87 |
7d8af31066c8
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
856
diff
changeset
|
88 " integer |
7d8af31066c8
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
856
diff
changeset
|
89 syn match rInteger "\<\d\+L" |
7d8af31066c8
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
856
diff
changeset
|
90 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
|
91 syn match rInteger "\<\d\+[Ee]+\=\d\+L" |
7d8af31066c8
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
856
diff
changeset
|
92 |
7d8af31066c8
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
856
diff
changeset
|
93 " number with no fractional part or exponent |
7d8af31066c8
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
856
diff
changeset
|
94 syn match rNumber "\<\d\+\>" |
6476 | 95 " hexadecimal number |
2608
7d8af31066c8
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
856
diff
changeset
|
96 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
|
97 |
7d8af31066c8
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
856
diff
changeset
|
98 " 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
|
99 syn match rFloat "\<\d\+\.\d*\([Ee][-+]\=\d\+\)\=" |
7d8af31066c8
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
856
diff
changeset
|
100 " 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
|
101 syn match rFloat "\<\.\d\+\([Ee][-+]\=\d\+\)\=" |
7d8af31066c8
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
856
diff
changeset
|
102 " 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
|
103 syn match rFloat "\<\d\+[Ee][-+]\=\d\+" |
7d8af31066c8
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
856
diff
changeset
|
104 |
2725 | 105 " complex number |
106 syn match rComplex "\<\d\+i" | |
107 syn match rComplex "\<\d\++\d\+i" | |
108 syn match rComplex "\<0x\([0-9]\|[a-f]\|[A-F]\)\+i" | |
109 syn match rComplex "\<\d\+\.\d*\([Ee][-+]\=\d\+\)\=i" | |
110 syn match rComplex "\<\.\d\+\([Ee][-+]\=\d\+\)\=i" | |
111 syn match rComplex "\<\d\+[Ee][-+]\=\d\+i" | |
112 | |
6476 | 113 syn match rAssign '=' |
2725 | 114 syn match rOperator "&" |
115 syn match rOperator '-' | |
4502
605c9ce57ec3
Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents:
2725
diff
changeset
|
116 syn match rOperator '\*' |
2725 | 117 syn match rOperator '+' |
4780 | 118 if &filetype != "rmd" && &filetype != "rrst" |
119 syn match rOperator "[|!<>^~/:]" | |
120 else | |
121 syn match rOperator "[|!<>^~`/:]" | |
122 endif | |
6051 | 123 syn match rOperator "%\{2}\|%\S\{-}%" |
6476 | 124 syn match rOperator '\([!><]\)\@<==' |
125 syn match rOperator '==' | |
4780 | 126 syn match rOpError '\*\{3}' |
2725 | 127 syn match rOpError '//' |
128 syn match rOpError '&&&' | |
129 syn match rOpError '|||' | |
130 syn match rOpError '<<' | |
131 syn match rOpError '>>' | |
132 | |
6476 | 133 syn match rAssign "<\{1,2}-" |
134 syn match rAssign "->\{1,2}" | |
7 | 135 |
136 " Special | |
2608
7d8af31066c8
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
856
diff
changeset
|
137 syn match rDelimiter "[,;:]" |
7 | 138 |
139 " Error | |
2725 | 140 if exists("g:r_syntax_folding") |
141 syn region rRegion matchgroup=Delimiter start=/(/ matchgroup=Delimiter end=/)/ transparent contains=ALLBUT,rError,rBraceError,rCurlyError fold | |
142 syn region rRegion matchgroup=Delimiter start=/{/ matchgroup=Delimiter end=/}/ transparent contains=ALLBUT,rError,rBraceError,rParenError fold | |
143 syn region rRegion matchgroup=Delimiter start=/\[/ matchgroup=Delimiter end=/]/ transparent contains=ALLBUT,rError,rCurlyError,rParenError fold | |
144 else | |
145 syn region rRegion matchgroup=Delimiter start=/(/ matchgroup=Delimiter end=/)/ transparent contains=ALLBUT,rError,rBraceError,rCurlyError | |
146 syn region rRegion matchgroup=Delimiter start=/{/ matchgroup=Delimiter end=/}/ transparent contains=ALLBUT,rError,rBraceError,rParenError | |
147 syn region rRegion matchgroup=Delimiter start=/\[/ matchgroup=Delimiter end=/]/ transparent contains=ALLBUT,rError,rCurlyError,rParenError | |
148 endif | |
149 | |
2608
7d8af31066c8
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
856
diff
changeset
|
150 syn match rError "[)\]}]" |
7d8af31066c8
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
856
diff
changeset
|
151 syn match rBraceError "[)}]" contained |
7d8af31066c8
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
856
diff
changeset
|
152 syn match rCurlyError "[)\]]" contained |
7d8af31066c8
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
856
diff
changeset
|
153 syn match rParenError "[\]}]" contained |
7d8af31066c8
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
856
diff
changeset
|
154 |
6476 | 155 " Source list of R functions produced by a filetype plugin (if installed) |
156 if has("nvim") | |
157 " Nvim-R | |
158 runtime R/functions.vim | |
159 else | |
160 " Vim-R-plugin | |
161 runtime r-plugin/functions.vim | |
162 endif | |
2725 | 163 |
164 syn match rDollar display contained "\$" | |
4780 | 165 syn match rDollar display contained "@" |
2725 | 166 |
167 " List elements will not be highlighted as functions: | |
168 syn match rLstElmt "\$[a-zA-Z0-9\\._]*" contains=rDollar | |
4780 | 169 syn match rLstElmt "@[a-zA-Z0-9\\._]*" contains=rDollar |
2725 | 170 |
2608
7d8af31066c8
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
856
diff
changeset
|
171 " Functions that may add new objects |
7d8af31066c8
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
856
diff
changeset
|
172 syn keyword rPreProc library require attach detach source |
7d8af31066c8
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
856
diff
changeset
|
173 |
2725 | 174 if &filetype == "rhelp" |
6051 | 175 syn match rHelpIdent '\\method' |
176 syn match rHelpIdent '\\S4method' | |
2725 | 177 endif |
178 | |
2608
7d8af31066c8
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
856
diff
changeset
|
179 " Type |
6476 | 180 syn keyword rType array category character complex double function integer list logical matrix numeric vector data.frame |
7 | 181 |
2725 | 182 " Name of object with spaces |
4780 | 183 if &filetype != "rmd" && &filetype != "rrst" |
184 syn region rNameWSpace start="`" end="`" | |
185 endif | |
2725 | 186 |
187 if &filetype == "rhelp" | |
6476 | 188 syn match rhPreProc "^#ifdef.*" |
189 syn match rhPreProc "^#endif.*" | |
2725 | 190 syn match rhSection "\\dontrun\>" |
191 endif | |
192 | |
6476 | 193 if exists("r_syn_minlines") |
194 exe "syn sync minlines=" . r_syn_minlines | |
195 else | |
196 syn sync minlines=40 | |
197 endif | |
198 | |
7 | 199 " Define the default highlighting. |
6476 | 200 hi def link rAssign Statement |
2608
7d8af31066c8
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
856
diff
changeset
|
201 hi def link rBoolean Boolean |
7d8af31066c8
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
856
diff
changeset
|
202 hi def link rBraceError Error |
7d8af31066c8
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
856
diff
changeset
|
203 hi def link rComment Comment |
6051 | 204 hi def link rCommentTodo Todo |
4780 | 205 hi def link rOComment Comment |
2608
7d8af31066c8
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
856
diff
changeset
|
206 hi def link rComplex Number |
7d8af31066c8
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
856
diff
changeset
|
207 hi def link rConditional Conditional |
7d8af31066c8
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
856
diff
changeset
|
208 hi def link rConstant Constant |
7d8af31066c8
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
856
diff
changeset
|
209 hi def link rCurlyError Error |
7d8af31066c8
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
856
diff
changeset
|
210 hi def link rDelimiter Delimiter |
7d8af31066c8
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
856
diff
changeset
|
211 hi def link rDollar SpecialChar |
7d8af31066c8
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
856
diff
changeset
|
212 hi def link rError Error |
7d8af31066c8
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
856
diff
changeset
|
213 hi def link rFloat Float |
2725 | 214 hi def link rFunction Function |
215 hi def link rHelpIdent Identifier | |
216 hi def link rhPreProc PreProc | |
217 hi def link rhSection PreCondit | |
2608
7d8af31066c8
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
856
diff
changeset
|
218 hi def link rInteger Number |
6476 | 219 hi def link rLstElmt Normal |
2725 | 220 hi def link rNameWSpace Normal |
2608
7d8af31066c8
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
856
diff
changeset
|
221 hi def link rNumber Number |
7d8af31066c8
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
856
diff
changeset
|
222 hi def link rOperator Operator |
2725 | 223 hi def link rOpError Error |
2608
7d8af31066c8
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
856
diff
changeset
|
224 hi def link rParenError Error |
7d8af31066c8
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
856
diff
changeset
|
225 hi def link rPreProc PreProc |
7d8af31066c8
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
856
diff
changeset
|
226 hi def link rRepeat Repeat |
7d8af31066c8
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
856
diff
changeset
|
227 hi def link rSpecial SpecialChar |
7d8af31066c8
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
856
diff
changeset
|
228 hi def link rStatement Statement |
7d8af31066c8
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
856
diff
changeset
|
229 hi def link rString String |
7d8af31066c8
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
856
diff
changeset
|
230 hi def link rStrError Error |
7d8af31066c8
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
856
diff
changeset
|
231 hi def link rType Type |
4780 | 232 hi def link rOKeyword Title |
7 | 233 |
234 let b:current_syntax="r" | |
235 | |
236 " vim: ts=8 sw=2 |