annotate runtime/syntax/r.vim @ 27:a01d8d9b2a58 first-working-version

first working version.
author kono
date Mon, 27 Oct 2008 18:28:11 +0900
parents 76efa0be13f1
children c16898406ff2
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1 " Vim syntax file
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
2 " Language: R (GNU S)
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
3 " Maintainer: Vaidotas Zemlys <zemlys@gmail.com>
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
4 " Last Change: 2006 Apr 30
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
5 " Filenames: *.R *.Rout *.r *.Rhistory *.Rt *.Rout.save *.Rout.fail
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
6 " URL: http://uosis.mif.vu.lt/~zemlys/vim-syntax/r.vim
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
7
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
8 " First maintainer Tom Payne <tom@tompayne.org>
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
9 " Modified to make syntax less colourful and added the highlighting of
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
10 " R assignment arrow
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
11
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
12 " For version 5.x: Clear all syntax items
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
13 " For version 6.x: Quit when a syntax file was already loaded
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
14 if version < 600
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
15 syntax clear
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
16 elseif exists("b:current_syntax")
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
17 finish
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
18 endif
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
19
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
20 if version >= 600
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
21 setlocal iskeyword=@,48-57,_,.
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
22 else
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
23 set iskeyword=@,48-57,_,.
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
24 endif
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
25
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
26 syn case match
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
27
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
28 " Comment
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
29 syn match rComment /\#.*/
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
30
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
31 " Constant
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
32 " string enclosed in double quotes
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
33 syn region rString start=/"/ skip=/\\\\\|\\"/ end=/"/
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
34 " string enclosed in single quotes
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
35 syn region rString start=/'/ skip=/\\\\\|\\'/ end=/'/
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
36 " number with no fractional part or exponent
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
37 syn match rNumber /\d\+/
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
38 " floating point number with integer and fractional parts and optional exponent
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
39 syn match rFloat /\d\+\.\d*\([Ee][-+]\=\d\+\)\=/
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
40 " floating point number with no integer part and optional exponent
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
41 syn match rFloat /\.\d\+\([Ee][-+]\=\d\+\)\=/
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
42 " floating point number with no fractional part and optional exponent
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
43 syn match rFloat /\d\+[Ee][-+]\=\d\+/
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
44
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
45 " Identifier
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
46 " identifier with leading letter and optional following keyword characters
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
47 syn match rIdentifier /\a\k*/
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
48 " identifier with leading period, one or more digits, and at least one non-digit keyword character
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
49 syn match rIdentifier /\.\d*\K\k*/
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
50
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
51 " Statement
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
52 syn keyword rStatement break next return
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
53 syn keyword rConditional if else
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
54 syn keyword rRepeat for in repeat while
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
55
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
56 " Constant
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
57 syn keyword rConstant LETTERS letters month.ab month.name pi
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
58 syn keyword rConstant NULL
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
59 syn keyword rBoolean FALSE TRUE
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
60 syn keyword rNumber NA
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
61 syn match rArrow /<\{1,2}-/
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
62
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
63 " Type
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
64 syn keyword rType array category character complex double function integer list logical matrix numeric vector data.frame
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
65
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
66 " Special
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
67 syn match rDelimiter /[,;:]/
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
68
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
69 " Error
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
70 syn region rRegion matchgroup=Delimiter start=/(/ matchgroup=Delimiter end=/)/ transparent contains=ALLBUT,rError,rBraceError,rCurlyError
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
71 syn region rRegion matchgroup=Delimiter start=/{/ matchgroup=Delimiter end=/}/ transparent contains=ALLBUT,rError,rBraceError,rParenError
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
72 syn region rRegion matchgroup=Delimiter start=/\[/ matchgroup=Delimiter end=/]/ transparent contains=ALLBUT,rError,rCurlyError,rParenError
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
73 syn match rError /[)\]}]/
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
74 syn match rBraceError /[)}]/ contained
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
75 syn match rCurlyError /[)\]]/ contained
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
76 syn match rParenError /[\]}]/ contained
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
77
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
78 " Define the default highlighting.
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
79 " For version 5.7 and earlier: only when not done already
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
80 " For version 5.8 and later: only when an item doesn't have highlighting yet
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
81 if version >= 508 || !exists("did_r_syn_inits")
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
82 if version < 508
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
83 let did_r_syn_inits = 1
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
84 command -nargs=+ HiLink hi link <args>
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
85 else
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
86 command -nargs=+ HiLink hi def link <args>
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
87 endif
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
88 HiLink rComment Comment
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
89 HiLink rConstant Constant
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
90 HiLink rString String
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
91 HiLink rNumber Number
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
92 HiLink rBoolean Boolean
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
93 HiLink rFloat Float
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
94 HiLink rStatement Statement
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
95 HiLink rConditional Conditional
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
96 HiLink rRepeat Repeat
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
97 HiLink rIdentifier Normal
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
98 HiLink rArrow Statement
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
99 HiLink rType Type
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
100 HiLink rDelimiter Delimiter
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
101 HiLink rError Error
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
102 HiLink rBraceError Error
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
103 HiLink rCurlyError Error
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
104 HiLink rParenError Error
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
105 delcommand HiLink
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
106 endif
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
107
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
108 let b:current_syntax="r"
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
109
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
110 " vim: ts=8 sw=2
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
111