Add support for :winpos
[MacVim.git] / runtime / syntax / r.vim
blobf3e730ef92cdc3ba9a91a31f0abefada5b1ce19e
1 " Vim syntax file
2 " Language:     R (GNU S)
3 " Maintainer:   Vaidotas Zemlys <zemlys@gmail.com>
4 " Last Change:  2006 Apr 30
5 " Filenames:    *.R *.Rout *.r *.Rhistory *.Rt *.Rout.save *.Rout.fail
6 " URL:          http://uosis.mif.vu.lt/~zemlys/vim-syntax/r.vim
8 " First maintainer Tom Payne <tom@tompayne.org>
9 " Modified to make syntax less colourful and added the highlighting of
10 " R assignment arrow
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
18 endif
20 if version >= 600
21   setlocal iskeyword=@,48-57,_,.
22 else
23   set iskeyword=@,48-57,_,.
24 endif
26 syn case match
28 " Comment
29 syn match rComment /\#.*/
31 " Constant
32 " string enclosed in double quotes
33 syn region rString start=/"/ skip=/\\\\\|\\"/ end=/"/
34 " string enclosed in single quotes
35 syn region rString 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\+/
45 " Identifier
46 " identifier with leading letter and optional following keyword characters
47 syn match rIdentifier /\a\k*/
48 " identifier with leading period, one or more digits, and at least one non-digit keyword character
49 syn match rIdentifier /\.\d*\K\k*/
51 " Statement
52 syn keyword rStatement   break next return
53 syn keyword rConditional if else
54 syn keyword rRepeat      for in repeat while
56 " Constant
57 syn keyword rConstant LETTERS letters month.ab month.name pi
58 syn keyword rConstant NULL
59 syn keyword rBoolean  FALSE TRUE
60 syn keyword rNumber   NA
61 syn match rArrow /<\{1,2}-/
63 " Type
64 syn keyword rType array category character complex double function integer list logical matrix numeric vector data.frame 
66 " Special
67 syn match rDelimiter /[,;:]/
69 " Error
70 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
72 syn region rRegion matchgroup=Delimiter start=/\[/ matchgroup=Delimiter end=/]/ transparent contains=ALLBUT,rError,rCurlyError,rParenError
73 syn match rError      /[)\]}]/
74 syn match rBraceError /[)}]/ contained
75 syn match rCurlyError /[)\]]/ contained
76 syn match rParenError /[\]}]/ contained
78 " Define the default highlighting.
79 " For version 5.7 and earlier: only when not done already
80 " For version 5.8 and later: only when an item doesn't have highlighting yet
81 if version >= 508 || !exists("did_r_syn_inits")
82   if version < 508
83     let did_r_syn_inits = 1
84     command -nargs=+ HiLink hi link <args>
85   else
86     command -nargs=+ HiLink hi def link <args>
87   endif
88   HiLink rComment     Comment
89   HiLink rConstant    Constant
90   HiLink rString      String
91   HiLink rNumber      Number
92   HiLink rBoolean     Boolean
93   HiLink rFloat       Float
94   HiLink rStatement   Statement
95   HiLink rConditional Conditional
96   HiLink rRepeat      Repeat
97   HiLink rIdentifier  Normal
98   HiLink rArrow       Statement 
99   HiLink rType        Type
100   HiLink rDelimiter   Delimiter
101   HiLink rError       Error
102   HiLink rBraceError  Error
103   HiLink rCurlyError  Error
104   HiLink rParenError  Error
105   delcommand HiLink
106 endif
108 let b:current_syntax="r"
110 " vim: ts=8 sw=2