Mercurial > vim
comparison runtime/syntax/r.vim @ 2608:7d8af31066c8
Updated runtime files and translations.
author | Bram Moolenaar <bram@vim.org> |
---|---|
date | Wed, 20 Oct 2010 18:45:33 +0200 |
parents | 8cd729851562 |
children | 6f63330ec225 |
comparison
equal
deleted
inserted
replaced
2607:2f57d93bdbf6 | 2608:7d8af31066c8 |
---|---|
1 " Vim syntax file | 1 " Vim syntax file |
2 " Language: R (GNU S) | 2 " Language: R (GNU S) |
3 " Maintainer: Vaidotas Zemlys <zemlys@gmail.com> | 3 " Maintainer: Jakson Aquino <jalvesaq@gmail.com> |
4 " Last Change: 2006 Apr 30 | 4 " Former Maintainers: Vaidotas Zemlys <zemlys@gmail.com> |
5 " Filenames: *.R *.Rout *.r *.Rhistory *.Rt *.Rout.save *.Rout.fail | 5 " Tom Payne <tom@tompayne.org> |
6 " URL: http://uosis.mif.vu.lt/~zemlys/vim-syntax/r.vim | 6 " Last Change: Wed Sep 29, 2010 09:31AM |
7 " Filenames: *.R *.r *.Rhistory *.Rt | |
8 " | |
9 " NOTE: The highlighting of R functions is defined in the | |
10 " r-plugin/functions.vim, which is part of vim-r-plugin2: | |
11 " http://www.vim.org/scripts/script.php?script_id=2628 | |
12 " | |
13 " Some lines of code were borrowed from Zhuojun Chen. | |
7 | 14 |
8 " First maintainer Tom Payne <tom@tompayne.org> | 15 if exists("b:current_syntax") |
9 " Modified to make syntax less colourful and added the highlighting of | |
10 " R assignment arrow | |
11 | |
12 " For version 5.x: Clear all syntax items | |
13 " For version 6.x: Quit when a syntax file was already loaded | |
14 if version < 600 | |
15 syntax clear | |
16 elseif exists("b:current_syntax") | |
17 finish | 16 finish |
18 endif | 17 endif |
19 | 18 |
20 if version >= 600 | 19 setlocal iskeyword=@,48-57,_,. |
21 setlocal iskeyword=@,48-57,_,. | |
22 else | |
23 set iskeyword=@,48-57,_,. | |
24 endif | |
25 | 20 |
26 syn case match | 21 syn case match |
27 | 22 |
28 " Comment | 23 " Comment |
29 syn match rComment /\#.*/ | 24 syn match rComment contains=@Spell "\#.*" |
30 | 25 |
31 " Constant | |
32 " string enclosed in double quotes | 26 " string enclosed in double quotes |
33 syn region rString start=/"/ skip=/\\\\\|\\"/ end=/"/ | 27 syn region rString contains=rSpecial,rStrError,@Spell start=/"/ skip=/\\\\\|\\"/ end=/"/ |
34 " string enclosed in single quotes | 28 " string enclosed in single quotes |
35 syn region rString start=/'/ skip=/\\\\\|\\'/ end=/'/ | 29 syn region rString contains=rSpecial,rStrError,@Spell start=/'/ skip=/\\\\\|\\'/ end=/'/ |
36 " number with no fractional part or exponent | |
37 syn match rNumber /\d\+/ | |
38 " floating point number with integer and fractional parts and optional exponent | |
39 syn match rFloat /\d\+\.\d*\([Ee][-+]\=\d\+\)\=/ | |
40 " floating point number with no integer part and optional exponent | |
41 syn match rFloat /\.\d\+\([Ee][-+]\=\d\+\)\=/ | |
42 " floating point number with no fractional part and optional exponent | |
43 syn match rFloat /\d\+[Ee][-+]\=\d\+/ | |
44 | 30 |
45 " Identifier | 31 syn match rStrError display contained "\\." |
46 " identifier with leading letter and optional following keyword characters | 32 |
47 syn match rIdentifier /\a\k*/ | 33 " New line, carriage return, tab, backspace, bell, feed, vertical tab, backslash |
48 " identifier with leading period, one or more digits, and at least one non-digit keyword character | 34 syn match rSpecial display contained "\\\(n\|r\|t\|b\|a\|f\|v\|'\|\"\)\|\\\\" |
49 syn match rIdentifier /\.\d*\K\k*/ | 35 |
36 " Hexadecimal and Octal digits | |
37 syn match rSpecial display contained "\\\(x\x\{1,2}\|[0-8]\{1,3}\)" | |
38 | |
39 " Unicode characters | |
40 syn match rSpecial display contained "\\u\x\{1,4}" | |
41 syn match rSpecial display contained "\\U\x\{1,8}" | |
42 syn match rSpecial display contained "\\u{\x\{1,4}}" | |
43 syn match rSpecial display contained "\\U{\x\{1,8}}" | |
44 | |
45 | |
46 syn match rDollar "\$" | |
50 | 47 |
51 " Statement | 48 " Statement |
52 syn keyword rStatement break next return | 49 syn keyword rStatement break next return |
53 syn keyword rConditional if else | 50 syn keyword rConditional if else |
54 syn keyword rRepeat for in repeat while | 51 syn keyword rRepeat for in repeat while |
55 | 52 |
53 " Constant (not really) | |
54 syn keyword rConstant T F LETTERS letters month.ab month.name pi | |
55 syn keyword rConstant R.version.string | |
56 | |
56 " Constant | 57 " Constant |
57 syn keyword rConstant LETTERS letters month.ab month.name pi | |
58 syn keyword rConstant NULL | 58 syn keyword rConstant NULL |
59 syn keyword rBoolean FALSE TRUE | 59 syn keyword rBoolean FALSE TRUE |
60 syn keyword rNumber NA | 60 syn keyword rNumber NA NA_integer_ NA_real_ NA_complex_ NA_character_ |
61 syn match rArrow /<\{1,2}-/ | 61 syn keyword rNumber Inf NaN |
62 | 62 |
63 " Type | 63 " integer |
64 syn keyword rType array category character complex double function integer list logical matrix numeric vector data.frame | 64 syn match rInteger "\<\d\+L" |
65 syn match rInteger "\<0x\([0-9]\|[a-f]\|[A-F]\)\+L" | |
66 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 | |
77 " number with no fractional part or exponent | |
78 syn match rNumber "\<\d\+\>" | |
79 " hexadecimal number | |
80 syn match rNumber "\<0x\([0-9]\|[a-f]\|[A-F]\)\+" | |
81 | |
82 " floating point number with integer and fractional parts and optional exponent | |
83 syn match rFloat "\<\d\+\.\d*\([Ee][-+]\=\d\+\)\=" | |
84 " floating point number with no integer part and optional exponent | |
85 syn match rFloat "\<\.\d\+\([Ee][-+]\=\d\+\)\=" | |
86 " floating point number with no fractional part and optional exponent | |
87 syn match rFloat "\<\d\+[Ee][-+]\=\d\+" | |
88 | |
89 syn match rArrow "<\{1,2}-" | |
90 syn match rArrow "->\{1,2}" | |
65 | 91 |
66 " Special | 92 " Special |
67 syn match rDelimiter /[,;:]/ | 93 syn match rDelimiter "[,;:]" |
68 | 94 |
69 " Error | 95 " Error |
70 syn region rRegion matchgroup=Delimiter start=/(/ matchgroup=Delimiter end=/)/ transparent contains=ALLBUT,rError,rBraceError,rCurlyError | 96 syn region rRegion matchgroup=Delimiter start=/(/ matchgroup=Delimiter end=/)/ transparent contains=ALLBUT,rError,rBraceError,rCurlyError |
71 syn region rRegion matchgroup=Delimiter start=/{/ matchgroup=Delimiter end=/}/ transparent contains=ALLBUT,rError,rBraceError,rParenError | 97 syn region rRegion matchgroup=Delimiter start=/{/ matchgroup=Delimiter end=/}/ transparent contains=ALLBUT,rError,rBraceError,rParenError |
72 syn region rRegion matchgroup=Delimiter start=/\[/ matchgroup=Delimiter end=/]/ transparent contains=ALLBUT,rError,rCurlyError,rParenError | 98 syn region rRegion matchgroup=Delimiter start=/\[/ matchgroup=Delimiter end=/]/ transparent contains=ALLBUT,rError,rCurlyError,rParenError |
73 syn match rError /[)\]}]/ | 99 syn match rError "[)\]}]" |
74 syn match rBraceError /[)}]/ contained | 100 syn match rBraceError "[)}]" contained |
75 syn match rCurlyError /[)\]]/ contained | 101 syn match rCurlyError "[)\]]" contained |
76 syn match rParenError /[\]}]/ contained | 102 syn match rParenError "[\]}]" contained |
103 | |
104 " Functions that may add new objects | |
105 syn keyword rPreProc library require attach detach source | |
106 | |
107 " Type | |
108 syn keyword rType array category character complex double function integer list logical matrix numeric vector data.frame | |
77 | 109 |
78 " Define the default highlighting. | 110 " Define the default highlighting. |
79 " For version 5.7 and earlier: only when not done already | 111 hi def link rArrow Statement |
80 " For version 5.8 and later: only when an item doesn't have highlighting yet | 112 hi def link rBoolean Boolean |
81 if version >= 508 || !exists("did_r_syn_inits") | 113 hi def link rBraceError Error |
82 if version < 508 | 114 hi def link rComment Comment |
83 let did_r_syn_inits = 1 | 115 hi def link rComplex Number |
84 command -nargs=+ HiLink hi link <args> | 116 hi def link rConditional Conditional |
85 else | 117 hi def link rConstant Constant |
86 command -nargs=+ HiLink hi def link <args> | 118 hi def link rCurlyError Error |
87 endif | 119 hi def link rDelimiter Delimiter |
88 HiLink rComment Comment | 120 hi def link rDollar SpecialChar |
89 HiLink rConstant Constant | 121 hi def link rError Error |
90 HiLink rString String | 122 hi def link rFloat Float |
91 HiLink rNumber Number | 123 hi def link rInteger Number |
92 HiLink rBoolean Boolean | 124 hi def link rNumber Number |
93 HiLink rFloat Float | 125 hi def link rOperator Operator |
94 HiLink rStatement Statement | 126 hi def link rParenError Error |
95 HiLink rConditional Conditional | 127 hi def link rPreProc PreProc |
96 HiLink rRepeat Repeat | 128 hi def link rRepeat Repeat |
97 HiLink rIdentifier Normal | 129 hi def link rSpecial SpecialChar |
98 HiLink rArrow Statement | 130 hi def link rStatement Statement |
99 HiLink rType Type | 131 hi def link rString String |
100 HiLink rDelimiter Delimiter | 132 hi def link rStrError Error |
101 HiLink rError Error | 133 hi def link rType Type |
102 HiLink rBraceError Error | |
103 HiLink rCurlyError Error | |
104 HiLink rParenError Error | |
105 delcommand HiLink | |
106 endif | |
107 | 134 |
108 let b:current_syntax="r" | 135 let b:current_syntax="r" |
109 | 136 |
110 " vim: ts=8 sw=2 | 137 " vim: ts=8 sw=2 |
111 |