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