blob: f1b8d88e1c1241658971ed6a5f99a1141fa551e8 [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 Moolenaar446cb832008-06-24 21:56:24 +00004" Last Change: 2008 Apr 10
5" Version: 0.7.1
Bram Moolenaarf9393ef2006-04-24 19:47:27 +00006" SVN: $Id$
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
11
12" Version Clears: {{{1
13" For version 5.x: Clear all syntax items
Bram Moolenaar910f66f2006-04-05 20:41:53 +000014" For version 6.x and 7.x: Quit when a syntax file was already loaded
Bram Moolenaar362e1a32006-03-06 23:29:24 +000015if version < 600
16 syntax clear
17elseif exists("b:current_syntax")
18 finish
19endif
20
21syn case match
22
Bram Moolenaarf9393ef2006-04-24 19:47:27 +000023" R help identifiers {{{
Bram Moolenaar362e1a32006-03-06 23:29:24 +000024syn region rhelpIdentifier matchgroup=rhelpSection start="\\name{" end="}"
25syn region rhelpIdentifier matchgroup=rhelpSection start="\\alias{" end="}"
26syn region rhelpIdentifier matchgroup=rhelpSection start="\\pkg{" end="}"
Bram Moolenaarf9393ef2006-04-24 19:47:27 +000027syn region rhelpIdentifier matchgroup=rhelpSection start="\\item{" end="}" contained contains=rhelpDots
Bram Moolenaar362e1a32006-03-06 23:29:24 +000028syn region rhelpIdentifier matchgroup=rhelpSection start="\\method{" end=/}/ contained
29
30" Highlighting of R code using an existing r.vim syntax file if available {{{1
Bram Moolenaar18144c82006-04-12 21:52:12 +000031syn include @R syntax/r.vim
Bram Moolenaarf9393ef2006-04-24 19:47:27 +000032syn match rhelpDots "\\dots" containedin=@R
Bram Moolenaar362e1a32006-03-06 23:29:24 +000033syn region rhelpRcode matchgroup=Delimiter start="\\examples{" matchgroup=Delimiter transparent end=/}/ contains=@R,rhelpSection
Bram Moolenaarf9393ef2006-04-24 19:47:27 +000034syn region rhelpRcode matchgroup=Delimiter start="\\usage{" matchgroup=Delimiter transparent end=/}/ contains=@R,rhelpIdentifier,rhelpS4method
Bram Moolenaar362e1a32006-03-06 23:29:24 +000035syn region rhelpRcode matchgroup=Delimiter start="\\synopsis{" matchgroup=Delimiter transparent end=/}/ contains=@R
36syn region rhelpRcode matchgroup=Delimiter start="\\special{" matchgroup=Delimiter transparent end=/}/ contains=@R contained
Bram Moolenaar910f66f2006-04-05 20:41:53 +000037syn region rhelpRcode matchgroup=Delimiter start="\\code{" matchgroup=Delimiter transparent end=/}/ contains=@R,rhelpLink contained
Bram Moolenaarf9393ef2006-04-24 19:47:27 +000038syn region rhelpS4method matchgroup=Delimiter start="\\S4method{.*}(" matchgroup=Delimiter transparent end=/)/ contains=@R,rhelpDots contained
Bram Moolenaar362e1a32006-03-06 23:29:24 +000039
40" Strings {{{1
41syn region rhelpString start=/"/ end=/"/
42
Bram Moolenaar910f66f2006-04-05 20:41:53 +000043" Special characters ( \$ \& \% \# \{ \} \_) {{{1
Bram Moolenaar362e1a32006-03-06 23:29:24 +000044syn match rhelpSpecialChar "\\[$&%#{}_]"
45
46" Special Delimiters {{{1
47syn match rhelpDelimiter "\\cr"
48syn match rhelpDelimiter "\\tab "
49
50" Keywords {{{1
51syn match rhelpKeyword "\\R"
Bram Moolenaar362e1a32006-03-06 23:29:24 +000052syn match rhelpKeyword "\\ldots"
Bram Moolenaarf9393ef2006-04-24 19:47:27 +000053syn match rhelpKeyword "--"
54syn match rhelpKeyword "---"
55syn match rhelpKeyword "<"
56syn match rhelpKeyword ">"
Bram Moolenaar362e1a32006-03-06 23:29:24 +000057
58" Links {{{1
59syn region rhelpLink matchgroup=rhelpSection start="\\link{" end="}" contained keepend
60syn region rhelpLink matchgroup=rhelpSection start="\\link\[.*\]{" end="}" contained keepend
Bram Moolenaarf9393ef2006-04-24 19:47:27 +000061syn region rhelpLink matchgroup=rhelpSection start="\\linkS4class{" end="}" contained keepend
Bram Moolenaar362e1a32006-03-06 23:29:24 +000062
63" Type Styles {{{1
64syn match rhelpType "\\emph\>"
65syn match rhelpType "\\strong\>"
66syn match rhelpType "\\bold\>"
67syn match rhelpType "\\sQuote\>"
68syn match rhelpType "\\dQuote\>"
69syn match rhelpType "\\preformatted\>"
70syn match rhelpType "\\kbd\>"
71syn match rhelpType "\\samp\>"
72syn match rhelpType "\\eqn\>"
73syn match rhelpType "\\deqn\>"
74syn match rhelpType "\\file\>"
75syn match rhelpType "\\email\>"
76syn match rhelpType "\\url\>"
77syn match rhelpType "\\var\>"
78syn match rhelpType "\\env\>"
79syn match rhelpType "\\option\>"
80syn match rhelpType "\\command\>"
81syn match rhelpType "\\dfn\>"
82syn match rhelpType "\\cite\>"
83syn match rhelpType "\\acronym\>"
84
85" rhelp sections {{{1
86syn match rhelpSection "\\encoding\>"
87syn match rhelpSection "\\title\>"
88syn match rhelpSection "\\description\>"
89syn match rhelpSection "\\concept\>"
90syn match rhelpSection "\\arguments\>"
91syn match rhelpSection "\\details\>"
92syn match rhelpSection "\\value\>"
93syn match rhelpSection "\\references\>"
94syn match rhelpSection "\\note\>"
95syn match rhelpSection "\\author\>"
96syn match rhelpSection "\\seealso\>"
97syn match rhelpSection "\\keyword\>"
98syn match rhelpSection "\\docType\>"
99syn match rhelpSection "\\format\>"
100syn match rhelpSection "\\source\>"
101syn match rhelpSection "\\itemize\>"
102syn match rhelpSection "\\describe\>"
103syn match rhelpSection "\\enumerate\>"
104syn match rhelpSection "\\item "
105syn match rhelpSection "\\item$"
106syn match rhelpSection "\\tabular{[lcr]*}"
107syn match rhelpSection "\\dontrun\>"
108syn match rhelpSection "\\dontshow\>"
109syn match rhelpSection "\\testonly\>"
Bram Moolenaar446cb832008-06-24 21:56:24 +0000110syn match rhelpSection "\\donttest\>"
Bram Moolenaar362e1a32006-03-06 23:29:24 +0000111
112" Freely named Sections {{{1
113syn region rhelpFreesec matchgroup=Delimiter start="\\section{" matchgroup=Delimiter transparent end=/}/
114
Bram Moolenaarf9393ef2006-04-24 19:47:27 +0000115" R help file comments {{{1
Bram Moolenaar362e1a32006-03-06 23:29:24 +0000116syn match rhelpComment /%.*$/ contained
117
118" Error {{{1
119syn region rhelpRegion matchgroup=Delimiter start=/(/ matchgroup=Delimiter end=/)/ transparent contains=ALLBUT,rhelpError,rhelpBraceError,rhelpCurlyError
120syn region rhelpRegion matchgroup=Delimiter start=/{/ matchgroup=Delimiter end=/}/ transparent contains=ALLBUT,rhelpError,rhelpBraceError,rhelpParenError
121syn region rhelpRegion matchgroup=Delimiter start=/\[/ matchgroup=Delimiter end=/]/ transparent contains=ALLBUT,rhelpError,rhelpCurlyError,rhelpParenError
122syn match rhelpError /[)\]}]/
123syn match rhelpBraceError /[)}]/ contained
124syn match rhelpCurlyError /[)\]]/ contained
125syn match rhelpParenError /[\]}]/ contained
126
127" Define the default highlighting {{{1
128" For version 5.7 and earlier: only when not done already
129" For version 5.8 and later: only when an item doesn't have highlighting yet
130if version >= 508 || !exists("did_rhelp_syntax_inits")
131 if version < 508
132 let did_rhelp_syntax_inits = 1
133 command -nargs=+ HiLink hi link <args>
134 else
135 command -nargs=+ HiLink hi def link <args>
136 endif
137 HiLink rhelpIdentifier Identifier
138 HiLink rhelpString String
139 HiLink rhelpKeyword Keyword
Bram Moolenaarf9393ef2006-04-24 19:47:27 +0000140 HiLink rhelpDots Keyword
Bram Moolenaar362e1a32006-03-06 23:29:24 +0000141 HiLink rhelpLink Underlined
Bram Moolenaarf9393ef2006-04-24 19:47:27 +0000142 HiLink rhelpType Type
Bram Moolenaar362e1a32006-03-06 23:29:24 +0000143 HiLink rhelpSection PreCondit
144 HiLink rhelpError Error
145 HiLink rhelpBraceError Error
146 HiLink rhelpCurlyError Error
147 HiLink rhelpParenError Error
148 HiLink rhelpDelimiter Delimiter
149 HiLink rhelpComment Comment
150 HiLink rhelpRComment Comment
151 HiLink rhelpSpecialChar SpecialChar
152 delcommand HiLink
153endif
154
155let b:current_syntax = "rhelp"
156" vim: foldmethod=marker: