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>
|
6051
|
5 " Last Change: Wed Jul 09, 2014 10:28PM
|
2662
|
6 " Remarks: - Includes R syntax highlighting in the appropriate
|
714
|
7 " sections if an r.vim file is in the same directory or in the
|
|
8 " default debian location.
|
|
9 " - There is no Latex markup in equations
|
2034
|
10 " - Thanks to Will Gray for finding and fixing a bug
|
2152
|
11 " - No support for \if, \ifelse and \out as I don't understand
|
|
12 " them and have no examples at hand (help welcome).
|
|
13 " - No support for \var tag within quoted string (dito)
|
714
|
14
|
|
15 " Version Clears: {{{1
|
|
16 " For version 5.x: Clear all syntax items
|
819
|
17 " For version 6.x and 7.x: Quit when a syntax file was already loaded
|
714
|
18 if version < 600
|
|
19 syntax clear
|
|
20 elseif exists("b:current_syntax")
|
|
21 finish
|
|
22 endif
|
|
23
|
6051
|
24 setlocal iskeyword=@,48-57,_,.
|
|
25
|
714
|
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
|
6051
|
54
|
|
55 if v:version > 703
|
|
56 syn region rhelpRcode matchgroup=Delimiter start="\\code{" skip='\\\@1<!{.\{-}\\\@1<!}' transparent end="}" contains=@R,rhelpDots,rhelpString,rhelpSpecialChar,rhelpLink keepend
|
|
57 else
|
|
58 syn region rhelpRcode matchgroup=Delimiter start="\\code{" skip='\\\@<!{.\{-}\\\@<!}' transparent end="}" contains=@R,rhelpDots,rhelpString,rhelpSpecialChar,rhelpLink keepend
|
|
59 endif
|
2725
|
60 syn region rhelpS4method matchgroup=Delimiter start="\\S4method{.*}(" matchgroup=Delimiter transparent end=")" contains=@R,rhelpDots
|
2662
|
61 syn region rhelpSexpr matchgroup=Delimiter start="\\Sexpr{" matchgroup=Delimiter transparent end="}" contains=@R
|
714
|
62
|
2725
|
63 " PreProc {{{1
|
|
64 syn match rhelpPreProc "^#ifdef.*"
|
|
65 syn match rhelpPreProc "^#endif.*"
|
714
|
66
|
|
67 " Special Delimiters {{{1
|
|
68 syn match rhelpDelimiter "\\cr"
|
|
69 syn match rhelpDelimiter "\\tab "
|
|
70
|
|
71 " Keywords {{{1
|
2725
|
72 syn match rhelpKeyword "\\R"
|
714
|
73 syn match rhelpKeyword "\\ldots"
|
842
|
74 syn match rhelpKeyword "--"
|
|
75 syn match rhelpKeyword "---"
|
|
76 syn match rhelpKeyword "<"
|
|
77 syn match rhelpKeyword ">"
|
2152
|
78 syn match rhelpKeyword "\\ge"
|
|
79 syn match rhelpKeyword "\\le"
|
|
80 syn match rhelpKeyword "\\alpha"
|
|
81 syn match rhelpKeyword "\\beta"
|
|
82 syn match rhelpKeyword "\\gamma"
|
|
83 syn match rhelpKeyword "\\delta"
|
|
84 syn match rhelpKeyword "\\epsilon"
|
|
85 syn match rhelpKeyword "\\zeta"
|
|
86 syn match rhelpKeyword "\\eta"
|
|
87 syn match rhelpKeyword "\\theta"
|
|
88 syn match rhelpKeyword "\\iota"
|
|
89 syn match rhelpKeyword "\\kappa"
|
|
90 syn match rhelpKeyword "\\lambda"
|
|
91 syn match rhelpKeyword "\\mu"
|
|
92 syn match rhelpKeyword "\\nu"
|
|
93 syn match rhelpKeyword "\\xi"
|
|
94 syn match rhelpKeyword "\\omicron"
|
|
95 syn match rhelpKeyword "\\pi"
|
|
96 syn match rhelpKeyword "\\rho"
|
|
97 syn match rhelpKeyword "\\sigma"
|
|
98 syn match rhelpKeyword "\\tau"
|
|
99 syn match rhelpKeyword "\\upsilon"
|
|
100 syn match rhelpKeyword "\\phi"
|
|
101 syn match rhelpKeyword "\\chi"
|
|
102 syn match rhelpKeyword "\\psi"
|
|
103 syn match rhelpKeyword "\\omega"
|
|
104 syn match rhelpKeyword "\\Alpha"
|
|
105 syn match rhelpKeyword "\\Beta"
|
|
106 syn match rhelpKeyword "\\Gamma"
|
|
107 syn match rhelpKeyword "\\Delta"
|
|
108 syn match rhelpKeyword "\\Epsilon"
|
|
109 syn match rhelpKeyword "\\Zeta"
|
|
110 syn match rhelpKeyword "\\Eta"
|
|
111 syn match rhelpKeyword "\\Theta"
|
|
112 syn match rhelpKeyword "\\Iota"
|
|
113 syn match rhelpKeyword "\\Kappa"
|
|
114 syn match rhelpKeyword "\\Lambda"
|
|
115 syn match rhelpKeyword "\\Mu"
|
|
116 syn match rhelpKeyword "\\Nu"
|
|
117 syn match rhelpKeyword "\\Xi"
|
|
118 syn match rhelpKeyword "\\Omicron"
|
|
119 syn match rhelpKeyword "\\Pi"
|
|
120 syn match rhelpKeyword "\\Rho"
|
|
121 syn match rhelpKeyword "\\Sigma"
|
|
122 syn match rhelpKeyword "\\Tau"
|
|
123 syn match rhelpKeyword "\\Upsilon"
|
|
124 syn match rhelpKeyword "\\Phi"
|
|
125 syn match rhelpKeyword "\\Chi"
|
|
126 syn match rhelpKeyword "\\Psi"
|
|
127 syn match rhelpKeyword "\\Omega"
|
714
|
128
|
|
129 " Links {{{1
|
2725
|
130 syn region rhelpLink matchgroup=rhelpSection start="\\link{" end="}" contained keepend extend
|
|
131 syn region rhelpLink matchgroup=rhelpSection start="\\link\[.\{-}\]{" end="}" contained keepend extend
|
|
132 syn region rhelpLink matchgroup=rhelpSection start="\\linkS4class{" end="}" contained keepend extend
|
|
133
|
|
134 " Verbatim like {{{1
|
6051
|
135 if v:version > 703
|
|
136 syn region rhelpVerbatim matchgroup=rhelpType start="\\samp{" skip='\\\@1<!{.\{-}\\\@1<!}' end="}" contains=rhelpSpecialChar,rhelpComment
|
|
137 syn region rhelpVerbatim matchgroup=rhelpType start="\\verb{" skip='\\\@1<!{.\{-}\\\@1<!}' end="}" contains=rhelpSpecialChar,rhelpComment
|
|
138 else
|
|
139 syn region rhelpVerbatim matchgroup=rhelpType start="\\samp{" skip='\\\@<!{.\{-}\\\@<!}' end="}" contains=rhelpSpecialChar,rhelpComment
|
|
140 syn region rhelpVerbatim matchgroup=rhelpType start="\\verb{" skip='\\\@<!{.\{-}\\\@<!}' end="}" contains=rhelpSpecialChar,rhelpComment
|
|
141 endif
|
714
|
142
|
|
143 " Type Styles {{{1
|
|
144 syn match rhelpType "\\emph\>"
|
|
145 syn match rhelpType "\\strong\>"
|
|
146 syn match rhelpType "\\bold\>"
|
|
147 syn match rhelpType "\\sQuote\>"
|
|
148 syn match rhelpType "\\dQuote\>"
|
|
149 syn match rhelpType "\\preformatted\>"
|
|
150 syn match rhelpType "\\kbd\>"
|
|
151 syn match rhelpType "\\eqn\>"
|
|
152 syn match rhelpType "\\deqn\>"
|
|
153 syn match rhelpType "\\file\>"
|
|
154 syn match rhelpType "\\email\>"
|
|
155 syn match rhelpType "\\url\>"
|
2662
|
156 syn match rhelpType "\\href\>"
|
714
|
157 syn match rhelpType "\\var\>"
|
|
158 syn match rhelpType "\\env\>"
|
|
159 syn match rhelpType "\\option\>"
|
|
160 syn match rhelpType "\\command\>"
|
2662
|
161 syn match rhelpType "\\newcommand\>"
|
|
162 syn match rhelpType "\\renewcommand\>"
|
714
|
163 syn match rhelpType "\\dfn\>"
|
|
164 syn match rhelpType "\\cite\>"
|
|
165 syn match rhelpType "\\acronym\>"
|
|
166
|
|
167 " rhelp sections {{{1
|
|
168 syn match rhelpSection "\\encoding\>"
|
|
169 syn match rhelpSection "\\title\>"
|
2662
|
170 syn match rhelpSection "\\item\>"
|
714
|
171 syn match rhelpSection "\\description\>"
|
|
172 syn match rhelpSection "\\concept\>"
|
|
173 syn match rhelpSection "\\arguments\>"
|
|
174 syn match rhelpSection "\\details\>"
|
|
175 syn match rhelpSection "\\value\>"
|
|
176 syn match rhelpSection "\\references\>"
|
|
177 syn match rhelpSection "\\note\>"
|
|
178 syn match rhelpSection "\\author\>"
|
|
179 syn match rhelpSection "\\seealso\>"
|
|
180 syn match rhelpSection "\\keyword\>"
|
|
181 syn match rhelpSection "\\docType\>"
|
|
182 syn match rhelpSection "\\format\>"
|
|
183 syn match rhelpSection "\\source\>"
|
2662
|
184 syn match rhelpSection "\\itemize\>"
|
|
185 syn match rhelpSection "\\describe\>"
|
|
186 syn match rhelpSection "\\enumerate\>"
|
|
187 syn match rhelpSection "\\item "
|
|
188 syn match rhelpSection "\\item$"
|
714
|
189 syn match rhelpSection "\\tabular{[lcr]*}"
|
|
190 syn match rhelpSection "\\dontrun\>"
|
|
191 syn match rhelpSection "\\dontshow\>"
|
|
192 syn match rhelpSection "\\testonly\>"
|
1621
|
193 syn match rhelpSection "\\donttest\>"
|
714
|
194
|
|
195 " Freely named Sections {{{1
|
2662
|
196 syn region rhelpFreesec matchgroup=Delimiter start="\\section{" matchgroup=Delimiter transparent end="}"
|
|
197 syn region rhelpFreesubsec matchgroup=Delimiter start="\\subsection{" matchgroup=Delimiter transparent end="}"
|
714
|
198
|
2725
|
199 syn match rhelpDelimiter "{\|\[\|(\|)\|\]\|}"
|
|
200
|
842
|
201 " R help file comments {{{1
|
2662
|
202 syn match rhelpComment /%.*$/
|
714
|
203
|
|
204 " Error {{{1
|
3153
|
205 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
|
|
206 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
|
|
207 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
|
208 syn match rhelpError /[)\]}]/
|
|
209 syn match rhelpBraceError /[)}]/ contained
|
|
210 syn match rhelpCurlyError /[)\]]/ contained
|
|
211 syn match rhelpParenError /[\]}]/ contained
|
|
212
|
6051
|
213 syntax sync match rhelpSyncRcode grouphere rhelpRcode "\\examples{"
|
|
214
|
714
|
215 " Define the default highlighting {{{1
|
|
216 " For version 5.7 and earlier: only when not done already
|
|
217 " For version 5.8 and later: only when an item doesn't have highlighting yet
|
|
218 if version >= 508 || !exists("did_rhelp_syntax_inits")
|
|
219 if version < 508
|
|
220 let did_rhelp_syntax_inits = 1
|
|
221 command -nargs=+ HiLink hi link <args>
|
|
222 else
|
|
223 command -nargs=+ HiLink hi def link <args>
|
|
224 endif
|
2725
|
225 HiLink rhelpVerbatim String
|
|
226 HiLink rhelpDelimiter Delimiter
|
714
|
227 HiLink rhelpIdentifier Identifier
|
|
228 HiLink rhelpString String
|
2725
|
229 HiLink rhelpCodeSpecial Special
|
714
|
230 HiLink rhelpKeyword Keyword
|
842
|
231 HiLink rhelpDots Keyword
|
714
|
232 HiLink rhelpLink Underlined
|
2725
|
233 HiLink rhelpType Type
|
714
|
234 HiLink rhelpSection PreCondit
|
|
235 HiLink rhelpError Error
|
|
236 HiLink rhelpBraceError Error
|
|
237 HiLink rhelpCurlyError Error
|
|
238 HiLink rhelpParenError Error
|
2725
|
239 HiLink rhelpPreProc PreProc
|
714
|
240 HiLink rhelpDelimiter Delimiter
|
|
241 HiLink rhelpComment Comment
|
|
242 HiLink rhelpRComment Comment
|
|
243 HiLink rhelpSpecialChar SpecialChar
|
|
244 delcommand HiLink
|
|
245 endif
|
|
246
|
|
247 let b:current_syntax = "rhelp"
|
6051
|
248
|
|
249 " vim: foldmethod=marker sw=2
|