blob: 7550b1293e73c666df671b47ff8c409ab72c09eb [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 Moolenaar81af9252010-12-10 20:35:50 +01004" Last Change: 2010 Nov 22
5" Version: 0.7.4
6" SVN: $Id: rhelp.vim 90 2010-11-22 10:58:11Z ranke $
7" Remarks: - Includes R syntax highlighting in the appropriate
Bram Moolenaar362e1a32006-03-06 23:29:24 +00008" 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 Moolenaar81af9252010-12-10 20:35:50 +010031syn region rhelpIdentifier matchgroup=rhelpSection start="\\method{" end="}" contained
32syn region rhelpIdentifier matchgroup=rhelpSection start="\\Rdversion{" end="}"
Bram Moolenaar362e1a32006-03-06 23:29:24 +000033
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 Moolenaar81af9252010-12-10 20:35:50 +010037syn region rhelpRcode matchgroup=Delimiter start="\\examples{" matchgroup=Delimiter transparent end="}" contains=@R,rhelpSection
38syn region rhelpRcode matchgroup=Delimiter start="\\usage{" matchgroup=Delimiter transparent end="}" contains=@R,rhelpIdentifier,rhelpS4method
39syn 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
41syn region rhelpRcode matchgroup=Delimiter start="\\code{" matchgroup=Delimiter transparent end="}" contains=@R,rhelpLink contained
42syn region rhelpS4method matchgroup=Delimiter start="\\S4method{.*}(" matchgroup=Delimiter transparent end=")" contains=@R,rhelpDots contained
43syn 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
Bram Moolenaar81af9252010-12-10 20:35:50 +010056syn match rhelpKeyword "\\R" contained
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\>"
Bram Moolenaar81af9252010-12-10 20:35:50 +0100132syn match rhelpType "\\href\>"
Bram Moolenaar362e1a32006-03-06 23:29:24 +0000133syn match rhelpType "\\var\>"
134syn match rhelpType "\\env\>"
135syn match rhelpType "\\option\>"
136syn match rhelpType "\\command\>"
Bram Moolenaar81af9252010-12-10 20:35:50 +0100137syn match rhelpType "\\newcommand\>"
138syn match rhelpType "\\renewcommand\>"
Bram Moolenaar362e1a32006-03-06 23:29:24 +0000139syn match rhelpType "\\dfn\>"
140syn match rhelpType "\\cite\>"
141syn match rhelpType "\\acronym\>"
142
143" rhelp sections {{{1
144syn match rhelpSection "\\encoding\>"
145syn match rhelpSection "\\title\>"
Bram Moolenaar81af9252010-12-10 20:35:50 +0100146syn match rhelpSection "\\item\>"
Bram Moolenaar362e1a32006-03-06 23:29:24 +0000147syn match rhelpSection "\\description\>"
148syn match rhelpSection "\\concept\>"
149syn match rhelpSection "\\arguments\>"
150syn match rhelpSection "\\details\>"
151syn match rhelpSection "\\value\>"
152syn match rhelpSection "\\references\>"
153syn match rhelpSection "\\note\>"
154syn match rhelpSection "\\author\>"
155syn match rhelpSection "\\seealso\>"
156syn match rhelpSection "\\keyword\>"
157syn match rhelpSection "\\docType\>"
158syn match rhelpSection "\\format\>"
159syn match rhelpSection "\\source\>"
Bram Moolenaar81af9252010-12-10 20:35:50 +0100160syn match rhelpSection "\\itemize\>"
161syn match rhelpSection "\\describe\>"
162syn match rhelpSection "\\enumerate\>"
163syn match rhelpSection "\\item "
164syn match rhelpSection "\\item$"
Bram Moolenaar362e1a32006-03-06 23:29:24 +0000165syn match rhelpSection "\\tabular{[lcr]*}"
166syn match rhelpSection "\\dontrun\>"
167syn match rhelpSection "\\dontshow\>"
168syn match rhelpSection "\\testonly\>"
Bram Moolenaar446cb832008-06-24 21:56:24 +0000169syn match rhelpSection "\\donttest\>"
Bram Moolenaar362e1a32006-03-06 23:29:24 +0000170
171" Freely named Sections {{{1
Bram Moolenaar81af9252010-12-10 20:35:50 +0100172syn region rhelpFreesec matchgroup=Delimiter start="\\section{" matchgroup=Delimiter transparent end="}"
173syn region rhelpFreesubsec matchgroup=Delimiter start="\\subsection{" matchgroup=Delimiter transparent end="}"
Bram Moolenaar362e1a32006-03-06 23:29:24 +0000174
Bram Moolenaarf9393ef2006-04-24 19:47:27 +0000175" R help file comments {{{1
Bram Moolenaar81af9252010-12-10 20:35:50 +0100176syn match rhelpComment /%.*$/
Bram Moolenaar362e1a32006-03-06 23:29:24 +0000177
178" Error {{{1
179syn region rhelpRegion matchgroup=Delimiter start=/(/ matchgroup=Delimiter end=/)/ transparent contains=ALLBUT,rhelpError,rhelpBraceError,rhelpCurlyError
180syn region rhelpRegion matchgroup=Delimiter start=/{/ matchgroup=Delimiter end=/}/ transparent contains=ALLBUT,rhelpError,rhelpBraceError,rhelpParenError
181syn region rhelpRegion matchgroup=Delimiter start=/\[/ matchgroup=Delimiter end=/]/ transparent contains=ALLBUT,rhelpError,rhelpCurlyError,rhelpParenError
182syn match rhelpError /[)\]}]/
183syn match rhelpBraceError /[)}]/ contained
184syn match rhelpCurlyError /[)\]]/ contained
185syn match rhelpParenError /[\]}]/ contained
186
187" Define the default highlighting {{{1
188" For version 5.7 and earlier: only when not done already
189" For version 5.8 and later: only when an item doesn't have highlighting yet
190if version >= 508 || !exists("did_rhelp_syntax_inits")
191 if version < 508
192 let did_rhelp_syntax_inits = 1
193 command -nargs=+ HiLink hi link <args>
194 else
195 command -nargs=+ HiLink hi def link <args>
196 endif
197 HiLink rhelpIdentifier Identifier
198 HiLink rhelpString String
199 HiLink rhelpKeyword Keyword
Bram Moolenaarf9393ef2006-04-24 19:47:27 +0000200 HiLink rhelpDots Keyword
Bram Moolenaar362e1a32006-03-06 23:29:24 +0000201 HiLink rhelpLink Underlined
Bram Moolenaarf9393ef2006-04-24 19:47:27 +0000202 HiLink rhelpType Type
Bram Moolenaar362e1a32006-03-06 23:29:24 +0000203 HiLink rhelpSection PreCondit
204 HiLink rhelpError Error
205 HiLink rhelpBraceError Error
206 HiLink rhelpCurlyError Error
207 HiLink rhelpParenError Error
208 HiLink rhelpDelimiter Delimiter
209 HiLink rhelpComment Comment
210 HiLink rhelpRComment Comment
211 HiLink rhelpSpecialChar SpecialChar
212 delcommand HiLink
213endif
214
215let b:current_syntax = "rhelp"
216" vim: foldmethod=marker: