1" Vim syntax file 2" Language: R Help File 3" Maintainer: Jakson Aquino <[email protected]> 4" Former Maintainer: Johannes Ranke <[email protected]> 5" Last Change: Fri Oct 14, 2011 09:54PM 6" Version: 0.7.4 7" SVN: $Id: rhelp.vim 90 2010-11-22 10:58:11Z ranke $ 8" Remarks: - Includes R syntax highlighting in the appropriate 9" sections if an r.vim file is in the same directory or in the 10" default debian location. 11" - There is no Latex markup in equations 12" - Thanks to Will Gray for finding and fixing a bug 13" - No support for \if, \ifelse and \out as I don't understand 14" them and have no examples at hand (help welcome). 15" - No support for \var tag within quoted string (dito) 16 17" Version Clears: {{{1 18" For version 5.x: Clear all syntax items 19" For version 6.x and 7.x: Quit when a syntax file was already loaded 20if version < 600 21 syntax clear 22elseif exists("b:current_syntax") 23 finish 24endif 25 26syn case match 27 28" R help identifiers {{{1 29syn region rhelpIdentifier matchgroup=rhelpSection start="\\name{" end="}" 30syn region rhelpIdentifier matchgroup=rhelpSection start="\\alias{" end="}" 31syn region rhelpIdentifier matchgroup=rhelpSection start="\\pkg{" end="}" contains=rhelpLink 32syn region rhelpIdentifier matchgroup=rhelpSection start="\\method{" end="}" contained 33syn region rhelpIdentifier matchgroup=rhelpSection start="\\Rdversion{" end="}" 34 35" Highlighting of R code using an existing r.vim syntax file if available {{{1 36syn include @R syntax/r.vim 37 38" Strings {{{1 39syn region rhelpString start=/"/ skip=/\\"/ end=/"/ contains=rhelpSpecialChar,rhelpCodeSpecial,rhelpLink contained 40 41" Special characters in R strings 42syn match rhelpCodeSpecial display contained "\\\\\(n\|r\|t\|b\|a\|f\|v\|'\|\"\)\|\\\\" 43 44" Special characters ( \$ \& \% \# \{ \} \_) 45syn match rhelpSpecialChar "\\[$&%#{}_]" 46 47 48" R code {{{1 49syn match rhelpDots "\\dots" containedin=@R 50syn region rhelpRcode matchgroup=Delimiter start="\\examples{" matchgroup=Delimiter transparent end="}" contains=@R,rhelpLink,rhelpIdentifier,rhelpString,rhelpSpecialChar,rhelpSection 51syn region rhelpRcode matchgroup=Delimiter start="\\usage{" matchgroup=Delimiter transparent end="}" contains=@R,rhelpIdentifier,rhelpS4method 52syn region rhelpRcode matchgroup=Delimiter start="\\synopsis{" matchgroup=Delimiter transparent end="}" contains=@R 53syn region rhelpRcode matchgroup=Delimiter start="\\special{" matchgroup=Delimiter transparent end="}" contains=@R 54syn region rhelpRcode matchgroup=Delimiter start="\\code{" skip='\\\@<!{.\{-}\\\@<!}' transparent end="}" contains=@R,rhelpDots,rhelpString,rhelpSpecialChar,rhelpLink keepend 55syn region rhelpS4method matchgroup=Delimiter start="\\S4method{.*}(" matchgroup=Delimiter transparent end=")" contains=@R,rhelpDots 56syn region rhelpSexpr matchgroup=Delimiter start="\\Sexpr{" matchgroup=Delimiter transparent end="}" contains=@R 57 58" PreProc {{{1 59syn match rhelpPreProc "^#ifdef.*" 60syn match rhelpPreProc "^#endif.*" 61 62" Special Delimiters {{{1 63syn match rhelpDelimiter "\\cr" 64syn match rhelpDelimiter "\\tab " 65 66" Keywords {{{1 67syn match rhelpKeyword "\\R" 68syn match rhelpKeyword "\\ldots" 69syn match rhelpKeyword "--" 70syn match rhelpKeyword "---" 71syn match rhelpKeyword "<" 72syn match rhelpKeyword ">" 73syn match rhelpKeyword "\\ge" 74syn match rhelpKeyword "\\le" 75syn match rhelpKeyword "\\alpha" 76syn match rhelpKeyword "\\beta" 77syn match rhelpKeyword "\\gamma" 78syn match rhelpKeyword "\\delta" 79syn match rhelpKeyword "\\epsilon" 80syn match rhelpKeyword "\\zeta" 81syn match rhelpKeyword "\\eta" 82syn match rhelpKeyword "\\theta" 83syn match rhelpKeyword "\\iota" 84syn match rhelpKeyword "\\kappa" 85syn match rhelpKeyword "\\lambda" 86syn match rhelpKeyword "\\mu" 87syn match rhelpKeyword "\\nu" 88syn match rhelpKeyword "\\xi" 89syn match rhelpKeyword "\\omicron" 90syn match rhelpKeyword "\\pi" 91syn match rhelpKeyword "\\rho" 92syn match rhelpKeyword "\\sigma" 93syn match rhelpKeyword "\\tau" 94syn match rhelpKeyword "\\upsilon" 95syn match rhelpKeyword "\\phi" 96syn match rhelpKeyword "\\chi" 97syn match rhelpKeyword "\\psi" 98syn match rhelpKeyword "\\omega" 99syn match rhelpKeyword "\\Alpha" 100syn match rhelpKeyword "\\Beta" 101syn match rhelpKeyword "\\Gamma" 102syn match rhelpKeyword "\\Delta" 103syn match rhelpKeyword "\\Epsilon" 104syn match rhelpKeyword "\\Zeta" 105syn match rhelpKeyword "\\Eta" 106syn match rhelpKeyword "\\Theta" 107syn match rhelpKeyword "\\Iota" 108syn match rhelpKeyword "\\Kappa" 109syn match rhelpKeyword "\\Lambda" 110syn match rhelpKeyword "\\Mu" 111syn match rhelpKeyword "\\Nu" 112syn match rhelpKeyword "\\Xi" 113syn match rhelpKeyword "\\Omicron" 114syn match rhelpKeyword "\\Pi" 115syn match rhelpKeyword "\\Rho" 116syn match rhelpKeyword "\\Sigma" 117syn match rhelpKeyword "\\Tau" 118syn match rhelpKeyword "\\Upsilon" 119syn match rhelpKeyword "\\Phi" 120syn match rhelpKeyword "\\Chi" 121syn match rhelpKeyword "\\Psi" 122syn match rhelpKeyword "\\Omega" 123 124" Links {{{1 125syn region rhelpLink matchgroup=rhelpSection start="\\link{" end="}" contained keepend extend 126syn region rhelpLink matchgroup=rhelpSection start="\\link\[.\{-}\]{" end="}" contained keepend extend 127syn region rhelpLink matchgroup=rhelpSection start="\\linkS4class{" end="}" contained keepend extend 128 129" Verbatim like {{{1 130syn region rhelpVerbatim matchgroup=rhelpType start="\\samp{" skip='\\\@<!{.\{-}\\\@<!}' end="}" contains=rhelpSpecialChar,rhelpComment 131syn region rhelpVerbatim matchgroup=rhelpType start="\\verb{" skip='\\\@<!{.\{-}\\\@<!}' end="}" contains=rhelpSpecialChar,rhelpComment 132 133" Type Styles {{{1 134syn match rhelpType "\\emph\>" 135syn match rhelpType "\\strong\>" 136syn match rhelpType "\\bold\>" 137syn match rhelpType "\\sQuote\>" 138syn match rhelpType "\\dQuote\>" 139syn match rhelpType "\\preformatted\>" 140syn match rhelpType "\\kbd\>" 141syn match rhelpType "\\eqn\>" 142syn match rhelpType "\\deqn\>" 143syn match rhelpType "\\file\>" 144syn match rhelpType "\\email\>" 145syn match rhelpType "\\url\>" 146syn match rhelpType "\\href\>" 147syn match rhelpType "\\var\>" 148syn match rhelpType "\\env\>" 149syn match rhelpType "\\option\>" 150syn match rhelpType "\\command\>" 151syn match rhelpType "\\newcommand\>" 152syn match rhelpType "\\renewcommand\>" 153syn match rhelpType "\\dfn\>" 154syn match rhelpType "\\cite\>" 155syn match rhelpType "\\acronym\>" 156 157" rhelp sections {{{1 158syn match rhelpSection "\\encoding\>" 159syn match rhelpSection "\\title\>" 160syn match rhelpSection "\\item\>" 161syn match rhelpSection "\\description\>" 162syn match rhelpSection "\\concept\>" 163syn match rhelpSection "\\arguments\>" 164syn match rhelpSection "\\details\>" 165syn match rhelpSection "\\value\>" 166syn match rhelpSection "\\references\>" 167syn match rhelpSection "\\note\>" 168syn match rhelpSection "\\author\>" 169syn match rhelpSection "\\seealso\>" 170syn match rhelpSection "\\keyword\>" 171syn match rhelpSection "\\docType\>" 172syn match rhelpSection "\\format\>" 173syn match rhelpSection "\\source\>" 174syn match rhelpSection "\\itemize\>" 175syn match rhelpSection "\\describe\>" 176syn match rhelpSection "\\enumerate\>" 177syn match rhelpSection "\\item " 178syn match rhelpSection "\\item$" 179syn match rhelpSection "\\tabular{[lcr]*}" 180syn match rhelpSection "\\dontrun\>" 181syn match rhelpSection "\\dontshow\>" 182syn match rhelpSection "\\testonly\>" 183syn match rhelpSection "\\donttest\>" 184 185" Freely named Sections {{{1 186syn region rhelpFreesec matchgroup=Delimiter start="\\section{" matchgroup=Delimiter transparent end="}" 187syn region rhelpFreesubsec matchgroup=Delimiter start="\\subsection{" matchgroup=Delimiter transparent end="}" 188 189syn match rhelpDelimiter "{\|\[\|(\|)\|\]\|}" 190 191" R help file comments {{{1 192syn match rhelpComment /%.*$/ 193 194" Error {{{1 195syn region rhelpRegion matchgroup=Delimiter start=/(/ matchgroup=Delimiter end=/)/ contains=@Spell,rhelpCodeSpecial,rhelpComment,rhelpDelimiter,rhelpDots,rhelpFreesec,rhelpFreesubsec,rhelpIdentifier,rhelpKeyword,rhelpLink,rhelpPreProc,rhelpRComment,rhelpRcode,rhelpRegion,rhelpS4method,rhelpSection,rhelpSexpr,rhelpSpecialChar,rhelpString,rhelpType,rhelpVerbatim 196syn region rhelpRegion matchgroup=Delimiter start=/{/ matchgroup=Delimiter end=/}/ contains=@Spell,rhelpCodeSpecial,rhelpComment,rhelpDelimiter,rhelpDots,rhelpFreesec,rhelpFreesubsec,rhelpIdentifier,rhelpKeyword,rhelpLink,rhelpPreProc,rhelpRComment,rhelpRcode,rhelpRegion,rhelpS4method,rhelpSection,rhelpSexpr,rhelpSpecialChar,rhelpString,rhelpType,rhelpVerbatim 197syn region rhelpRegion matchgroup=Delimiter start=/\[/ matchgroup=Delimiter end=/]/ contains=@Spell,rhelpCodeSpecial,rhelpComment,rhelpDelimiter,rhelpDots,rhelpFreesec,rhelpFreesubsec,rhelpIdentifier,rhelpKeyword,rhelpLink,rhelpPreProc,rhelpRComment,rhelpRcode,rhelpRegion,rhelpS4method,rhelpSection,rhelpSexpr,rhelpSpecialChar,rhelpString,rhelpType,rhelpVerbatim 198syn match rhelpError /[)\]}]/ 199syn match rhelpBraceError /[)}]/ contained 200syn match rhelpCurlyError /[)\]]/ contained 201syn match rhelpParenError /[\]}]/ contained 202 203" Define the default highlighting {{{1 204" For version 5.7 and earlier: only when not done already 205" For version 5.8 and later: only when an item doesn't have highlighting yet 206if version >= 508 || !exists("did_rhelp_syntax_inits") 207 if version < 508 208 let did_rhelp_syntax_inits = 1 209 command -nargs=+ HiLink hi link <args> 210 else 211 command -nargs=+ HiLink hi def link <args> 212 endif 213 HiLink rhelpVerbatim String 214 HiLink rhelpDelimiter Delimiter 215 HiLink rhelpIdentifier Identifier 216 HiLink rhelpString String 217 HiLink rhelpCodeSpecial Special 218 HiLink rhelpKeyword Keyword 219 HiLink rhelpDots Keyword 220 HiLink rhelpLink Underlined 221 HiLink rhelpType Type 222 HiLink rhelpSection PreCondit 223 HiLink rhelpError Error 224 HiLink rhelpBraceError Error 225 HiLink rhelpCurlyError Error 226 HiLink rhelpParenError Error 227 HiLink rhelpPreProc PreProc 228 HiLink rhelpDelimiter Delimiter 229 HiLink rhelpComment Comment 230 HiLink rhelpRComment Comment 231 HiLink rhelpSpecialChar SpecialChar 232 delcommand HiLink 233endif 234 235let b:current_syntax = "rhelp" 236" vim: foldmethod=marker: 237