Install vim73
[git/jnareb-git.git] / share / vim / vim73 / syntax / rhelp.vim
blob98e5bc0c684de7a1b469fa339d796c54b544c56f
1 " Vim syntax file
2 " Language:    R Help File
3 " Maintainer:  Johannes Ranke <jranke@uni-bremen.de>
4 " Last Change: 2010 Apr 22
5 " Version:     0.7.3
6 " SVN:             $Id: rhelp.vim 88 2010-04-22 19:37:09Z ranke $
7 " Remarks:     - Now includes R syntax highlighting in the appropriate
8 "                sections if an r.vim file is in the same directory or in the
9 "                default debian location.
10 "              - There is no Latex markup in equations
11 "              - Thanks to Will Gray for finding and fixing a bug
12 "              - No support for \if, \ifelse and \out as I don't understand
13 "                them and have no examples at hand (help welcome).
14 "              - No support for \var tag within quoted string (dito)
16 " Version Clears: {{{1
17 " For version 5.x: Clear all syntax items
18 " For version 6.x and 7.x: Quit when a syntax file was already loaded
19 if version < 600 
20   syntax clear
21 elseif exists("b:current_syntax")
22   finish
23 endif 
25 syn case match
27 " R help identifiers {{{
28 syn region rhelpIdentifier matchgroup=rhelpSection      start="\\name{" end="}" 
29 syn region rhelpIdentifier matchgroup=rhelpSection      start="\\alias{" end="}" 
30 syn region rhelpIdentifier matchgroup=rhelpSection      start="\\pkg{" end="}" 
31 syn region rhelpIdentifier matchgroup=rhelpSection      start="\\item{" end="}" contained contains=rhelpDots
32 syn region rhelpIdentifier matchgroup=rhelpSection start="\\method{" end=/}/ contained
34 " Highlighting of R code using an existing r.vim syntax file if available {{{1
35 syn include @R syntax/r.vim
36 syn match rhelpDots             "\\dots" containedin=@R
37 syn region rhelpRcode matchgroup=Delimiter start="\\examples{" matchgroup=Delimiter transparent end=/}/ contains=@R,rhelpSection
38 syn region rhelpRcode matchgroup=Delimiter start="\\usage{" matchgroup=Delimiter transparent end=/}/ contains=@R,rhelpIdentifier,rhelpS4method
39 syn region rhelpRcode matchgroup=Delimiter start="\\synopsis{" matchgroup=Delimiter transparent end=/}/ contains=@R
40 syn region rhelpRcode matchgroup=Delimiter start="\\special{" matchgroup=Delimiter transparent end=/}/ contains=@R contained
41 syn region rhelpRcode matchgroup=Delimiter start="\\code{" matchgroup=Delimiter transparent end=/}/ contains=@R,rhelpLink contained
42 syn region rhelpS4method matchgroup=Delimiter start="\\S4method{.*}(" matchgroup=Delimiter transparent end=/)/ contains=@R,rhelpDots contained
43 syn region rhelpSexpr matchgroup=Delimiter start="\\Sexpr{" matchgroup=Delimiter transparent end=/}/ contains=@R
45 " Strings {{{1
46 syn region rhelpString start=/"/ end=/"/ 
48 " Special characters  ( \$ \& \% \# \{ \} \_) {{{1
49 syn match rhelpSpecialChar        "\\[$&%#{}_]"
51 " Special Delimiters {{{1
52 syn match rhelpDelimiter                "\\cr"
53 syn match rhelpDelimiter                "\\tab "
55 " Keywords {{{1
56 syn match rhelpKeyword  "\\R"
57 syn match rhelpKeyword  "\\ldots"
58 syn match rhelpKeyword  "--"
59 syn match rhelpKeyword  "---"
60 syn match rhelpKeyword  "<"
61 syn match rhelpKeyword  ">"
62 syn match rhelpKeyword  "\\ge"
63 syn match rhelpKeyword  "\\le"
64 syn match rhelpKeyword  "\\alpha"
65 syn match rhelpKeyword  "\\beta"
66 syn match rhelpKeyword  "\\gamma"
67 syn match rhelpKeyword  "\\delta"
68 syn match rhelpKeyword  "\\epsilon"
69 syn match rhelpKeyword  "\\zeta"
70 syn match rhelpKeyword  "\\eta"
71 syn match rhelpKeyword  "\\theta"
72 syn match rhelpKeyword  "\\iota"
73 syn match rhelpKeyword  "\\kappa"
74 syn match rhelpKeyword  "\\lambda"
75 syn match rhelpKeyword  "\\mu"
76 syn match rhelpKeyword  "\\nu"
77 syn match rhelpKeyword  "\\xi"
78 syn match rhelpKeyword  "\\omicron"
79 syn match rhelpKeyword  "\\pi"
80 syn match rhelpKeyword  "\\rho"
81 syn match rhelpKeyword  "\\sigma"
82 syn match rhelpKeyword  "\\tau"
83 syn match rhelpKeyword  "\\upsilon"
84 syn match rhelpKeyword  "\\phi"
85 syn match rhelpKeyword  "\\chi"
86 syn match rhelpKeyword  "\\psi"
87 syn match rhelpKeyword  "\\omega"
88 syn match rhelpKeyword  "\\Alpha"
89 syn match rhelpKeyword  "\\Beta"
90 syn match rhelpKeyword  "\\Gamma"
91 syn match rhelpKeyword  "\\Delta"
92 syn match rhelpKeyword  "\\Epsilon"
93 syn match rhelpKeyword  "\\Zeta"
94 syn match rhelpKeyword  "\\Eta"
95 syn match rhelpKeyword  "\\Theta"
96 syn match rhelpKeyword  "\\Iota"
97 syn match rhelpKeyword  "\\Kappa"
98 syn match rhelpKeyword  "\\Lambda"
99 syn match rhelpKeyword  "\\Mu"
100 syn match rhelpKeyword  "\\Nu"
101 syn match rhelpKeyword  "\\Xi"
102 syn match rhelpKeyword  "\\Omicron"
103 syn match rhelpKeyword  "\\Pi"
104 syn match rhelpKeyword  "\\Rho"
105 syn match rhelpKeyword  "\\Sigma"
106 syn match rhelpKeyword  "\\Tau"
107 syn match rhelpKeyword  "\\Upsilon"
108 syn match rhelpKeyword  "\\Phi"
109 syn match rhelpKeyword  "\\Chi"
110 syn match rhelpKeyword  "\\Psi"
111 syn match rhelpKeyword  "\\Omega"
113 " Links {{{1
114 syn region rhelpLink matchgroup=rhelpSection start="\\link{" end="}" contained keepend
115 syn region rhelpLink matchgroup=rhelpSection start="\\link\[.\{-}\]{" end="}" contained keepend
116 syn region rhelpLink matchgroup=rhelpSection start="\\linkS4class{" end="}" contained keepend
118 " Type Styles {{{1
119 syn match rhelpType             "\\emph\>"
120 syn match rhelpType             "\\strong\>"
121 syn match rhelpType             "\\bold\>"
122 syn match rhelpType             "\\sQuote\>"
123 syn match rhelpType             "\\dQuote\>"
124 syn match rhelpType             "\\preformatted\>"
125 syn match rhelpType             "\\kbd\>"
126 syn match rhelpType             "\\samp\>"
127 syn match rhelpType             "\\eqn\>"
128 syn match rhelpType             "\\deqn\>"
129 syn match rhelpType             "\\file\>"
130 syn match rhelpType             "\\email\>"
131 syn match rhelpType             "\\url\>"
132 syn match rhelpType             "\\var\>"
133 syn match rhelpType             "\\env\>"
134 syn match rhelpType             "\\option\>"
135 syn match rhelpType             "\\command\>"
136 syn match rhelpType             "\\dfn\>"
137 syn match rhelpType             "\\cite\>"
138 syn match rhelpType             "\\acronym\>"
140 " rhelp sections {{{1
141 syn match rhelpSection          "\\encoding\>"
142 syn match rhelpSection          "\\title\>"
143 syn match rhelpSection          "\\description\>"
144 syn match rhelpSection          "\\concept\>"
145 syn match rhelpSection          "\\arguments\>"
146 syn match rhelpSection          "\\details\>"
147 syn match rhelpSection          "\\value\>"
148 syn match rhelpSection          "\\references\>"
149 syn match rhelpSection          "\\note\>"
150 syn match rhelpSection          "\\author\>"
151 syn match rhelpSection          "\\seealso\>"
152 syn match rhelpSection          "\\keyword\>"
153 syn match rhelpSection          "\\docType\>"
154 syn match rhelpSection          "\\format\>"
155 syn match rhelpSection          "\\source\>"
156 syn match rhelpSection     "\\itemize\>"
157 syn match rhelpSection     "\\describe\>"
158 syn match rhelpSection     "\\enumerate\>"
159 syn match rhelpSection     "\\item "
160 syn match rhelpSection     "\\item$"
161 syn match rhelpSection          "\\tabular{[lcr]*}"
162 syn match rhelpSection          "\\dontrun\>"
163 syn match rhelpSection          "\\dontshow\>"
164 syn match rhelpSection          "\\testonly\>"
165 syn match rhelpSection          "\\donttest\>"
167 " Freely named Sections {{{1
168 syn region rhelpFreesec matchgroup=Delimiter start="\\section{" matchgroup=Delimiter transparent end=/}/ 
169 syn region rhelpFreesubsec matchgroup=Delimiter start="\\subsection{" matchgroup=Delimiter transparent end=/}/ 
171 " R help file comments {{{1
172 syn match rhelpComment /%.*$/ contained 
174 " Error {{{1
175 syn region rhelpRegion matchgroup=Delimiter start=/(/ matchgroup=Delimiter end=/)/ transparent contains=ALLBUT,rhelpError,rhelpBraceError,rhelpCurlyError
176 syn region rhelpRegion matchgroup=Delimiter start=/{/ matchgroup=Delimiter end=/}/ transparent contains=ALLBUT,rhelpError,rhelpBraceError,rhelpParenError
177 syn region rhelpRegion matchgroup=Delimiter start=/\[/ matchgroup=Delimiter end=/]/ transparent contains=ALLBUT,rhelpError,rhelpCurlyError,rhelpParenError
178 syn match rhelpError      /[)\]}]/
179 syn match rhelpBraceError /[)}]/ contained
180 syn match rhelpCurlyError /[)\]]/ contained
181 syn match rhelpParenError /[\]}]/ contained
183 " Define the default highlighting {{{1
184 " For version 5.7 and earlier: only when not done already
185 " For version 5.8 and later: only when an item doesn't have highlighting yet
186 if version >= 508 || !exists("did_rhelp_syntax_inits")
187   if version < 508
188     let did_rhelp_syntax_inits = 1
189     command -nargs=+ HiLink hi link <args>
190   else
191     command -nargs=+ HiLink hi def link <args>
192   endif
193   HiLink rhelpIdentifier  Identifier
194   HiLink rhelpString      String
195   HiLink rhelpKeyword     Keyword
196   HiLink rhelpDots        Keyword
197   HiLink rhelpLink        Underlined
198   HiLink rhelpType            Type
199   HiLink rhelpSection     PreCondit
200   HiLink rhelpError       Error
201   HiLink rhelpBraceError  Error
202   HiLink rhelpCurlyError  Error
203   HiLink rhelpParenError  Error
204   HiLink rhelpDelimiter   Delimiter
205   HiLink rhelpComment     Comment
206   HiLink rhelpRComment    Comment
207   HiLink rhelpSpecialChar SpecialChar
208   delcommand HiLink
209 endif 
211 let   b:current_syntax = "rhelp"
212 " vim: foldmethod=marker: