Mercurial > vim
comparison runtime/syntax/r.vim @ 2725:6f63330ec225
Updated runtime files.
author | Bram Moolenaar <bram@vim.org> |
---|---|
date | Tue, 22 Mar 2011 14:05:35 +0100 |
parents | 7d8af31066c8 |
children | 605c9ce57ec3 |
comparison
equal
deleted
inserted
replaced
2724:96a7b564c2f3 | 2725:6f63330ec225 |
---|---|
1 " Vim syntax file | 1 " Vim syntax file |
2 " Language: R (GNU S) | 2 " Language: R (GNU S) |
3 " Maintainer: Jakson Aquino <jalvesaq@gmail.com> | 3 " Maintainer: Jakson Aquino <jalvesaq@gmail.com> |
4 " Former Maintainers: Vaidotas Zemlys <zemlys@gmail.com> | 4 " Former Maintainers: Vaidotas Zemlys <zemlys@gmail.com> |
5 " Tom Payne <tom@tompayne.org> | 5 " Tom Payne <tom@tompayne.org> |
6 " Last Change: Wed Sep 29, 2010 09:31AM | 6 " Last Change: Sun Feb 20, 2011 12:06PM |
7 " Filenames: *.R *.r *.Rhistory *.Rt | 7 " Filenames: *.R *.r *.Rhistory *.Rt |
8 " | 8 " |
9 " NOTE: The highlighting of R functions is defined in the | 9 " NOTE: The highlighting of R functions is defined in the |
10 " r-plugin/functions.vim, which is part of vim-r-plugin2: | 10 " r-plugin/functions.vim, which is part of vim-r-plugin2: |
11 " http://www.vim.org/scripts/script.php?script_id=2628 | 11 " http://www.vim.org/scripts/script.php?script_id=2628 |
12 " | 12 " |
13 " CONFIGURATION: | |
14 " syntax folding can be turned on by | |
15 " | |
16 " let r_syntax_folding = 1 | |
17 " | |
13 " Some lines of code were borrowed from Zhuojun Chen. | 18 " Some lines of code were borrowed from Zhuojun Chen. |
14 | 19 |
15 if exists("b:current_syntax") | 20 if exists("b:current_syntax") |
16 finish | 21 finish |
17 endif | 22 endif |
18 | 23 |
19 setlocal iskeyword=@,48-57,_,. | 24 setlocal iskeyword=@,48-57,_,. |
20 | 25 |
26 if exists("g:r_syntax_folding") | |
27 setlocal foldmethod=syntax | |
28 endif | |
29 | |
21 syn case match | 30 syn case match |
22 | 31 |
23 " Comment | 32 " Comment |
24 syn match rComment contains=@Spell "\#.*" | 33 syn match rComment contains=@Spell "\#.*" |
25 | 34 |
26 " string enclosed in double quotes | 35 if &filetype == "rhelp" |
27 syn region rString contains=rSpecial,rStrError,@Spell start=/"/ skip=/\\\\\|\\"/ end=/"/ | 36 " string enclosed in double quotes |
28 " string enclosed in single quotes | 37 syn region rString contains=rSpecial,@Spell start=/"/ skip=/\\\\\|\\"/ end=/"/ |
29 syn region rString contains=rSpecial,rStrError,@Spell start=/'/ skip=/\\\\\|\\'/ end=/'/ | 38 " string enclosed in single quotes |
39 syn region rString contains=rSpecial,@Spell start=/'/ skip=/\\\\\|\\'/ end=/'/ | |
40 else | |
41 " string enclosed in double quotes | |
42 syn region rString contains=rSpecial,rStrError,@Spell start=/"/ skip=/\\\\\|\\"/ end=/"/ | |
43 " string enclosed in single quotes | |
44 syn region rString contains=rSpecial,rStrError,@Spell start=/'/ skip=/\\\\\|\\'/ end=/'/ | |
45 endif | |
30 | 46 |
31 syn match rStrError display contained "\\." | 47 syn match rStrError display contained "\\." |
48 | |
32 | 49 |
33 " New line, carriage return, tab, backspace, bell, feed, vertical tab, backslash | 50 " New line, carriage return, tab, backspace, bell, feed, vertical tab, backslash |
34 syn match rSpecial display contained "\\\(n\|r\|t\|b\|a\|f\|v\|'\|\"\)\|\\\\" | 51 syn match rSpecial display contained "\\\(n\|r\|t\|b\|a\|f\|v\|'\|\"\)\|\\\\" |
35 | 52 |
36 " Hexadecimal and Octal digits | 53 " Hexadecimal and Octal digits |
40 syn match rSpecial display contained "\\u\x\{1,4}" | 57 syn match rSpecial display contained "\\u\x\{1,4}" |
41 syn match rSpecial display contained "\\U\x\{1,8}" | 58 syn match rSpecial display contained "\\U\x\{1,8}" |
42 syn match rSpecial display contained "\\u{\x\{1,4}}" | 59 syn match rSpecial display contained "\\u{\x\{1,4}}" |
43 syn match rSpecial display contained "\\U{\x\{1,8}}" | 60 syn match rSpecial display contained "\\U{\x\{1,8}}" |
44 | 61 |
45 | |
46 syn match rDollar "\$" | |
47 | |
48 " Statement | 62 " Statement |
49 syn keyword rStatement break next return | 63 syn keyword rStatement break next return |
50 syn keyword rConditional if else | 64 syn keyword rConditional if else |
51 syn keyword rRepeat for in repeat while | 65 syn keyword rRepeat for in repeat while |
52 | 66 |
53 " Constant (not really) | 67 " Constant (not really) |
54 syn keyword rConstant T F LETTERS letters month.ab month.name pi | 68 syn keyword rConstant T F LETTERS letters month.ab month.name pi |
55 syn keyword rConstant R.version.string | 69 syn keyword rConstant R.version.string |
56 | 70 |
57 " Constant | 71 syn keyword rNumber NA_integer_ NA_real_ NA_complex_ NA_character_ |
72 | |
73 " Constants | |
58 syn keyword rConstant NULL | 74 syn keyword rConstant NULL |
59 syn keyword rBoolean FALSE TRUE | 75 syn keyword rBoolean FALSE TRUE |
60 syn keyword rNumber NA NA_integer_ NA_real_ NA_complex_ NA_character_ | 76 syn keyword rNumber NA Inf NaN |
61 syn keyword rNumber Inf NaN | |
62 | 77 |
63 " integer | 78 " integer |
64 syn match rInteger "\<\d\+L" | 79 syn match rInteger "\<\d\+L" |
65 syn match rInteger "\<0x\([0-9]\|[a-f]\|[A-F]\)\+L" | 80 syn match rInteger "\<0x\([0-9]\|[a-f]\|[A-F]\)\+L" |
66 syn match rInteger "\<\d\+[Ee]+\=\d\+L" | 81 syn match rInteger "\<\d\+[Ee]+\=\d\+L" |
67 | |
68 syn match rOperator "[\*\!\&\+\-\<\>\=\^\|\~\`/:@]" | |
69 syn match rOperator "%\{2}\|%\*%\|%\/%\|%in%\|%o%\|%x%" | |
70 | |
71 syn match rComplex "\<\d\+i" | |
72 syn match rComplex "\<0x\([0-9]\|[a-f]\|[A-F]\)\+i" | |
73 syn match rComplex "\<\d\+\.\d*\([Ee][-+]\=\d\+\)\=i" | |
74 syn match rComplex "\<\.\d\+\([Ee][-+]\=\d\+\)\=i" | |
75 syn match rComplex "\<\d\+[Ee][-+]\=\d\+i" | |
76 | 82 |
77 " number with no fractional part or exponent | 83 " number with no fractional part or exponent |
78 syn match rNumber "\<\d\+\>" | 84 syn match rNumber "\<\d\+\>" |
79 " hexadecimal number | 85 " hexadecimal number |
80 syn match rNumber "\<0x\([0-9]\|[a-f]\|[A-F]\)\+" | 86 syn match rNumber "\<0x\([0-9]\|[a-f]\|[A-F]\)\+" |
84 " floating point number with no integer part and optional exponent | 90 " floating point number with no integer part and optional exponent |
85 syn match rFloat "\<\.\d\+\([Ee][-+]\=\d\+\)\=" | 91 syn match rFloat "\<\.\d\+\([Ee][-+]\=\d\+\)\=" |
86 " floating point number with no fractional part and optional exponent | 92 " floating point number with no fractional part and optional exponent |
87 syn match rFloat "\<\d\+[Ee][-+]\=\d\+" | 93 syn match rFloat "\<\d\+[Ee][-+]\=\d\+" |
88 | 94 |
95 " complex number | |
96 syn match rComplex "\<\d\+i" | |
97 syn match rComplex "\<\d\++\d\+i" | |
98 syn match rComplex "\<0x\([0-9]\|[a-f]\|[A-F]\)\+i" | |
99 syn match rComplex "\<\d\+\.\d*\([Ee][-+]\=\d\+\)\=i" | |
100 syn match rComplex "\<\.\d\+\([Ee][-+]\=\d\+\)\=i" | |
101 syn match rComplex "\<\d\+[Ee][-+]\=\d\+i" | |
102 | |
103 syn match rOperator "&" | |
104 syn match rOperator '-' | |
105 syn match rOperator '*' | |
106 syn match rOperator '+' | |
107 syn match rOperator '=' | |
108 syn match rOperator "[|!<>^~`/:@]" | |
109 syn match rOperator "%\{2}\|%\*%\|%\/%\|%in%\|%o%\|%x%" | |
110 syn match rOpError '*\{3}' | |
111 syn match rOpError '//' | |
112 syn match rOpError '&&&' | |
113 syn match rOpError '|||' | |
114 syn match rOpError '<<' | |
115 syn match rOpError '>>' | |
116 | |
89 syn match rArrow "<\{1,2}-" | 117 syn match rArrow "<\{1,2}-" |
90 syn match rArrow "->\{1,2}" | 118 syn match rArrow "->\{1,2}" |
91 | 119 |
92 " Special | 120 " Special |
93 syn match rDelimiter "[,;:]" | 121 syn match rDelimiter "[,;:]" |
94 | 122 |
95 " Error | 123 " Error |
96 syn region rRegion matchgroup=Delimiter start=/(/ matchgroup=Delimiter end=/)/ transparent contains=ALLBUT,rError,rBraceError,rCurlyError | 124 if exists("g:r_syntax_folding") |
97 syn region rRegion matchgroup=Delimiter start=/{/ matchgroup=Delimiter end=/}/ transparent contains=ALLBUT,rError,rBraceError,rParenError | 125 syn region rRegion matchgroup=Delimiter start=/(/ matchgroup=Delimiter end=/)/ transparent contains=ALLBUT,rError,rBraceError,rCurlyError fold |
98 syn region rRegion matchgroup=Delimiter start=/\[/ matchgroup=Delimiter end=/]/ transparent contains=ALLBUT,rError,rCurlyError,rParenError | 126 syn region rRegion matchgroup=Delimiter start=/{/ matchgroup=Delimiter end=/}/ transparent contains=ALLBUT,rError,rBraceError,rParenError fold |
127 syn region rRegion matchgroup=Delimiter start=/\[/ matchgroup=Delimiter end=/]/ transparent contains=ALLBUT,rError,rCurlyError,rParenError fold | |
128 else | |
129 syn region rRegion matchgroup=Delimiter start=/(/ matchgroup=Delimiter end=/)/ transparent contains=ALLBUT,rError,rBraceError,rCurlyError | |
130 syn region rRegion matchgroup=Delimiter start=/{/ matchgroup=Delimiter end=/}/ transparent contains=ALLBUT,rError,rBraceError,rParenError | |
131 syn region rRegion matchgroup=Delimiter start=/\[/ matchgroup=Delimiter end=/]/ transparent contains=ALLBUT,rError,rCurlyError,rParenError | |
132 endif | |
133 | |
99 syn match rError "[)\]}]" | 134 syn match rError "[)\]}]" |
100 syn match rBraceError "[)}]" contained | 135 syn match rBraceError "[)}]" contained |
101 syn match rCurlyError "[)\]]" contained | 136 syn match rCurlyError "[)\]]" contained |
102 syn match rParenError "[\]}]" contained | 137 syn match rParenError "[\]}]" contained |
103 | 138 |
139 " Source list of R functions. The list is produced by the Vim-R-plugin | |
140 " http://www.vim.org/scripts/script.php?script_id=2628 | |
141 runtime r-plugin/functions.vim | |
142 | |
143 syn match rDollar display contained "\$" | |
144 | |
145 " List elements will not be highlighted as functions: | |
146 syn match rLstElmt "\$[a-zA-Z0-9\\._]*" contains=rDollar | |
147 | |
104 " Functions that may add new objects | 148 " Functions that may add new objects |
105 syn keyword rPreProc library require attach detach source | 149 syn keyword rPreProc library require attach detach source |
106 | 150 |
151 if &filetype == "rhelp" | |
152 syn match rHelpIdent '\\method' | |
153 syn match rHelpIdent '\\S4method' | |
154 endif | |
155 | |
107 " Type | 156 " Type |
108 syn keyword rType array category character complex double function integer list logical matrix numeric vector data.frame | 157 syn keyword rType array category character complex double function integer list logical matrix numeric vector data.frame |
158 | |
159 " Name of object with spaces | |
160 syn region rNameWSpace start="`" end="`" | |
161 | |
162 if &filetype == "rhelp" | |
163 syn match rhPreProc "^#ifdef.*" | |
164 syn match rhPreProc "^#endif.*" | |
165 syn match rhSection "\\dontrun\>" | |
166 endif | |
109 | 167 |
110 " Define the default highlighting. | 168 " Define the default highlighting. |
111 hi def link rArrow Statement | 169 hi def link rArrow Statement |
112 hi def link rBoolean Boolean | 170 hi def link rBoolean Boolean |
113 hi def link rBraceError Error | 171 hi def link rBraceError Error |
118 hi def link rCurlyError Error | 176 hi def link rCurlyError Error |
119 hi def link rDelimiter Delimiter | 177 hi def link rDelimiter Delimiter |
120 hi def link rDollar SpecialChar | 178 hi def link rDollar SpecialChar |
121 hi def link rError Error | 179 hi def link rError Error |
122 hi def link rFloat Float | 180 hi def link rFloat Float |
181 hi def link rFunction Function | |
182 hi def link rHelpIdent Identifier | |
183 hi def link rhPreProc PreProc | |
184 hi def link rhSection PreCondit | |
123 hi def link rInteger Number | 185 hi def link rInteger Number |
186 hi def link rLstElmt Normal | |
187 hi def link rNameWSpace Normal | |
124 hi def link rNumber Number | 188 hi def link rNumber Number |
125 hi def link rOperator Operator | 189 hi def link rOperator Operator |
190 hi def link rOpError Error | |
126 hi def link rParenError Error | 191 hi def link rParenError Error |
127 hi def link rPreProc PreProc | 192 hi def link rPreProc PreProc |
128 hi def link rRepeat Repeat | 193 hi def link rRepeat Repeat |
129 hi def link rSpecial SpecialChar | 194 hi def link rSpecial SpecialChar |
130 hi def link rStatement Statement | 195 hi def link rStatement Statement |