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