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