Merged from the latest developing branch.
[MacVim/KaoriYa.git] / runtime / syntax / rhelp.vim
blob90e2d1941b982b6e80deba220009b862832da782
1 " Vim syntax file
2 " Language:    R Help File
3 " Maintainer:  Johannes Ranke <jranke@uni-bremen.de>
4 " Last Change: 2006 Apr 24
5 " Version:     0.7
6 " SVN:             $Id: rhelp.vim,v 1.4 2006/04/24 19:33:52 vimboss Exp $
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
12 " Version Clears: {{{1
13 " For version 5.x: Clear all syntax items
14 " For version 6.x and 7.x: Quit when a syntax file was already loaded
15 if version < 600 
16   syntax clear
17 elseif exists("b:current_syntax")
18   finish
19 endif 
21 syn case match
23 " R help identifiers {{{
24 syn region rhelpIdentifier matchgroup=rhelpSection      start="\\name{" end="}" 
25 syn region rhelpIdentifier matchgroup=rhelpSection      start="\\alias{" end="}" 
26 syn region rhelpIdentifier matchgroup=rhelpSection      start="\\pkg{" end="}" 
27 syn region rhelpIdentifier matchgroup=rhelpSection      start="\\item{" end="}" contained contains=rhelpDots
28 syn region rhelpIdentifier matchgroup=rhelpSection start="\\method{" end=/}/ contained
30 " Highlighting of R code using an existing r.vim syntax file if available {{{1
31 syn include @R syntax/r.vim
32 syn match rhelpDots             "\\dots" containedin=@R
33 syn region rhelpRcode matchgroup=Delimiter start="\\examples{" matchgroup=Delimiter transparent end=/}/ contains=@R,rhelpSection
34 syn region rhelpRcode matchgroup=Delimiter start="\\usage{" matchgroup=Delimiter transparent end=/}/ contains=@R,rhelpIdentifier,rhelpS4method
35 syn region rhelpRcode matchgroup=Delimiter start="\\synopsis{" matchgroup=Delimiter transparent end=/}/ contains=@R
36 syn region rhelpRcode matchgroup=Delimiter start="\\special{" matchgroup=Delimiter transparent end=/}/ contains=@R contained
37 syn region rhelpRcode matchgroup=Delimiter start="\\code{" matchgroup=Delimiter transparent end=/}/ contains=@R,rhelpLink contained
38 syn region rhelpS4method matchgroup=Delimiter start="\\S4method{.*}(" matchgroup=Delimiter transparent end=/)/ contains=@R,rhelpDots contained
40 " Strings {{{1
41 syn region rhelpString start=/"/ end=/"/ 
43 " Special characters  ( \$ \& \% \# \{ \} \_) {{{1
44 syn match rhelpSpecialChar        "\\[$&%#{}_]"
46 " Special Delimiters {{{1
47 syn match rhelpDelimiter                "\\cr"
48 syn match rhelpDelimiter                "\\tab "
50 " Keywords {{{1
51 syn match rhelpKeyword  "\\R"
52 syn match rhelpKeyword  "\\ldots"
53 syn match rhelpKeyword  "--"
54 syn match rhelpKeyword  "---"
55 syn match rhelpKeyword  "<"
56 syn match rhelpKeyword  ">"
58 " Links {{{1
59 syn region rhelpLink matchgroup=rhelpSection start="\\link{" end="}" contained keepend
60 syn region rhelpLink matchgroup=rhelpSection start="\\link\[.*\]{" end="}" contained keepend
61 syn region rhelpLink matchgroup=rhelpSection start="\\linkS4class{" end="}" contained keepend
63 " Type Styles {{{1
64 syn match rhelpType             "\\emph\>"
65 syn match rhelpType             "\\strong\>"
66 syn match rhelpType             "\\bold\>"
67 syn match rhelpType             "\\sQuote\>"
68 syn match rhelpType             "\\dQuote\>"
69 syn match rhelpType             "\\preformatted\>"
70 syn match rhelpType             "\\kbd\>"
71 syn match rhelpType             "\\samp\>"
72 syn match rhelpType             "\\eqn\>"
73 syn match rhelpType             "\\deqn\>"
74 syn match rhelpType             "\\file\>"
75 syn match rhelpType             "\\email\>"
76 syn match rhelpType             "\\url\>"
77 syn match rhelpType             "\\var\>"
78 syn match rhelpType             "\\env\>"
79 syn match rhelpType             "\\option\>"
80 syn match rhelpType             "\\command\>"
81 syn match rhelpType             "\\dfn\>"
82 syn match rhelpType             "\\cite\>"
83 syn match rhelpType             "\\acronym\>"
85 " rhelp sections {{{1
86 syn match rhelpSection          "\\encoding\>"
87 syn match rhelpSection          "\\title\>"
88 syn match rhelpSection          "\\description\>"
89 syn match rhelpSection          "\\concept\>"
90 syn match rhelpSection          "\\arguments\>"
91 syn match rhelpSection          "\\details\>"
92 syn match rhelpSection          "\\value\>"
93 syn match rhelpSection          "\\references\>"
94 syn match rhelpSection          "\\note\>"
95 syn match rhelpSection          "\\author\>"
96 syn match rhelpSection          "\\seealso\>"
97 syn match rhelpSection          "\\keyword\>"
98 syn match rhelpSection          "\\docType\>"
99 syn match rhelpSection          "\\format\>"
100 syn match rhelpSection          "\\source\>"
101 syn match rhelpSection     "\\itemize\>"
102 syn match rhelpSection     "\\describe\>"
103 syn match rhelpSection     "\\enumerate\>"
104 syn match rhelpSection     "\\item "
105 syn match rhelpSection     "\\item$"
106 syn match rhelpSection          "\\tabular{[lcr]*}"
107 syn match rhelpSection          "\\dontrun\>"
108 syn match rhelpSection          "\\dontshow\>"
109 syn match rhelpSection          "\\testonly\>"
111 " Freely named Sections {{{1
112 syn region rhelpFreesec matchgroup=Delimiter start="\\section{" matchgroup=Delimiter transparent end=/}/ 
114 " R help file comments {{{1
115 syn match rhelpComment /%.*$/ contained 
117 " Error {{{1
118 syn region rhelpRegion matchgroup=Delimiter start=/(/ matchgroup=Delimiter end=/)/ transparent contains=ALLBUT,rhelpError,rhelpBraceError,rhelpCurlyError
119 syn region rhelpRegion matchgroup=Delimiter start=/{/ matchgroup=Delimiter end=/}/ transparent contains=ALLBUT,rhelpError,rhelpBraceError,rhelpParenError
120 syn region rhelpRegion matchgroup=Delimiter start=/\[/ matchgroup=Delimiter end=/]/ transparent contains=ALLBUT,rhelpError,rhelpCurlyError,rhelpParenError
121 syn match rhelpError      /[)\]}]/
122 syn match rhelpBraceError /[)}]/ contained
123 syn match rhelpCurlyError /[)\]]/ contained
124 syn match rhelpParenError /[\]}]/ contained
126 " Define the default highlighting {{{1
127 " For version 5.7 and earlier: only when not done already
128 " For version 5.8 and later: only when an item doesn't have highlighting yet
129 if version >= 508 || !exists("did_rhelp_syntax_inits")
130   if version < 508
131     let did_rhelp_syntax_inits = 1
132     command -nargs=+ HiLink hi link <args>
133   else
134     command -nargs=+ HiLink hi def link <args>
135   endif
136   HiLink rhelpIdentifier  Identifier
137   HiLink rhelpString      String
138   HiLink rhelpKeyword     Keyword
139   HiLink rhelpDots        Keyword
140   HiLink rhelpLink        Underlined
141   HiLink rhelpType            Type
142   HiLink rhelpSection     PreCondit
143   HiLink rhelpError       Error
144   HiLink rhelpBraceError  Error
145   HiLink rhelpCurlyError  Error
146   HiLink rhelpParenError  Error
147   HiLink rhelpDelimiter   Delimiter
148   HiLink rhelpComment     Comment
149   HiLink rhelpRComment    Comment
150   HiLink rhelpSpecialChar SpecialChar
151   delcommand HiLink
152 endif 
154 let   b:current_syntax = "rhelp"
155 " vim: foldmethod=marker: