blob: 0c07861d946ee5e151589fbd97ea96c5a469c9f5 [file] [log] [blame]
Bram Moolenaar362e1a32006-03-06 23:29:24 +00001" Vim syntax file
2" Language: R Help File
Bram Moolenaar662db672011-03-22 14:05:35 +01003" Maintainer: Jakson Aquino <jalvesaq@gmail.com>
4" Former Maintainer: Johannes Ranke <jranke@uni-bremen.de>
Bram Moolenaar15146672011-10-20 22:22:38 +02005" Last Change: Fri Oct 14, 2011 09:54PM
Bram Moolenaar81af9252010-12-10 20:35:50 +01006" Version: 0.7.4
7" SVN: $Id: rhelp.vim 90 2010-11-22 10:58:11Z ranke $
8" Remarks: - Includes R syntax highlighting in the appropriate
Bram Moolenaar362e1a32006-03-06 23:29:24 +00009" sections if an r.vim file is in the same directory or in the
10" default debian location.
Bram Moolenaar362e1a32006-03-06 23:29:24 +000011" - There is no Latex markup in equations
Bram Moolenaar5c736222010-01-06 20:54:52 +010012" - Thanks to Will Gray for finding and fixing a bug
Bram Moolenaar00a927d2010-05-14 23:24:24 +020013" - No support for \if, \ifelse and \out as I don't understand
14" them and have no examples at hand (help welcome).
15" - No support for \var tag within quoted string (dito)
Bram Moolenaar362e1a32006-03-06 23:29:24 +000016
17" Version Clears: {{{1
18" For version 5.x: Clear all syntax items
Bram Moolenaar910f66f2006-04-05 20:41:53 +000019" For version 6.x and 7.x: Quit when a syntax file was already loaded
Bram Moolenaar362e1a32006-03-06 23:29:24 +000020if version < 600
21 syntax clear
22elseif exists("b:current_syntax")
23 finish
24endif
25
26syn case match
27
Bram Moolenaar662db672011-03-22 14:05:35 +010028" R help identifiers {{{1
Bram Moolenaar362e1a32006-03-06 23:29:24 +000029syn region rhelpIdentifier matchgroup=rhelpSection start="\\name{" end="}"
30syn region rhelpIdentifier matchgroup=rhelpSection start="\\alias{" end="}"
Bram Moolenaar662db672011-03-22 14:05:35 +010031syn region rhelpIdentifier matchgroup=rhelpSection start="\\pkg{" end="}" contains=rhelpLink
Bram Moolenaar81af9252010-12-10 20:35:50 +010032syn region rhelpIdentifier matchgroup=rhelpSection start="\\method{" end="}" contained
33syn region rhelpIdentifier matchgroup=rhelpSection start="\\Rdversion{" end="}"
Bram Moolenaar362e1a32006-03-06 23:29:24 +000034
35" Highlighting of R code using an existing r.vim syntax file if available {{{1
Bram Moolenaar18144c82006-04-12 21:52:12 +000036syn include @R syntax/r.vim
Bram Moolenaar362e1a32006-03-06 23:29:24 +000037
38" Strings {{{1
Bram Moolenaar662db672011-03-22 14:05:35 +010039syn region rhelpString start=/"/ skip=/\\"/ end=/"/ contains=rhelpSpecialChar,rhelpCodeSpecial,rhelpLink contained
Bram Moolenaar362e1a32006-03-06 23:29:24 +000040
Bram Moolenaar662db672011-03-22 14:05:35 +010041" Special characters in R strings
42syn match rhelpCodeSpecial display contained "\\\\\(n\|r\|t\|b\|a\|f\|v\|'\|\"\)\|\\\\"
43
44" Special characters ( \$ \& \% \# \{ \} \_)
Bram Moolenaar362e1a32006-03-06 23:29:24 +000045syn match rhelpSpecialChar "\\[$&%#{}_]"
46
Bram Moolenaar662db672011-03-22 14:05:35 +010047
48" R code {{{1
49syn match rhelpDots "\\dots" containedin=@R
50syn region rhelpRcode matchgroup=Delimiter start="\\examples{" matchgroup=Delimiter transparent end="}" contains=@R,rhelpLink,rhelpIdentifier,rhelpString,rhelpSpecialChar,rhelpSection
51syn region rhelpRcode matchgroup=Delimiter start="\\usage{" matchgroup=Delimiter transparent end="}" contains=@R,rhelpIdentifier,rhelpS4method
52syn region rhelpRcode matchgroup=Delimiter start="\\synopsis{" matchgroup=Delimiter transparent end="}" contains=@R
53syn region rhelpRcode matchgroup=Delimiter start="\\special{" matchgroup=Delimiter transparent end="}" contains=@R
54syn region rhelpRcode matchgroup=Delimiter start="\\code{" skip='\\\@<!{.\{-}\\\@<!}' transparent end="}" contains=@R,rhelpDots,rhelpString,rhelpSpecialChar,rhelpLink keepend
55syn region rhelpS4method matchgroup=Delimiter start="\\S4method{.*}(" matchgroup=Delimiter transparent end=")" contains=@R,rhelpDots
56syn region rhelpSexpr matchgroup=Delimiter start="\\Sexpr{" matchgroup=Delimiter transparent end="}" contains=@R
57
58" PreProc {{{1
59syn match rhelpPreProc "^#ifdef.*"
60syn match rhelpPreProc "^#endif.*"
61
Bram Moolenaar362e1a32006-03-06 23:29:24 +000062" Special Delimiters {{{1
63syn match rhelpDelimiter "\\cr"
64syn match rhelpDelimiter "\\tab "
65
66" Keywords {{{1
Bram Moolenaar662db672011-03-22 14:05:35 +010067syn match rhelpKeyword "\\R"
Bram Moolenaar362e1a32006-03-06 23:29:24 +000068syn match rhelpKeyword "\\ldots"
Bram Moolenaarf9393ef2006-04-24 19:47:27 +000069syn match rhelpKeyword "--"
70syn match rhelpKeyword "---"
71syn match rhelpKeyword "<"
72syn match rhelpKeyword ">"
Bram Moolenaar00a927d2010-05-14 23:24:24 +020073syn match rhelpKeyword "\\ge"
74syn match rhelpKeyword "\\le"
75syn match rhelpKeyword "\\alpha"
76syn match rhelpKeyword "\\beta"
77syn match rhelpKeyword "\\gamma"
78syn match rhelpKeyword "\\delta"
79syn match rhelpKeyword "\\epsilon"
80syn match rhelpKeyword "\\zeta"
81syn match rhelpKeyword "\\eta"
82syn match rhelpKeyword "\\theta"
83syn match rhelpKeyword "\\iota"
84syn match rhelpKeyword "\\kappa"
85syn match rhelpKeyword "\\lambda"
86syn match rhelpKeyword "\\mu"
87syn match rhelpKeyword "\\nu"
88syn match rhelpKeyword "\\xi"
89syn match rhelpKeyword "\\omicron"
90syn match rhelpKeyword "\\pi"
91syn match rhelpKeyword "\\rho"
92syn match rhelpKeyword "\\sigma"
93syn match rhelpKeyword "\\tau"
94syn match rhelpKeyword "\\upsilon"
95syn match rhelpKeyword "\\phi"
96syn match rhelpKeyword "\\chi"
97syn match rhelpKeyword "\\psi"
98syn match rhelpKeyword "\\omega"
99syn match rhelpKeyword "\\Alpha"
100syn match rhelpKeyword "\\Beta"
101syn match rhelpKeyword "\\Gamma"
102syn match rhelpKeyword "\\Delta"
103syn match rhelpKeyword "\\Epsilon"
104syn match rhelpKeyword "\\Zeta"
105syn match rhelpKeyword "\\Eta"
106syn match rhelpKeyword "\\Theta"
107syn match rhelpKeyword "\\Iota"
108syn match rhelpKeyword "\\Kappa"
109syn match rhelpKeyword "\\Lambda"
110syn match rhelpKeyword "\\Mu"
111syn match rhelpKeyword "\\Nu"
112syn match rhelpKeyword "\\Xi"
113syn match rhelpKeyword "\\Omicron"
114syn match rhelpKeyword "\\Pi"
115syn match rhelpKeyword "\\Rho"
116syn match rhelpKeyword "\\Sigma"
117syn match rhelpKeyword "\\Tau"
118syn match rhelpKeyword "\\Upsilon"
119syn match rhelpKeyword "\\Phi"
120syn match rhelpKeyword "\\Chi"
121syn match rhelpKeyword "\\Psi"
122syn match rhelpKeyword "\\Omega"
Bram Moolenaar362e1a32006-03-06 23:29:24 +0000123
124" Links {{{1
Bram Moolenaar662db672011-03-22 14:05:35 +0100125syn region rhelpLink matchgroup=rhelpSection start="\\link{" end="}" contained keepend extend
126syn region rhelpLink matchgroup=rhelpSection start="\\link\[.\{-}\]{" end="}" contained keepend extend
127syn region rhelpLink matchgroup=rhelpSection start="\\linkS4class{" end="}" contained keepend extend
128
129" Verbatim like {{{1
130syn region rhelpVerbatim matchgroup=rhelpType start="\\samp{" skip='\\\@<!{.\{-}\\\@<!}' end="}" contains=rhelpSpecialChar,rhelpComment
131syn region rhelpVerbatim matchgroup=rhelpType start="\\verb{" skip='\\\@<!{.\{-}\\\@<!}' end="}" contains=rhelpSpecialChar,rhelpComment
Bram Moolenaar362e1a32006-03-06 23:29:24 +0000132
133" Type Styles {{{1
134syn match rhelpType "\\emph\>"
135syn match rhelpType "\\strong\>"
136syn match rhelpType "\\bold\>"
137syn match rhelpType "\\sQuote\>"
138syn match rhelpType "\\dQuote\>"
139syn match rhelpType "\\preformatted\>"
140syn match rhelpType "\\kbd\>"
Bram Moolenaar362e1a32006-03-06 23:29:24 +0000141syn match rhelpType "\\eqn\>"
142syn match rhelpType "\\deqn\>"
143syn match rhelpType "\\file\>"
144syn match rhelpType "\\email\>"
145syn match rhelpType "\\url\>"
Bram Moolenaar81af9252010-12-10 20:35:50 +0100146syn match rhelpType "\\href\>"
Bram Moolenaar362e1a32006-03-06 23:29:24 +0000147syn match rhelpType "\\var\>"
148syn match rhelpType "\\env\>"
149syn match rhelpType "\\option\>"
150syn match rhelpType "\\command\>"
Bram Moolenaar81af9252010-12-10 20:35:50 +0100151syn match rhelpType "\\newcommand\>"
152syn match rhelpType "\\renewcommand\>"
Bram Moolenaar362e1a32006-03-06 23:29:24 +0000153syn match rhelpType "\\dfn\>"
154syn match rhelpType "\\cite\>"
155syn match rhelpType "\\acronym\>"
156
157" rhelp sections {{{1
158syn match rhelpSection "\\encoding\>"
159syn match rhelpSection "\\title\>"
Bram Moolenaar81af9252010-12-10 20:35:50 +0100160syn match rhelpSection "\\item\>"
Bram Moolenaar362e1a32006-03-06 23:29:24 +0000161syn match rhelpSection "\\description\>"
162syn match rhelpSection "\\concept\>"
163syn match rhelpSection "\\arguments\>"
164syn match rhelpSection "\\details\>"
165syn match rhelpSection "\\value\>"
166syn match rhelpSection "\\references\>"
167syn match rhelpSection "\\note\>"
168syn match rhelpSection "\\author\>"
169syn match rhelpSection "\\seealso\>"
170syn match rhelpSection "\\keyword\>"
171syn match rhelpSection "\\docType\>"
172syn match rhelpSection "\\format\>"
173syn match rhelpSection "\\source\>"
Bram Moolenaar81af9252010-12-10 20:35:50 +0100174syn match rhelpSection "\\itemize\>"
175syn match rhelpSection "\\describe\>"
176syn match rhelpSection "\\enumerate\>"
177syn match rhelpSection "\\item "
178syn match rhelpSection "\\item$"
Bram Moolenaar362e1a32006-03-06 23:29:24 +0000179syn match rhelpSection "\\tabular{[lcr]*}"
180syn match rhelpSection "\\dontrun\>"
181syn match rhelpSection "\\dontshow\>"
182syn match rhelpSection "\\testonly\>"
Bram Moolenaar446cb832008-06-24 21:56:24 +0000183syn match rhelpSection "\\donttest\>"
Bram Moolenaar362e1a32006-03-06 23:29:24 +0000184
185" Freely named Sections {{{1
Bram Moolenaar81af9252010-12-10 20:35:50 +0100186syn region rhelpFreesec matchgroup=Delimiter start="\\section{" matchgroup=Delimiter transparent end="}"
187syn region rhelpFreesubsec matchgroup=Delimiter start="\\subsection{" matchgroup=Delimiter transparent end="}"
Bram Moolenaar362e1a32006-03-06 23:29:24 +0000188
Bram Moolenaar662db672011-03-22 14:05:35 +0100189syn match rhelpDelimiter "{\|\[\|(\|)\|\]\|}"
190
Bram Moolenaarf9393ef2006-04-24 19:47:27 +0000191" R help file comments {{{1
Bram Moolenaar81af9252010-12-10 20:35:50 +0100192syn match rhelpComment /%.*$/
Bram Moolenaar362e1a32006-03-06 23:29:24 +0000193
194" Error {{{1
Bram Moolenaar15146672011-10-20 22:22:38 +0200195syn region rhelpRegion matchgroup=Delimiter start=/(/ matchgroup=Delimiter end=/)/ contains=@Spell,rhelpCodeSpecial,rhelpComment,rhelpDelimiter,rhelpDots,rhelpFreesec,rhelpFreesubsec,rhelpIdentifier,rhelpKeyword,rhelpLink,rhelpPreProc,rhelpRComment,rhelpRcode,rhelpRegion,rhelpS4method,rhelpSection,rhelpSexpr,rhelpSpecialChar,rhelpString,rhelpType,rhelpVerbatim
196syn region rhelpRegion matchgroup=Delimiter start=/{/ matchgroup=Delimiter end=/}/ contains=@Spell,rhelpCodeSpecial,rhelpComment,rhelpDelimiter,rhelpDots,rhelpFreesec,rhelpFreesubsec,rhelpIdentifier,rhelpKeyword,rhelpLink,rhelpPreProc,rhelpRComment,rhelpRcode,rhelpRegion,rhelpS4method,rhelpSection,rhelpSexpr,rhelpSpecialChar,rhelpString,rhelpType,rhelpVerbatim
197syn region rhelpRegion matchgroup=Delimiter start=/\[/ matchgroup=Delimiter end=/]/ contains=@Spell,rhelpCodeSpecial,rhelpComment,rhelpDelimiter,rhelpDots,rhelpFreesec,rhelpFreesubsec,rhelpIdentifier,rhelpKeyword,rhelpLink,rhelpPreProc,rhelpRComment,rhelpRcode,rhelpRegion,rhelpS4method,rhelpSection,rhelpSexpr,rhelpSpecialChar,rhelpString,rhelpType,rhelpVerbatim
Bram Moolenaar362e1a32006-03-06 23:29:24 +0000198syn match rhelpError /[)\]}]/
199syn match rhelpBraceError /[)}]/ contained
200syn match rhelpCurlyError /[)\]]/ contained
201syn match rhelpParenError /[\]}]/ contained
202
203" Define the default highlighting {{{1
204" For version 5.7 and earlier: only when not done already
205" For version 5.8 and later: only when an item doesn't have highlighting yet
206if version >= 508 || !exists("did_rhelp_syntax_inits")
207 if version < 508
208 let did_rhelp_syntax_inits = 1
209 command -nargs=+ HiLink hi link <args>
210 else
211 command -nargs=+ HiLink hi def link <args>
212 endif
Bram Moolenaar662db672011-03-22 14:05:35 +0100213 HiLink rhelpVerbatim String
214 HiLink rhelpDelimiter Delimiter
Bram Moolenaar362e1a32006-03-06 23:29:24 +0000215 HiLink rhelpIdentifier Identifier
216 HiLink rhelpString String
Bram Moolenaar662db672011-03-22 14:05:35 +0100217 HiLink rhelpCodeSpecial Special
Bram Moolenaar362e1a32006-03-06 23:29:24 +0000218 HiLink rhelpKeyword Keyword
Bram Moolenaarf9393ef2006-04-24 19:47:27 +0000219 HiLink rhelpDots Keyword
Bram Moolenaar362e1a32006-03-06 23:29:24 +0000220 HiLink rhelpLink Underlined
Bram Moolenaar662db672011-03-22 14:05:35 +0100221 HiLink rhelpType Type
Bram Moolenaar362e1a32006-03-06 23:29:24 +0000222 HiLink rhelpSection PreCondit
223 HiLink rhelpError Error
224 HiLink rhelpBraceError Error
225 HiLink rhelpCurlyError Error
226 HiLink rhelpParenError Error
Bram Moolenaar662db672011-03-22 14:05:35 +0100227 HiLink rhelpPreProc PreProc
Bram Moolenaar362e1a32006-03-06 23:29:24 +0000228 HiLink rhelpDelimiter Delimiter
229 HiLink rhelpComment Comment
230 HiLink rhelpRComment Comment
231 HiLink rhelpSpecialChar SpecialChar
232 delcommand HiLink
233endif
234
235let b:current_syntax = "rhelp"
236" vim: foldmethod=marker: