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