xref: /vim-8.2.3635/runtime/syntax/rhelp.vim (revision c0880db6)
1" Vim syntax file
2" Language:    R Help File
3" Maintainer:  Johannes Ranke <[email protected]>
4" Last Change: 2009 Mai 12
5" Version:     0.7.2
6" SVN:		   $Id: rhelp.vim 86 2009-05-12 19:23:47Z ranke $
7" 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.
10"              - There is no Latex markup in equations
11"              - Thanks to Will Gray for finding and fixing a bug
12
13" Version Clears: {{{1
14" For version 5.x: Clear all syntax items
15" For version 6.x and 7.x: Quit when a syntax file was already loaded
16if version < 600
17  syntax clear
18elseif exists("b:current_syntax")
19  finish
20endif
21
22syn case match
23
24" R help identifiers {{{
25syn region rhelpIdentifier matchgroup=rhelpSection	start="\\name{" end="}"
26syn region rhelpIdentifier matchgroup=rhelpSection	start="\\alias{" end="}"
27syn region rhelpIdentifier matchgroup=rhelpSection	start="\\pkg{" end="}"
28syn region rhelpIdentifier matchgroup=rhelpSection	start="\\item{" end="}" contained contains=rhelpDots
29syn region rhelpIdentifier matchgroup=rhelpSection start="\\method{" end=/}/ contained
30
31" Highlighting of R code using an existing r.vim syntax file if available {{{1
32syn include @R syntax/r.vim
33syn match rhelpDots		"\\dots" containedin=@R
34syn region rhelpRcode matchgroup=Delimiter start="\\examples{" matchgroup=Delimiter transparent end=/}/ contains=@R,rhelpSection
35syn region rhelpRcode matchgroup=Delimiter start="\\usage{" matchgroup=Delimiter transparent end=/}/ contains=@R,rhelpIdentifier,rhelpS4method
36syn 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
38syn region rhelpRcode matchgroup=Delimiter start="\\code{" matchgroup=Delimiter transparent end=/}/ contains=@R,rhelpLink contained
39syn region rhelpS4method matchgroup=Delimiter start="\\S4method{.*}(" matchgroup=Delimiter transparent end=/)/ contains=@R,rhelpDots contained
40
41" Strings {{{1
42syn region rhelpString start=/"/ end=/"/
43
44" Special characters  ( \$ \& \% \# \{ \} \_) {{{1
45syn match rhelpSpecialChar        "\\[$&%#{}_]"
46
47" Special Delimiters {{{1
48syn match rhelpDelimiter		"\\cr"
49syn match rhelpDelimiter		"\\tab "
50
51" Keywords {{{1
52syn match rhelpKeyword	"\\R"
53syn match rhelpKeyword	"\\ldots"
54syn match rhelpKeyword  "--"
55syn match rhelpKeyword  "---"
56syn match rhelpKeyword  "<"
57syn match rhelpKeyword  ">"
58
59" Links {{{1
60syn region rhelpLink matchgroup=rhelpSection start="\\link{" end="}" contained keepend
61syn region rhelpLink matchgroup=rhelpSection start="\\link\[.\{-}\]{" end="}" contained keepend
62syn region rhelpLink matchgroup=rhelpSection start="\\linkS4class{" end="}" contained keepend
63
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\>"
111syn match rhelpSection		"\\donttest\>"
112
113" Freely named Sections {{{1
114syn region rhelpFreesec matchgroup=Delimiter start="\\section{" matchgroup=Delimiter transparent end=/}/
115
116" R help file comments {{{1
117syn 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
141  HiLink rhelpDots        Keyword
142  HiLink rhelpLink        Underlined
143  HiLink rhelpType	      Type
144  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:
158