blob: 98e5bc0c684de7a1b469fa339d796c54b544c56f [file] [log] [blame]
Bram Moolenaar362e1a32006-03-06 23:29:24 +00001" Vim syntax file
2" Language: R Help File
3" Maintainer: Johannes Ranke <jranke@uni-bremen.de>
Bram Moolenaar00a927d2010-05-14 23:24:24 +02004" Last Change: 2010 Apr 22
5" Version: 0.7.3
6" SVN: $Id: rhelp.vim 88 2010-04-22 19:37:09Z ranke $
Bram Moolenaar362e1a32006-03-06 23:29:24 +00007" 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.
Bram Moolenaar362e1a32006-03-06 23:29:24 +000010" - There is no Latex markup in equations
Bram Moolenaar5c736222010-01-06 20:54:52 +010011" - Thanks to Will Gray for finding and fixing a bug
Bram Moolenaar00a927d2010-05-14 23:24:24 +020012" - 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)
Bram Moolenaar362e1a32006-03-06 23:29:24 +000015
16" Version Clears: {{{1
17" For version 5.x: Clear all syntax items
Bram Moolenaar910f66f2006-04-05 20:41:53 +000018" For version 6.x and 7.x: Quit when a syntax file was already loaded
Bram Moolenaar362e1a32006-03-06 23:29:24 +000019if version < 600
20 syntax clear
21elseif exists("b:current_syntax")
22 finish
23endif
24
25syn case match
26
Bram Moolenaarf9393ef2006-04-24 19:47:27 +000027" R help identifiers {{{
Bram Moolenaar362e1a32006-03-06 23:29:24 +000028syn region rhelpIdentifier matchgroup=rhelpSection start="\\name{" end="}"
29syn region rhelpIdentifier matchgroup=rhelpSection start="\\alias{" end="}"
30syn region rhelpIdentifier matchgroup=rhelpSection start="\\pkg{" end="}"
Bram Moolenaarf9393ef2006-04-24 19:47:27 +000031syn region rhelpIdentifier matchgroup=rhelpSection start="\\item{" end="}" contained contains=rhelpDots
Bram Moolenaar362e1a32006-03-06 23:29:24 +000032syn region rhelpIdentifier matchgroup=rhelpSection start="\\method{" end=/}/ contained
33
34" Highlighting of R code using an existing r.vim syntax file if available {{{1
Bram Moolenaar18144c82006-04-12 21:52:12 +000035syn include @R syntax/r.vim
Bram Moolenaarf9393ef2006-04-24 19:47:27 +000036syn match rhelpDots "\\dots" containedin=@R
Bram Moolenaar362e1a32006-03-06 23:29:24 +000037syn region rhelpRcode matchgroup=Delimiter start="\\examples{" matchgroup=Delimiter transparent end=/}/ contains=@R,rhelpSection
Bram Moolenaarf9393ef2006-04-24 19:47:27 +000038syn region rhelpRcode matchgroup=Delimiter start="\\usage{" matchgroup=Delimiter transparent end=/}/ contains=@R,rhelpIdentifier,rhelpS4method
Bram Moolenaar362e1a32006-03-06 23:29:24 +000039syn region rhelpRcode matchgroup=Delimiter start="\\synopsis{" matchgroup=Delimiter transparent end=/}/ contains=@R
40syn region rhelpRcode matchgroup=Delimiter start="\\special{" matchgroup=Delimiter transparent end=/}/ contains=@R contained
Bram Moolenaar910f66f2006-04-05 20:41:53 +000041syn region rhelpRcode matchgroup=Delimiter start="\\code{" matchgroup=Delimiter transparent end=/}/ contains=@R,rhelpLink contained
Bram Moolenaarf9393ef2006-04-24 19:47:27 +000042syn region rhelpS4method matchgroup=Delimiter start="\\S4method{.*}(" matchgroup=Delimiter transparent end=/)/ contains=@R,rhelpDots contained
Bram Moolenaar00a927d2010-05-14 23:24:24 +020043syn region rhelpSexpr matchgroup=Delimiter start="\\Sexpr{" matchgroup=Delimiter transparent end=/}/ contains=@R
Bram Moolenaar362e1a32006-03-06 23:29:24 +000044
45" Strings {{{1
46syn region rhelpString start=/"/ end=/"/
47
Bram Moolenaar910f66f2006-04-05 20:41:53 +000048" Special characters ( \$ \& \% \# \{ \} \_) {{{1
Bram Moolenaar362e1a32006-03-06 23:29:24 +000049syn match rhelpSpecialChar "\\[$&%#{}_]"
50
51" Special Delimiters {{{1
52syn match rhelpDelimiter "\\cr"
53syn match rhelpDelimiter "\\tab "
54
55" Keywords {{{1
56syn match rhelpKeyword "\\R"
Bram Moolenaar362e1a32006-03-06 23:29:24 +000057syn match rhelpKeyword "\\ldots"
Bram Moolenaarf9393ef2006-04-24 19:47:27 +000058syn match rhelpKeyword "--"
59syn match rhelpKeyword "---"
60syn match rhelpKeyword "<"
61syn match rhelpKeyword ">"
Bram Moolenaar00a927d2010-05-14 23:24:24 +020062syn match rhelpKeyword "\\ge"
63syn match rhelpKeyword "\\le"
64syn match rhelpKeyword "\\alpha"
65syn match rhelpKeyword "\\beta"
66syn match rhelpKeyword "\\gamma"
67syn match rhelpKeyword "\\delta"
68syn match rhelpKeyword "\\epsilon"
69syn match rhelpKeyword "\\zeta"
70syn match rhelpKeyword "\\eta"
71syn match rhelpKeyword "\\theta"
72syn match rhelpKeyword "\\iota"
73syn match rhelpKeyword "\\kappa"
74syn match rhelpKeyword "\\lambda"
75syn match rhelpKeyword "\\mu"
76syn match rhelpKeyword "\\nu"
77syn match rhelpKeyword "\\xi"
78syn match rhelpKeyword "\\omicron"
79syn match rhelpKeyword "\\pi"
80syn match rhelpKeyword "\\rho"
81syn match rhelpKeyword "\\sigma"
82syn match rhelpKeyword "\\tau"
83syn match rhelpKeyword "\\upsilon"
84syn match rhelpKeyword "\\phi"
85syn match rhelpKeyword "\\chi"
86syn match rhelpKeyword "\\psi"
87syn match rhelpKeyword "\\omega"
88syn match rhelpKeyword "\\Alpha"
89syn match rhelpKeyword "\\Beta"
90syn match rhelpKeyword "\\Gamma"
91syn match rhelpKeyword "\\Delta"
92syn match rhelpKeyword "\\Epsilon"
93syn match rhelpKeyword "\\Zeta"
94syn match rhelpKeyword "\\Eta"
95syn match rhelpKeyword "\\Theta"
96syn match rhelpKeyword "\\Iota"
97syn match rhelpKeyword "\\Kappa"
98syn match rhelpKeyword "\\Lambda"
99syn match rhelpKeyword "\\Mu"
100syn match rhelpKeyword "\\Nu"
101syn match rhelpKeyword "\\Xi"
102syn match rhelpKeyword "\\Omicron"
103syn match rhelpKeyword "\\Pi"
104syn match rhelpKeyword "\\Rho"
105syn match rhelpKeyword "\\Sigma"
106syn match rhelpKeyword "\\Tau"
107syn match rhelpKeyword "\\Upsilon"
108syn match rhelpKeyword "\\Phi"
109syn match rhelpKeyword "\\Chi"
110syn match rhelpKeyword "\\Psi"
111syn match rhelpKeyword "\\Omega"
Bram Moolenaar362e1a32006-03-06 23:29:24 +0000112
113" Links {{{1
114syn region rhelpLink matchgroup=rhelpSection start="\\link{" end="}" contained keepend
Bram Moolenaar5c736222010-01-06 20:54:52 +0100115syn region rhelpLink matchgroup=rhelpSection start="\\link\[.\{-}\]{" end="}" contained keepend
Bram Moolenaarf9393ef2006-04-24 19:47:27 +0000116syn region rhelpLink matchgroup=rhelpSection start="\\linkS4class{" end="}" contained keepend
Bram Moolenaar362e1a32006-03-06 23:29:24 +0000117
118" Type Styles {{{1
119syn match rhelpType "\\emph\>"
120syn match rhelpType "\\strong\>"
121syn match rhelpType "\\bold\>"
122syn match rhelpType "\\sQuote\>"
123syn match rhelpType "\\dQuote\>"
124syn match rhelpType "\\preformatted\>"
125syn match rhelpType "\\kbd\>"
126syn match rhelpType "\\samp\>"
127syn match rhelpType "\\eqn\>"
128syn match rhelpType "\\deqn\>"
129syn match rhelpType "\\file\>"
130syn match rhelpType "\\email\>"
131syn match rhelpType "\\url\>"
132syn match rhelpType "\\var\>"
133syn match rhelpType "\\env\>"
134syn match rhelpType "\\option\>"
135syn match rhelpType "\\command\>"
136syn match rhelpType "\\dfn\>"
137syn match rhelpType "\\cite\>"
138syn match rhelpType "\\acronym\>"
139
140" rhelp sections {{{1
141syn match rhelpSection "\\encoding\>"
142syn match rhelpSection "\\title\>"
143syn match rhelpSection "\\description\>"
144syn match rhelpSection "\\concept\>"
145syn match rhelpSection "\\arguments\>"
146syn match rhelpSection "\\details\>"
147syn match rhelpSection "\\value\>"
148syn match rhelpSection "\\references\>"
149syn match rhelpSection "\\note\>"
150syn match rhelpSection "\\author\>"
151syn match rhelpSection "\\seealso\>"
152syn match rhelpSection "\\keyword\>"
153syn match rhelpSection "\\docType\>"
154syn match rhelpSection "\\format\>"
155syn match rhelpSection "\\source\>"
156syn match rhelpSection "\\itemize\>"
157syn match rhelpSection "\\describe\>"
158syn match rhelpSection "\\enumerate\>"
159syn match rhelpSection "\\item "
160syn match rhelpSection "\\item$"
161syn match rhelpSection "\\tabular{[lcr]*}"
162syn match rhelpSection "\\dontrun\>"
163syn match rhelpSection "\\dontshow\>"
164syn match rhelpSection "\\testonly\>"
Bram Moolenaar446cb832008-06-24 21:56:24 +0000165syn match rhelpSection "\\donttest\>"
Bram Moolenaar362e1a32006-03-06 23:29:24 +0000166
167" Freely named Sections {{{1
168syn region rhelpFreesec matchgroup=Delimiter start="\\section{" matchgroup=Delimiter transparent end=/}/
Bram Moolenaar00a927d2010-05-14 23:24:24 +0200169syn region rhelpFreesubsec matchgroup=Delimiter start="\\subsection{" matchgroup=Delimiter transparent end=/}/
Bram Moolenaar362e1a32006-03-06 23:29:24 +0000170
Bram Moolenaarf9393ef2006-04-24 19:47:27 +0000171" R help file comments {{{1
Bram Moolenaar362e1a32006-03-06 23:29:24 +0000172syn match rhelpComment /%.*$/ contained
173
174" Error {{{1
175syn region rhelpRegion matchgroup=Delimiter start=/(/ matchgroup=Delimiter end=/)/ transparent contains=ALLBUT,rhelpError,rhelpBraceError,rhelpCurlyError
176syn region rhelpRegion matchgroup=Delimiter start=/{/ matchgroup=Delimiter end=/}/ transparent contains=ALLBUT,rhelpError,rhelpBraceError,rhelpParenError
177syn region rhelpRegion matchgroup=Delimiter start=/\[/ matchgroup=Delimiter end=/]/ transparent contains=ALLBUT,rhelpError,rhelpCurlyError,rhelpParenError
178syn match rhelpError /[)\]}]/
179syn match rhelpBraceError /[)}]/ contained
180syn match rhelpCurlyError /[)\]]/ contained
181syn match rhelpParenError /[\]}]/ contained
182
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
186if 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
Bram Moolenaarf9393ef2006-04-24 19:47:27 +0000196 HiLink rhelpDots Keyword
Bram Moolenaar362e1a32006-03-06 23:29:24 +0000197 HiLink rhelpLink Underlined
Bram Moolenaarf9393ef2006-04-24 19:47:27 +0000198 HiLink rhelpType Type
Bram Moolenaar362e1a32006-03-06 23:29:24 +0000199 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
209endif
210
211let b:current_syntax = "rhelp"
212" vim: foldmethod=marker: