xref: /vim-8.2.3635/runtime/syntax/rhelp.vim (revision fc1421eb)
1" Vim syntax file
2" Language:    R Help File
3" Maintainer:  Johannes Ranke <[email protected]>
4" Last Change: 2006 Apr 12
5" Version:     0.6
6" Remarks:     - Now 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"              - I didn't yet include any special markup for S4 methods.
10"              - The two versions of \item{}{} markup are not
11"                distinguished (in the \arguments{} environment, the items to
12"                be described are R identifiers, but not in the \describe{}
13"                environment).
14"              - There is no Latex markup in equations
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" Rd 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="\\item{" end="}" contained
32syn region rhelpIdentifier matchgroup=rhelpSection start="\\method{" end=/}/ contained
33
34" Highlighting of R code using an existing r.vim syntax file if available {{{1
35syn include @R syntax/r.vim
36syn region rhelpRcode matchgroup=Delimiter start="\\examples{" matchgroup=Delimiter transparent end=/}/ contains=@R,rhelpSection
37syn region rhelpRcode matchgroup=Delimiter start="\\usage{" matchgroup=Delimiter transparent end=/}/ contains=@R,rhelpIdentifier
38syn region rhelpRcode matchgroup=Delimiter start="\\synopsis{" matchgroup=Delimiter transparent end=/}/ contains=@R
39syn region rhelpRcode matchgroup=Delimiter start="\\special{" matchgroup=Delimiter transparent end=/}/ contains=@R contained
40syn region rhelpRcode matchgroup=Delimiter start="\\code{" matchgroup=Delimiter transparent end=/}/ contains=@R,rhelpLink contained
41
42" Strings {{{1
43syn region rhelpString start=/"/ end=/"/
44
45" Special characters  ( \$ \& \% \# \{ \} \_) {{{1
46syn match rhelpSpecialChar        "\\[$&%#{}_]"
47
48" Special Delimiters {{{1
49syn match rhelpDelimiter		"\\cr"
50syn match rhelpDelimiter		"\\tab "
51
52" Keywords {{{1
53syn match rhelpKeyword	"\\R"
54syn match rhelpKeyword	"\\dots"
55syn match rhelpKeyword	"\\ldots"
56
57" Links {{{1
58syn region rhelpLink matchgroup=rhelpSection start="\\link{" end="}" contained keepend
59syn region rhelpLink matchgroup=rhelpSection start="\\link\[.*\]{" end="}" contained keepend
60
61" Type Styles {{{1
62syn match rhelpType		"\\emph\>"
63syn match rhelpType		"\\strong\>"
64syn match rhelpType		"\\bold\>"
65syn match rhelpType		"\\sQuote\>"
66syn match rhelpType		"\\dQuote\>"
67syn match rhelpType		"\\preformatted\>"
68syn match rhelpType		"\\kbd\>"
69syn match rhelpType		"\\samp\>"
70syn match rhelpType		"\\eqn\>"
71syn match rhelpType		"\\deqn\>"
72syn match rhelpType		"\\file\>"
73syn match rhelpType		"\\email\>"
74syn match rhelpType		"\\url\>"
75syn match rhelpType		"\\var\>"
76syn match rhelpType		"\\env\>"
77syn match rhelpType		"\\option\>"
78syn match rhelpType		"\\command\>"
79syn match rhelpType		"\\dfn\>"
80syn match rhelpType		"\\cite\>"
81syn match rhelpType		"\\acronym\>"
82
83" rhelp sections {{{1
84syn match rhelpSection		"\\encoding\>"
85syn match rhelpSection		"\\title\>"
86syn match rhelpSection		"\\description\>"
87syn match rhelpSection		"\\concept\>"
88syn match rhelpSection		"\\arguments\>"
89syn match rhelpSection		"\\details\>"
90syn match rhelpSection		"\\value\>"
91syn match rhelpSection		"\\references\>"
92syn match rhelpSection		"\\note\>"
93syn match rhelpSection		"\\author\>"
94syn match rhelpSection		"\\seealso\>"
95syn match rhelpSection		"\\keyword\>"
96syn match rhelpSection		"\\docType\>"
97syn match rhelpSection		"\\format\>"
98syn match rhelpSection		"\\source\>"
99syn match rhelpSection     "\\itemize\>"
100syn match rhelpSection     "\\describe\>"
101syn match rhelpSection     "\\enumerate\>"
102syn match rhelpSection     "\\item "
103syn match rhelpSection     "\\item$"
104syn match rhelpSection		"\\tabular{[lcr]*}"
105syn match rhelpSection		"\\dontrun\>"
106syn match rhelpSection		"\\dontshow\>"
107syn match rhelpSection		"\\testonly\>"
108
109" Freely named Sections {{{1
110syn region rhelpFreesec matchgroup=Delimiter start="\\section{" matchgroup=Delimiter transparent end=/}/
111
112" Rd comments {{{1
113syn match rhelpComment /%.*$/ contained
114
115" Error {{{1
116syn region rhelpRegion matchgroup=Delimiter start=/(/ matchgroup=Delimiter end=/)/ transparent contains=ALLBUT,rhelpError,rhelpBraceError,rhelpCurlyError
117syn region rhelpRegion matchgroup=Delimiter start=/{/ matchgroup=Delimiter end=/}/ transparent contains=ALLBUT,rhelpError,rhelpBraceError,rhelpParenError
118syn region rhelpRegion matchgroup=Delimiter start=/\[/ matchgroup=Delimiter end=/]/ transparent contains=ALLBUT,rhelpError,rhelpCurlyError,rhelpParenError
119syn match rhelpError      /[)\]}]/
120syn match rhelpBraceError /[)}]/ contained
121syn match rhelpCurlyError /[)\]]/ contained
122syn match rhelpParenError /[\]}]/ contained
123
124" Define the default highlighting {{{1
125" For version 5.7 and earlier: only when not done already
126" For version 5.8 and later: only when an item doesn't have highlighting yet
127if version >= 508 || !exists("did_rhelp_syntax_inits")
128  if version < 508
129    let did_rhelp_syntax_inits = 1
130    command -nargs=+ HiLink hi link <args>
131  else
132    command -nargs=+ HiLink hi def link <args>
133  endif
134  HiLink rhelpIdentifier  Identifier
135  HiLink rhelpString      String
136  HiLink rhelpKeyword     Keyword
137  HiLink rhelpLink        Underlined
138  HiLink rhelpType	       Type
139  HiLink rhelpSection     PreCondit
140  HiLink rhelpError       Error
141  HiLink rhelpBraceError  Error
142  HiLink rhelpCurlyError  Error
143  HiLink rhelpParenError  Error
144  HiLink rhelpDelimiter   Delimiter
145  HiLink rhelpComment     Comment
146  HiLink rhelpRComment    Comment
147  HiLink rhelpSpecialChar SpecialChar
148  delcommand HiLink
149endif
150
151let   b:current_syntax = "rhelp"
152" vim: foldmethod=marker:
153