Add support for :winpos
[MacVim.git] / runtime / syntax / rhelp.vim
blobfa585b286864c8c719e844217234bc6b2e877833
1 " Vim syntax file
2 " Language:    R Help File
3 " Maintainer:  Johannes Ranke <jranke@uni-bremen.de>
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
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
16 if version < 600 
17   syntax clear
18 elseif exists("b:current_syntax")
19   finish
20 endif 
22 syn case match
24 " R help identifiers {{{
25 syn region rhelpIdentifier matchgroup=rhelpSection      start="\\name{" end="}" 
26 syn region rhelpIdentifier matchgroup=rhelpSection      start="\\alias{" end="}" 
27 syn region rhelpIdentifier matchgroup=rhelpSection      start="\\pkg{" end="}" 
28 syn region rhelpIdentifier matchgroup=rhelpSection      start="\\item{" end="}" contained contains=rhelpDots
29 syn region rhelpIdentifier matchgroup=rhelpSection start="\\method{" end=/}/ contained
31 " Highlighting of R code using an existing r.vim syntax file if available {{{1
32 syn include @R syntax/r.vim
33 syn match rhelpDots             "\\dots" containedin=@R
34 syn region rhelpRcode matchgroup=Delimiter start="\\examples{" matchgroup=Delimiter transparent end=/}/ contains=@R,rhelpSection
35 syn region rhelpRcode matchgroup=Delimiter start="\\usage{" matchgroup=Delimiter transparent end=/}/ contains=@R,rhelpIdentifier,rhelpS4method
36 syn region rhelpRcode matchgroup=Delimiter start="\\synopsis{" matchgroup=Delimiter transparent end=/}/ contains=@R
37 syn region rhelpRcode matchgroup=Delimiter start="\\special{" matchgroup=Delimiter transparent end=/}/ contains=@R contained
38 syn region rhelpRcode matchgroup=Delimiter start="\\code{" matchgroup=Delimiter transparent end=/}/ contains=@R,rhelpLink contained
39 syn region rhelpS4method matchgroup=Delimiter start="\\S4method{.*}(" matchgroup=Delimiter transparent end=/)/ contains=@R,rhelpDots contained
41 " Strings {{{1
42 syn region rhelpString start=/"/ end=/"/ 
44 " Special characters  ( \$ \& \% \# \{ \} \_) {{{1
45 syn match rhelpSpecialChar        "\\[$&%#{}_]"
47 " Special Delimiters {{{1
48 syn match rhelpDelimiter                "\\cr"
49 syn match rhelpDelimiter                "\\tab "
51 " Keywords {{{1
52 syn match rhelpKeyword  "\\R"
53 syn match rhelpKeyword  "\\ldots"
54 syn match rhelpKeyword  "--"
55 syn match rhelpKeyword  "---"
56 syn match rhelpKeyword  "<"
57 syn match rhelpKeyword  ">"
59 " Links {{{1
60 syn region rhelpLink matchgroup=rhelpSection start="\\link{" end="}" contained keepend
61 syn region rhelpLink matchgroup=rhelpSection start="\\link\[.\{-}\]{" end="}" contained keepend
62 syn region rhelpLink matchgroup=rhelpSection start="\\linkS4class{" end="}" contained keepend
64 " Type Styles {{{1
65 syn match rhelpType             "\\emph\>"
66 syn match rhelpType             "\\strong\>"
67 syn match rhelpType             "\\bold\>"
68 syn match rhelpType             "\\sQuote\>"
69 syn match rhelpType             "\\dQuote\>"
70 syn match rhelpType             "\\preformatted\>"
71 syn match rhelpType             "\\kbd\>"
72 syn match rhelpType             "\\samp\>"
73 syn match rhelpType             "\\eqn\>"
74 syn match rhelpType             "\\deqn\>"
75 syn match rhelpType             "\\file\>"
76 syn match rhelpType             "\\email\>"
77 syn match rhelpType             "\\url\>"
78 syn match rhelpType             "\\var\>"
79 syn match rhelpType             "\\env\>"
80 syn match rhelpType             "\\option\>"
81 syn match rhelpType             "\\command\>"
82 syn match rhelpType             "\\dfn\>"
83 syn match rhelpType             "\\cite\>"
84 syn match rhelpType             "\\acronym\>"
86 " rhelp sections {{{1
87 syn match rhelpSection          "\\encoding\>"
88 syn match rhelpSection          "\\title\>"
89 syn match rhelpSection          "\\description\>"
90 syn match rhelpSection          "\\concept\>"
91 syn match rhelpSection          "\\arguments\>"
92 syn match rhelpSection          "\\details\>"
93 syn match rhelpSection          "\\value\>"
94 syn match rhelpSection          "\\references\>"
95 syn match rhelpSection          "\\note\>"
96 syn match rhelpSection          "\\author\>"
97 syn match rhelpSection          "\\seealso\>"
98 syn match rhelpSection          "\\keyword\>"
99 syn match rhelpSection          "\\docType\>"
100 syn match rhelpSection          "\\format\>"
101 syn match rhelpSection          "\\source\>"
102 syn match rhelpSection     "\\itemize\>"
103 syn match rhelpSection     "\\describe\>"
104 syn match rhelpSection     "\\enumerate\>"
105 syn match rhelpSection     "\\item "
106 syn match rhelpSection     "\\item$"
107 syn match rhelpSection          "\\tabular{[lcr]*}"
108 syn match rhelpSection          "\\dontrun\>"
109 syn match rhelpSection          "\\dontshow\>"
110 syn match rhelpSection          "\\testonly\>"
111 syn match rhelpSection          "\\donttest\>"
113 " Freely named Sections {{{1
114 syn region rhelpFreesec matchgroup=Delimiter start="\\section{" matchgroup=Delimiter transparent end=/}/ 
116 " R help file comments {{{1
117 syn match rhelpComment /%.*$/ contained 
119 " Error {{{1
120 syn region rhelpRegion matchgroup=Delimiter start=/(/ matchgroup=Delimiter end=/)/ transparent contains=ALLBUT,rhelpError,rhelpBraceError,rhelpCurlyError
121 syn region rhelpRegion matchgroup=Delimiter start=/{/ matchgroup=Delimiter end=/}/ transparent contains=ALLBUT,rhelpError,rhelpBraceError,rhelpParenError
122 syn region rhelpRegion matchgroup=Delimiter start=/\[/ matchgroup=Delimiter end=/]/ transparent contains=ALLBUT,rhelpError,rhelpCurlyError,rhelpParenError
123 syn match rhelpError      /[)\]}]/
124 syn match rhelpBraceError /[)}]/ contained
125 syn match rhelpCurlyError /[)\]]/ contained
126 syn match rhelpParenError /[\]}]/ contained
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
131 if 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
154 endif 
156 let   b:current_syntax = "rhelp"
157 " vim: foldmethod=marker: