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