1" Vim syntax file 2" Language: R Help File 3" Maintainer: Johannes Ranke <[email protected]> 4" Last Change: 2010 Apr 22 5" Version: 0.7.3 6" SVN: $Id: rhelp.vim 88 2010-04-22 19:37:09Z 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" - 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="\\item{" end="}" contained contains=rhelpDots 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 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" 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 "\\var\>" 133syn match rhelpType "\\env\>" 134syn match rhelpType "\\option\>" 135syn match rhelpType "\\command\>" 136syn match rhelpType "\\dfn\>" 137syn match rhelpType "\\cite\>" 138syn match rhelpType "\\acronym\>" 139 140" rhelp sections {{{1 141syn match rhelpSection "\\encoding\>" 142syn match rhelpSection "\\title\>" 143syn match rhelpSection "\\description\>" 144syn match rhelpSection "\\concept\>" 145syn match rhelpSection "\\arguments\>" 146syn match rhelpSection "\\details\>" 147syn match rhelpSection "\\value\>" 148syn match rhelpSection "\\references\>" 149syn match rhelpSection "\\note\>" 150syn match rhelpSection "\\author\>" 151syn match rhelpSection "\\seealso\>" 152syn match rhelpSection "\\keyword\>" 153syn match rhelpSection "\\docType\>" 154syn match rhelpSection "\\format\>" 155syn match rhelpSection "\\source\>" 156syn match rhelpSection "\\itemize\>" 157syn match rhelpSection "\\describe\>" 158syn match rhelpSection "\\enumerate\>" 159syn match rhelpSection "\\item " 160syn match rhelpSection "\\item$" 161syn match rhelpSection "\\tabular{[lcr]*}" 162syn match rhelpSection "\\dontrun\>" 163syn match rhelpSection "\\dontshow\>" 164syn match rhelpSection "\\testonly\>" 165syn match rhelpSection "\\donttest\>" 166 167" Freely named Sections {{{1 168syn region rhelpFreesec matchgroup=Delimiter start="\\section{" matchgroup=Delimiter transparent end=/}/ 169syn region rhelpFreesubsec matchgroup=Delimiter start="\\subsection{" matchgroup=Delimiter transparent end=/}/ 170 171" R help file comments {{{1 172syn match rhelpComment /%.*$/ contained 173 174" Error {{{1 175syn region rhelpRegion matchgroup=Delimiter start=/(/ matchgroup=Delimiter end=/)/ transparent contains=ALLBUT,rhelpError,rhelpBraceError,rhelpCurlyError 176syn region rhelpRegion matchgroup=Delimiter start=/{/ matchgroup=Delimiter end=/}/ transparent contains=ALLBUT,rhelpError,rhelpBraceError,rhelpParenError 177syn region rhelpRegion matchgroup=Delimiter start=/\[/ matchgroup=Delimiter end=/]/ transparent contains=ALLBUT,rhelpError,rhelpCurlyError,rhelpParenError 178syn match rhelpError /[)\]}]/ 179syn match rhelpBraceError /[)}]/ contained 180syn match rhelpCurlyError /[)\]]/ contained 181syn match rhelpParenError /[\]}]/ contained 182 183" Define the default highlighting {{{1 184" For version 5.7 and earlier: only when not done already 185" For version 5.8 and later: only when an item doesn't have highlighting yet 186if version >= 508 || !exists("did_rhelp_syntax_inits") 187 if version < 508 188 let did_rhelp_syntax_inits = 1 189 command -nargs=+ HiLink hi link <args> 190 else 191 command -nargs=+ HiLink hi def link <args> 192 endif 193 HiLink rhelpIdentifier Identifier 194 HiLink rhelpString String 195 HiLink rhelpKeyword Keyword 196 HiLink rhelpDots Keyword 197 HiLink rhelpLink Underlined 198 HiLink rhelpType Type 199 HiLink rhelpSection PreCondit 200 HiLink rhelpError Error 201 HiLink rhelpBraceError Error 202 HiLink rhelpCurlyError Error 203 HiLink rhelpParenError Error 204 HiLink rhelpDelimiter Delimiter 205 HiLink rhelpComment Comment 206 HiLink rhelpRComment Comment 207 HiLink rhelpSpecialChar SpecialChar 208 delcommand HiLink 209endif 210 211let b:current_syntax = "rhelp" 212" vim: foldmethod=marker: 213