714
|
1 " Vim syntax file
|
|
2 " Language: R Help File
|
2725
|
3 " Maintainer: Jakson Aquino <jalvesaq@gmail.com>
|
|
4 " Former Maintainer: Johannes Ranke <jranke@uni-bremen.de>
|
3153
|
5 " Last Change: Fri Oct 14, 2011 09:54PM
|
2662
|
6 " 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
|
714
|
9 " sections if an r.vim file is in the same directory or in the
|
|
10 " default debian location.
|
|
11 " - There is no Latex markup in equations
|
2034
|
12 " - Thanks to Will Gray for finding and fixing a bug
|
2152
|
13 " - 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)
|
714
|
16
|
|
17 " Version Clears: {{{1
|
|
18 " For version 5.x: Clear all syntax items
|
819
|
19 " For version 6.x and 7.x: Quit when a syntax file was already loaded
|
714
|
20 if version < 600
|
|
21 syntax clear
|
|
22 elseif exists("b:current_syntax")
|
|
23 finish
|
|
24 endif
|
|
25
|
|
26 syn case match
|
|
27
|
2725
|
28 " R help identifiers {{{1
|
714
|
29 syn region rhelpIdentifier matchgroup=rhelpSection start="\\name{" end="}"
|
|
30 syn region rhelpIdentifier matchgroup=rhelpSection start="\\alias{" end="}"
|
2725
|
31 syn region rhelpIdentifier matchgroup=rhelpSection start="\\pkg{" end="}" contains=rhelpLink
|
2662
|
32 syn region rhelpIdentifier matchgroup=rhelpSection start="\\method{" end="}" contained
|
|
33 syn region rhelpIdentifier matchgroup=rhelpSection start="\\Rdversion{" end="}"
|
714
|
34
|
|
35 " Highlighting of R code using an existing r.vim syntax file if available {{{1
|
827
|
36 syn include @R syntax/r.vim
|
2725
|
37
|
|
38 " Strings {{{1
|
|
39 syn region rhelpString start=/"/ skip=/\\"/ end=/"/ contains=rhelpSpecialChar,rhelpCodeSpecial,rhelpLink contained
|
|
40
|
|
41 " Special characters in R strings
|
|
42 syn match rhelpCodeSpecial display contained "\\\\\(n\|r\|t\|b\|a\|f\|v\|'\|\"\)\|\\\\"
|
|
43
|
|
44 " Special characters ( \$ \& \% \# \{ \} \_)
|
|
45 syn match rhelpSpecialChar "\\[$&%#{}_]"
|
|
46
|
|
47
|
|
48 " R code {{{1
|
842
|
49 syn match rhelpDots "\\dots" containedin=@R
|
2725
|
50 syn region rhelpRcode matchgroup=Delimiter start="\\examples{" matchgroup=Delimiter transparent end="}" contains=@R,rhelpLink,rhelpIdentifier,rhelpString,rhelpSpecialChar,rhelpSection
|
2662
|
51 syn region rhelpRcode matchgroup=Delimiter start="\\usage{" matchgroup=Delimiter transparent end="}" contains=@R,rhelpIdentifier,rhelpS4method
|
|
52 syn region rhelpRcode matchgroup=Delimiter start="\\synopsis{" matchgroup=Delimiter transparent end="}" contains=@R
|
2725
|
53 syn region rhelpRcode matchgroup=Delimiter start="\\special{" matchgroup=Delimiter transparent end="}" contains=@R
|
|
54 syn region rhelpRcode matchgroup=Delimiter start="\\code{" skip='\\\@<!{.\{-}\\\@<!}' transparent end="}" contains=@R,rhelpDots,rhelpString,rhelpSpecialChar,rhelpLink keepend
|
|
55 syn region rhelpS4method matchgroup=Delimiter start="\\S4method{.*}(" matchgroup=Delimiter transparent end=")" contains=@R,rhelpDots
|
2662
|
56 syn region rhelpSexpr matchgroup=Delimiter start="\\Sexpr{" matchgroup=Delimiter transparent end="}" contains=@R
|
714
|
57
|
2725
|
58 " PreProc {{{1
|
|
59 syn match rhelpPreProc "^#ifdef.*"
|
|
60 syn match rhelpPreProc "^#endif.*"
|
714
|
61
|
|
62 " Special Delimiters {{{1
|
|
63 syn match rhelpDelimiter "\\cr"
|
|
64 syn match rhelpDelimiter "\\tab "
|
|
65
|
|
66 " Keywords {{{1
|
2725
|
67 syn match rhelpKeyword "\\R"
|
714
|
68 syn match rhelpKeyword "\\ldots"
|
842
|
69 syn match rhelpKeyword "--"
|
|
70 syn match rhelpKeyword "---"
|
|
71 syn match rhelpKeyword "<"
|
|
72 syn match rhelpKeyword ">"
|
2152
|
73 syn match rhelpKeyword "\\ge"
|
|
74 syn match rhelpKeyword "\\le"
|
|
75 syn match rhelpKeyword "\\alpha"
|
|
76 syn match rhelpKeyword "\\beta"
|
|
77 syn match rhelpKeyword "\\gamma"
|
|
78 syn match rhelpKeyword "\\delta"
|
|
79 syn match rhelpKeyword "\\epsilon"
|
|
80 syn match rhelpKeyword "\\zeta"
|
|
81 syn match rhelpKeyword "\\eta"
|
|
82 syn match rhelpKeyword "\\theta"
|
|
83 syn match rhelpKeyword "\\iota"
|
|
84 syn match rhelpKeyword "\\kappa"
|
|
85 syn match rhelpKeyword "\\lambda"
|
|
86 syn match rhelpKeyword "\\mu"
|
|
87 syn match rhelpKeyword "\\nu"
|
|
88 syn match rhelpKeyword "\\xi"
|
|
89 syn match rhelpKeyword "\\omicron"
|
|
90 syn match rhelpKeyword "\\pi"
|
|
91 syn match rhelpKeyword "\\rho"
|
|
92 syn match rhelpKeyword "\\sigma"
|
|
93 syn match rhelpKeyword "\\tau"
|
|
94 syn match rhelpKeyword "\\upsilon"
|
|
95 syn match rhelpKeyword "\\phi"
|
|
96 syn match rhelpKeyword "\\chi"
|
|
97 syn match rhelpKeyword "\\psi"
|
|
98 syn match rhelpKeyword "\\omega"
|
|
99 syn match rhelpKeyword "\\Alpha"
|
|
100 syn match rhelpKeyword "\\Beta"
|
|
101 syn match rhelpKeyword "\\Gamma"
|
|
102 syn match rhelpKeyword "\\Delta"
|
|
103 syn match rhelpKeyword "\\Epsilon"
|
|
104 syn match rhelpKeyword "\\Zeta"
|
|
105 syn match rhelpKeyword "\\Eta"
|
|
106 syn match rhelpKeyword "\\Theta"
|
|
107 syn match rhelpKeyword "\\Iota"
|
|
108 syn match rhelpKeyword "\\Kappa"
|
|
109 syn match rhelpKeyword "\\Lambda"
|
|
110 syn match rhelpKeyword "\\Mu"
|
|
111 syn match rhelpKeyword "\\Nu"
|
|
112 syn match rhelpKeyword "\\Xi"
|
|
113 syn match rhelpKeyword "\\Omicron"
|
|
114 syn match rhelpKeyword "\\Pi"
|
|
115 syn match rhelpKeyword "\\Rho"
|
|
116 syn match rhelpKeyword "\\Sigma"
|
|
117 syn match rhelpKeyword "\\Tau"
|
|
118 syn match rhelpKeyword "\\Upsilon"
|
|
119 syn match rhelpKeyword "\\Phi"
|
|
120 syn match rhelpKeyword "\\Chi"
|
|
121 syn match rhelpKeyword "\\Psi"
|
|
122 syn match rhelpKeyword "\\Omega"
|
714
|
123
|
|
124 " Links {{{1
|
2725
|
125 syn region rhelpLink matchgroup=rhelpSection start="\\link{" end="}" contained keepend extend
|
|
126 syn region rhelpLink matchgroup=rhelpSection start="\\link\[.\{-}\]{" end="}" contained keepend extend
|
|
127 syn region rhelpLink matchgroup=rhelpSection start="\\linkS4class{" end="}" contained keepend extend
|
|
128
|
|
129 " Verbatim like {{{1
|
|
130 syn region rhelpVerbatim matchgroup=rhelpType start="\\samp{" skip='\\\@<!{.\{-}\\\@<!}' end="}" contains=rhelpSpecialChar,rhelpComment
|
|
131 syn region rhelpVerbatim matchgroup=rhelpType start="\\verb{" skip='\\\@<!{.\{-}\\\@<!}' end="}" contains=rhelpSpecialChar,rhelpComment
|
714
|
132
|
|
133 " Type Styles {{{1
|
|
134 syn match rhelpType "\\emph\>"
|
|
135 syn match rhelpType "\\strong\>"
|
|
136 syn match rhelpType "\\bold\>"
|
|
137 syn match rhelpType "\\sQuote\>"
|
|
138 syn match rhelpType "\\dQuote\>"
|
|
139 syn match rhelpType "\\preformatted\>"
|
|
140 syn match rhelpType "\\kbd\>"
|
|
141 syn match rhelpType "\\eqn\>"
|
|
142 syn match rhelpType "\\deqn\>"
|
|
143 syn match rhelpType "\\file\>"
|
|
144 syn match rhelpType "\\email\>"
|
|
145 syn match rhelpType "\\url\>"
|
2662
|
146 syn match rhelpType "\\href\>"
|
714
|
147 syn match rhelpType "\\var\>"
|
|
148 syn match rhelpType "\\env\>"
|
|
149 syn match rhelpType "\\option\>"
|
|
150 syn match rhelpType "\\command\>"
|
2662
|
151 syn match rhelpType "\\newcommand\>"
|
|
152 syn match rhelpType "\\renewcommand\>"
|
714
|
153 syn match rhelpType "\\dfn\>"
|
|
154 syn match rhelpType "\\cite\>"
|
|
155 syn match rhelpType "\\acronym\>"
|
|
156
|
|
157 " rhelp sections {{{1
|
|
158 syn match rhelpSection "\\encoding\>"
|
|
159 syn match rhelpSection "\\title\>"
|
2662
|
160 syn match rhelpSection "\\item\>"
|
714
|
161 syn match rhelpSection "\\description\>"
|
|
162 syn match rhelpSection "\\concept\>"
|
|
163 syn match rhelpSection "\\arguments\>"
|
|
164 syn match rhelpSection "\\details\>"
|
|
165 syn match rhelpSection "\\value\>"
|
|
166 syn match rhelpSection "\\references\>"
|
|
167 syn match rhelpSection "\\note\>"
|
|
168 syn match rhelpSection "\\author\>"
|
|
169 syn match rhelpSection "\\seealso\>"
|
|
170 syn match rhelpSection "\\keyword\>"
|
|
171 syn match rhelpSection "\\docType\>"
|
|
172 syn match rhelpSection "\\format\>"
|
|
173 syn match rhelpSection "\\source\>"
|
2662
|
174 syn match rhelpSection "\\itemize\>"
|
|
175 syn match rhelpSection "\\describe\>"
|
|
176 syn match rhelpSection "\\enumerate\>"
|
|
177 syn match rhelpSection "\\item "
|
|
178 syn match rhelpSection "\\item$"
|
714
|
179 syn match rhelpSection "\\tabular{[lcr]*}"
|
|
180 syn match rhelpSection "\\dontrun\>"
|
|
181 syn match rhelpSection "\\dontshow\>"
|
|
182 syn match rhelpSection "\\testonly\>"
|
1621
|
183 syn match rhelpSection "\\donttest\>"
|
714
|
184
|
|
185 " Freely named Sections {{{1
|
2662
|
186 syn region rhelpFreesec matchgroup=Delimiter start="\\section{" matchgroup=Delimiter transparent end="}"
|
|
187 syn region rhelpFreesubsec matchgroup=Delimiter start="\\subsection{" matchgroup=Delimiter transparent end="}"
|
714
|
188
|
2725
|
189 syn match rhelpDelimiter "{\|\[\|(\|)\|\]\|}"
|
|
190
|
842
|
191 " R help file comments {{{1
|
2662
|
192 syn match rhelpComment /%.*$/
|
714
|
193
|
|
194 " Error {{{1
|
3153
|
195 syn 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
|
|
196 syn 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
|
|
197 syn 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
|
714
|
198 syn match rhelpError /[)\]}]/
|
|
199 syn match rhelpBraceError /[)}]/ contained
|
|
200 syn match rhelpCurlyError /[)\]]/ contained
|
|
201 syn 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
|
|
206 if 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
|
2725
|
213 HiLink rhelpVerbatim String
|
|
214 HiLink rhelpDelimiter Delimiter
|
714
|
215 HiLink rhelpIdentifier Identifier
|
|
216 HiLink rhelpString String
|
2725
|
217 HiLink rhelpCodeSpecial Special
|
714
|
218 HiLink rhelpKeyword Keyword
|
842
|
219 HiLink rhelpDots Keyword
|
714
|
220 HiLink rhelpLink Underlined
|
2725
|
221 HiLink rhelpType Type
|
714
|
222 HiLink rhelpSection PreCondit
|
|
223 HiLink rhelpError Error
|
|
224 HiLink rhelpBraceError Error
|
|
225 HiLink rhelpCurlyError Error
|
|
226 HiLink rhelpParenError Error
|
2725
|
227 HiLink rhelpPreProc PreProc
|
714
|
228 HiLink rhelpDelimiter Delimiter
|
|
229 HiLink rhelpComment Comment
|
|
230 HiLink rhelpRComment Comment
|
|
231 HiLink rhelpSpecialChar SpecialChar
|
|
232 delcommand HiLink
|
|
233 endif
|
|
234
|
|
235 let b:current_syntax = "rhelp"
|
|
236 " vim: foldmethod=marker:
|