xref: /vim-8.2.3635/runtime/syntax/rhelp.vim (revision 81af9250)
1" Vim syntax file
2" Language:    R Help File
3" Maintainer:  Johannes Ranke <[email protected]>
4" Last Change: 2010 Nov 22
5" Version:     0.7.4
6" SVN:		   $Id: rhelp.vim 90 2010-11-22 10:58:11Z ranke $
7" Remarks:     - 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.
10"              - There is no Latex markup in equations
11"              - Thanks to Will Gray for finding and fixing a bug
12"              - No support for \if, \ifelse and \out as I don't understand
13"                them and have no examples at hand (help welcome).
14"              - No support for \var tag within quoted string (dito)
15
16" Version Clears: {{{1
17" For version 5.x: Clear all syntax items
18" For version 6.x and 7.x: Quit when a syntax file was already loaded
19if version < 600
20  syntax clear
21elseif exists("b:current_syntax")
22  finish
23endif
24
25syn case match
26
27" R help identifiers {{{
28syn region rhelpIdentifier matchgroup=rhelpSection	start="\\name{" end="}"
29syn region rhelpIdentifier matchgroup=rhelpSection	start="\\alias{" end="}"
30syn region rhelpIdentifier matchgroup=rhelpSection	start="\\pkg{" end="}"
31syn region rhelpIdentifier matchgroup=rhelpSection start="\\method{" end="}" contained
32syn region rhelpIdentifier matchgroup=rhelpSection start="\\Rdversion{" end="}"
33
34" Highlighting of R code using an existing r.vim syntax file if available {{{1
35syn include @R syntax/r.vim
36syn match rhelpDots		"\\dots" containedin=@R
37syn region rhelpRcode matchgroup=Delimiter start="\\examples{" matchgroup=Delimiter transparent end="}" contains=@R,rhelpSection
38syn region rhelpRcode matchgroup=Delimiter start="\\usage{" matchgroup=Delimiter transparent end="}" contains=@R,rhelpIdentifier,rhelpS4method
39syn region rhelpRcode matchgroup=Delimiter start="\\synopsis{" matchgroup=Delimiter transparent end="}" contains=@R
40syn region rhelpRcode matchgroup=Delimiter start="\\special{" matchgroup=Delimiter transparent end="}" contains=@R contained
41syn region rhelpRcode matchgroup=Delimiter start="\\code{" matchgroup=Delimiter transparent end="}" contains=@R,rhelpLink contained
42syn region rhelpS4method matchgroup=Delimiter start="\\S4method{.*}(" matchgroup=Delimiter transparent end=")" contains=@R,rhelpDots contained
43syn region rhelpSexpr matchgroup=Delimiter start="\\Sexpr{" matchgroup=Delimiter transparent end="}" contains=@R
44
45" Strings {{{1
46syn region rhelpString start=/"/ end=/"/
47
48" Special characters  ( \$ \& \% \# \{ \} \_) {{{1
49syn match rhelpSpecialChar        "\\[$&%#{}_]"
50
51" Special Delimiters {{{1
52syn match rhelpDelimiter		"\\cr"
53syn match rhelpDelimiter		"\\tab "
54
55" Keywords {{{1
56syn match rhelpKeyword	"\\R" contained
57syn match rhelpKeyword	"\\ldots"
58syn match rhelpKeyword  "--"
59syn match rhelpKeyword  "---"
60syn match rhelpKeyword  "<"
61syn match rhelpKeyword  ">"
62syn match rhelpKeyword	"\\ge"
63syn match rhelpKeyword	"\\le"
64syn match rhelpKeyword	"\\alpha"
65syn match rhelpKeyword	"\\beta"
66syn match rhelpKeyword	"\\gamma"
67syn match rhelpKeyword	"\\delta"
68syn match rhelpKeyword	"\\epsilon"
69syn match rhelpKeyword	"\\zeta"
70syn match rhelpKeyword	"\\eta"
71syn match rhelpKeyword	"\\theta"
72syn match rhelpKeyword	"\\iota"
73syn match rhelpKeyword	"\\kappa"
74syn match rhelpKeyword	"\\lambda"
75syn match rhelpKeyword	"\\mu"
76syn match rhelpKeyword	"\\nu"
77syn match rhelpKeyword	"\\xi"
78syn match rhelpKeyword	"\\omicron"
79syn match rhelpKeyword	"\\pi"
80syn match rhelpKeyword	"\\rho"
81syn match rhelpKeyword	"\\sigma"
82syn match rhelpKeyword	"\\tau"
83syn match rhelpKeyword	"\\upsilon"
84syn match rhelpKeyword	"\\phi"
85syn match rhelpKeyword	"\\chi"
86syn match rhelpKeyword	"\\psi"
87syn match rhelpKeyword	"\\omega"
88syn match rhelpKeyword	"\\Alpha"
89syn match rhelpKeyword	"\\Beta"
90syn match rhelpKeyword	"\\Gamma"
91syn match rhelpKeyword	"\\Delta"
92syn match rhelpKeyword	"\\Epsilon"
93syn match rhelpKeyword	"\\Zeta"
94syn match rhelpKeyword	"\\Eta"
95syn match rhelpKeyword	"\\Theta"
96syn match rhelpKeyword	"\\Iota"
97syn match rhelpKeyword	"\\Kappa"
98syn match rhelpKeyword	"\\Lambda"
99syn match rhelpKeyword	"\\Mu"
100syn match rhelpKeyword	"\\Nu"
101syn match rhelpKeyword	"\\Xi"
102syn match rhelpKeyword	"\\Omicron"
103syn match rhelpKeyword	"\\Pi"
104syn match rhelpKeyword	"\\Rho"
105syn match rhelpKeyword	"\\Sigma"
106syn match rhelpKeyword	"\\Tau"
107syn match rhelpKeyword	"\\Upsilon"
108syn match rhelpKeyword	"\\Phi"
109syn match rhelpKeyword	"\\Chi"
110syn match rhelpKeyword	"\\Psi"
111syn match rhelpKeyword	"\\Omega"
112
113" Links {{{1
114syn region rhelpLink matchgroup=rhelpSection start="\\link{" end="}" contained keepend
115syn region rhelpLink matchgroup=rhelpSection start="\\link\[.\{-}\]{" end="}" contained keepend
116syn region rhelpLink matchgroup=rhelpSection start="\\linkS4class{" end="}" contained keepend
117
118" Type Styles {{{1
119syn match rhelpType		"\\emph\>"
120syn match rhelpType		"\\strong\>"
121syn match rhelpType		"\\bold\>"
122syn match rhelpType		"\\sQuote\>"
123syn match rhelpType		"\\dQuote\>"
124syn match rhelpType		"\\preformatted\>"
125syn match rhelpType		"\\kbd\>"
126syn match rhelpType		"\\samp\>"
127syn match rhelpType		"\\eqn\>"
128syn match rhelpType		"\\deqn\>"
129syn match rhelpType		"\\file\>"
130syn match rhelpType		"\\email\>"
131syn match rhelpType		"\\url\>"
132syn match rhelpType		"\\href\>"
133syn match rhelpType		"\\var\>"
134syn match rhelpType		"\\env\>"
135syn match rhelpType		"\\option\>"
136syn match rhelpType		"\\command\>"
137syn match rhelpType		"\\newcommand\>"
138syn match rhelpType		"\\renewcommand\>"
139syn match rhelpType		"\\dfn\>"
140syn match rhelpType		"\\cite\>"
141syn match rhelpType		"\\acronym\>"
142
143" rhelp sections {{{1
144syn match rhelpSection		"\\encoding\>"
145syn match rhelpSection		"\\title\>"
146syn match rhelpSection		"\\item\>"
147syn match rhelpSection		"\\description\>"
148syn match rhelpSection		"\\concept\>"
149syn match rhelpSection		"\\arguments\>"
150syn match rhelpSection		"\\details\>"
151syn match rhelpSection		"\\value\>"
152syn match rhelpSection		"\\references\>"
153syn match rhelpSection		"\\note\>"
154syn match rhelpSection		"\\author\>"
155syn match rhelpSection		"\\seealso\>"
156syn match rhelpSection		"\\keyword\>"
157syn match rhelpSection		"\\docType\>"
158syn match rhelpSection		"\\format\>"
159syn match rhelpSection		"\\source\>"
160syn match rhelpSection    "\\itemize\>"
161syn match rhelpSection    "\\describe\>"
162syn match rhelpSection    "\\enumerate\>"
163syn match rhelpSection    "\\item "
164syn match rhelpSection    "\\item$"
165syn match rhelpSection		"\\tabular{[lcr]*}"
166syn match rhelpSection		"\\dontrun\>"
167syn match rhelpSection		"\\dontshow\>"
168syn match rhelpSection		"\\testonly\>"
169syn match rhelpSection		"\\donttest\>"
170
171" Freely named Sections {{{1
172syn region rhelpFreesec matchgroup=Delimiter start="\\section{" matchgroup=Delimiter transparent end="}"
173syn region rhelpFreesubsec matchgroup=Delimiter start="\\subsection{" matchgroup=Delimiter transparent end="}"
174
175" R help file comments {{{1
176syn match rhelpComment /%.*$/
177
178" Error {{{1
179syn region rhelpRegion matchgroup=Delimiter start=/(/ matchgroup=Delimiter end=/)/ transparent contains=ALLBUT,rhelpError,rhelpBraceError,rhelpCurlyError
180syn region rhelpRegion matchgroup=Delimiter start=/{/ matchgroup=Delimiter end=/}/ transparent contains=ALLBUT,rhelpError,rhelpBraceError,rhelpParenError
181syn region rhelpRegion matchgroup=Delimiter start=/\[/ matchgroup=Delimiter end=/]/ transparent contains=ALLBUT,rhelpError,rhelpCurlyError,rhelpParenError
182syn match rhelpError      /[)\]}]/
183syn match rhelpBraceError /[)}]/ contained
184syn match rhelpCurlyError /[)\]]/ contained
185syn match rhelpParenError /[\]}]/ contained
186
187" Define the default highlighting {{{1
188" For version 5.7 and earlier: only when not done already
189" For version 5.8 and later: only when an item doesn't have highlighting yet
190if version >= 508 || !exists("did_rhelp_syntax_inits")
191  if version < 508
192    let did_rhelp_syntax_inits = 1
193    command -nargs=+ HiLink hi link <args>
194  else
195    command -nargs=+ HiLink hi def link <args>
196  endif
197  HiLink rhelpIdentifier  Identifier
198  HiLink rhelpString      String
199  HiLink rhelpKeyword     Keyword
200  HiLink rhelpDots        Keyword
201  HiLink rhelpLink        Underlined
202  HiLink rhelpType	      Type
203  HiLink rhelpSection     PreCondit
204  HiLink rhelpError       Error
205  HiLink rhelpBraceError  Error
206  HiLink rhelpCurlyError  Error
207  HiLink rhelpParenError  Error
208  HiLink rhelpDelimiter   Delimiter
209  HiLink rhelpComment     Comment
210  HiLink rhelpRComment    Comment
211  HiLink rhelpSpecialChar SpecialChar
212  delcommand HiLink
213endif
214
215let   b:current_syntax = "rhelp"
216" vim: foldmethod=marker:
217