Bram Moolenaar | 362e1a3 | 2006-03-06 23:29:24 +0000 | [diff] [blame] | 1 | " Vim syntax file |
| 2 | " Language: R Help File |
| 3 | " Maintainer: Johannes Ranke <jranke@uni-bremen.de> |
Bram Moolenaar | 5c73622 | 2010-01-06 20:54:52 +0100 | [diff] [blame] | 4 | " Last Change: 2009 Mai 12 |
| 5 | " Version: 0.7.2 |
| 6 | " SVN: $Id: rhelp.vim 86 2009-05-12 19:23:47Z ranke $ |
Bram Moolenaar | 362e1a3 | 2006-03-06 23:29:24 +0000 | [diff] [blame] | 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. |
Bram Moolenaar | 362e1a3 | 2006-03-06 23:29:24 +0000 | [diff] [blame] | 10 | " - There is no Latex markup in equations |
Bram Moolenaar | 5c73622 | 2010-01-06 20:54:52 +0100 | [diff] [blame] | 11 | " - Thanks to Will Gray for finding and fixing a bug |
Bram Moolenaar | 362e1a3 | 2006-03-06 23:29:24 +0000 | [diff] [blame] | 12 | |
| 13 | " Version Clears: {{{1 |
| 14 | " For version 5.x: Clear all syntax items |
Bram Moolenaar | 910f66f | 2006-04-05 20:41:53 +0000 | [diff] [blame] | 15 | " 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] | 16 | if version < 600 |
| 17 | syntax clear |
| 18 | elseif exists("b:current_syntax") |
| 19 | finish |
| 20 | endif |
| 21 | |
| 22 | syn case match |
| 23 | |
Bram Moolenaar | f9393ef | 2006-04-24 19:47:27 +0000 | [diff] [blame] | 24 | " R help identifiers {{{ |
Bram Moolenaar | 362e1a3 | 2006-03-06 23:29:24 +0000 | [diff] [blame] | 25 | syn region rhelpIdentifier matchgroup=rhelpSection start="\\name{" end="}" |
| 26 | syn region rhelpIdentifier matchgroup=rhelpSection start="\\alias{" end="}" |
| 27 | syn region rhelpIdentifier matchgroup=rhelpSection start="\\pkg{" end="}" |
Bram Moolenaar | f9393ef | 2006-04-24 19:47:27 +0000 | [diff] [blame] | 28 | syn region rhelpIdentifier matchgroup=rhelpSection start="\\item{" end="}" contained contains=rhelpDots |
Bram Moolenaar | 362e1a3 | 2006-03-06 23:29:24 +0000 | [diff] [blame] | 29 | syn region rhelpIdentifier matchgroup=rhelpSection start="\\method{" end=/}/ contained |
| 30 | |
| 31 | " 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] | 32 | syn include @R syntax/r.vim |
Bram Moolenaar | f9393ef | 2006-04-24 19:47:27 +0000 | [diff] [blame] | 33 | syn match rhelpDots "\\dots" containedin=@R |
Bram Moolenaar | 362e1a3 | 2006-03-06 23:29:24 +0000 | [diff] [blame] | 34 | syn region rhelpRcode matchgroup=Delimiter start="\\examples{" matchgroup=Delimiter transparent end=/}/ contains=@R,rhelpSection |
Bram Moolenaar | f9393ef | 2006-04-24 19:47:27 +0000 | [diff] [blame] | 35 | syn region rhelpRcode matchgroup=Delimiter start="\\usage{" matchgroup=Delimiter transparent end=/}/ contains=@R,rhelpIdentifier,rhelpS4method |
Bram Moolenaar | 362e1a3 | 2006-03-06 23:29:24 +0000 | [diff] [blame] | 36 | syn region rhelpRcode matchgroup=Delimiter start="\\synopsis{" matchgroup=Delimiter transparent end=/}/ contains=@R |
| 37 | syn region rhelpRcode matchgroup=Delimiter start="\\special{" matchgroup=Delimiter transparent end=/}/ contains=@R contained |
Bram Moolenaar | 910f66f | 2006-04-05 20:41:53 +0000 | [diff] [blame] | 38 | syn region rhelpRcode matchgroup=Delimiter start="\\code{" matchgroup=Delimiter transparent end=/}/ contains=@R,rhelpLink contained |
Bram Moolenaar | f9393ef | 2006-04-24 19:47:27 +0000 | [diff] [blame] | 39 | syn region rhelpS4method matchgroup=Delimiter start="\\S4method{.*}(" matchgroup=Delimiter transparent end=/)/ contains=@R,rhelpDots contained |
Bram Moolenaar | 362e1a3 | 2006-03-06 23:29:24 +0000 | [diff] [blame] | 40 | |
| 41 | " Strings {{{1 |
| 42 | syn region rhelpString start=/"/ end=/"/ |
| 43 | |
Bram Moolenaar | 910f66f | 2006-04-05 20:41:53 +0000 | [diff] [blame] | 44 | " Special characters ( \$ \& \% \# \{ \} \_) {{{1 |
Bram Moolenaar | 362e1a3 | 2006-03-06 23:29:24 +0000 | [diff] [blame] | 45 | syn match rhelpSpecialChar "\\[$&%#{}_]" |
| 46 | |
| 47 | " Special Delimiters {{{1 |
| 48 | syn match rhelpDelimiter "\\cr" |
| 49 | syn match rhelpDelimiter "\\tab " |
| 50 | |
| 51 | " Keywords {{{1 |
| 52 | syn match rhelpKeyword "\\R" |
Bram Moolenaar | 362e1a3 | 2006-03-06 23:29:24 +0000 | [diff] [blame] | 53 | syn match rhelpKeyword "\\ldots" |
Bram Moolenaar | f9393ef | 2006-04-24 19:47:27 +0000 | [diff] [blame] | 54 | syn match rhelpKeyword "--" |
| 55 | syn match rhelpKeyword "---" |
| 56 | syn match rhelpKeyword "<" |
| 57 | syn match rhelpKeyword ">" |
Bram Moolenaar | 362e1a3 | 2006-03-06 23:29:24 +0000 | [diff] [blame] | 58 | |
| 59 | " Links {{{1 |
| 60 | syn region rhelpLink matchgroup=rhelpSection start="\\link{" end="}" contained keepend |
Bram Moolenaar | 5c73622 | 2010-01-06 20:54:52 +0100 | [diff] [blame] | 61 | syn region rhelpLink matchgroup=rhelpSection start="\\link\[.\{-}\]{" end="}" contained keepend |
Bram Moolenaar | f9393ef | 2006-04-24 19:47:27 +0000 | [diff] [blame] | 62 | syn region rhelpLink matchgroup=rhelpSection start="\\linkS4class{" end="}" contained keepend |
Bram Moolenaar | 362e1a3 | 2006-03-06 23:29:24 +0000 | [diff] [blame] | 63 | |
| 64 | " Type Styles {{{1 |
| 65 | syn match rhelpType "\\emph\>" |
| 66 | syn match rhelpType "\\strong\>" |
| 67 | syn match rhelpType "\\bold\>" |
| 68 | syn match rhelpType "\\sQuote\>" |
| 69 | syn match rhelpType "\\dQuote\>" |
| 70 | syn match rhelpType "\\preformatted\>" |
| 71 | syn match rhelpType "\\kbd\>" |
| 72 | syn match rhelpType "\\samp\>" |
| 73 | syn match rhelpType "\\eqn\>" |
| 74 | syn match rhelpType "\\deqn\>" |
| 75 | syn match rhelpType "\\file\>" |
| 76 | syn match rhelpType "\\email\>" |
| 77 | syn match rhelpType "\\url\>" |
| 78 | syn match rhelpType "\\var\>" |
| 79 | syn match rhelpType "\\env\>" |
| 80 | syn match rhelpType "\\option\>" |
| 81 | syn match rhelpType "\\command\>" |
| 82 | syn match rhelpType "\\dfn\>" |
| 83 | syn match rhelpType "\\cite\>" |
| 84 | syn match rhelpType "\\acronym\>" |
| 85 | |
| 86 | " rhelp sections {{{1 |
| 87 | syn match rhelpSection "\\encoding\>" |
| 88 | syn match rhelpSection "\\title\>" |
| 89 | syn match rhelpSection "\\description\>" |
| 90 | syn match rhelpSection "\\concept\>" |
| 91 | syn match rhelpSection "\\arguments\>" |
| 92 | syn match rhelpSection "\\details\>" |
| 93 | syn match rhelpSection "\\value\>" |
| 94 | syn match rhelpSection "\\references\>" |
| 95 | syn match rhelpSection "\\note\>" |
| 96 | syn match rhelpSection "\\author\>" |
| 97 | syn match rhelpSection "\\seealso\>" |
| 98 | syn match rhelpSection "\\keyword\>" |
| 99 | syn match rhelpSection "\\docType\>" |
| 100 | syn match rhelpSection "\\format\>" |
| 101 | syn match rhelpSection "\\source\>" |
| 102 | syn match rhelpSection "\\itemize\>" |
| 103 | syn match rhelpSection "\\describe\>" |
| 104 | syn match rhelpSection "\\enumerate\>" |
| 105 | syn match rhelpSection "\\item " |
| 106 | syn match rhelpSection "\\item$" |
| 107 | syn match rhelpSection "\\tabular{[lcr]*}" |
| 108 | syn match rhelpSection "\\dontrun\>" |
| 109 | syn match rhelpSection "\\dontshow\>" |
| 110 | syn match rhelpSection "\\testonly\>" |
Bram Moolenaar | 446cb83 | 2008-06-24 21:56:24 +0000 | [diff] [blame] | 111 | syn match rhelpSection "\\donttest\>" |
Bram Moolenaar | 362e1a3 | 2006-03-06 23:29:24 +0000 | [diff] [blame] | 112 | |
| 113 | " Freely named Sections {{{1 |
| 114 | syn region rhelpFreesec matchgroup=Delimiter start="\\section{" matchgroup=Delimiter transparent end=/}/ |
| 115 | |
Bram Moolenaar | f9393ef | 2006-04-24 19:47:27 +0000 | [diff] [blame] | 116 | " R help file comments {{{1 |
Bram Moolenaar | 362e1a3 | 2006-03-06 23:29:24 +0000 | [diff] [blame] | 117 | syn match rhelpComment /%.*$/ contained |
| 118 | |
| 119 | " Error {{{1 |
| 120 | syn region rhelpRegion matchgroup=Delimiter start=/(/ matchgroup=Delimiter end=/)/ transparent contains=ALLBUT,rhelpError,rhelpBraceError,rhelpCurlyError |
| 121 | syn region rhelpRegion matchgroup=Delimiter start=/{/ matchgroup=Delimiter end=/}/ transparent contains=ALLBUT,rhelpError,rhelpBraceError,rhelpParenError |
| 122 | syn region rhelpRegion matchgroup=Delimiter start=/\[/ matchgroup=Delimiter end=/]/ transparent contains=ALLBUT,rhelpError,rhelpCurlyError,rhelpParenError |
| 123 | syn match rhelpError /[)\]}]/ |
| 124 | syn match rhelpBraceError /[)}]/ contained |
| 125 | syn match rhelpCurlyError /[)\]]/ contained |
| 126 | syn match rhelpParenError /[\]}]/ contained |
| 127 | |
| 128 | " Define the default highlighting {{{1 |
| 129 | " For version 5.7 and earlier: only when not done already |
| 130 | " For version 5.8 and later: only when an item doesn't have highlighting yet |
| 131 | if version >= 508 || !exists("did_rhelp_syntax_inits") |
| 132 | if version < 508 |
| 133 | let did_rhelp_syntax_inits = 1 |
| 134 | command -nargs=+ HiLink hi link <args> |
| 135 | else |
| 136 | command -nargs=+ HiLink hi def link <args> |
| 137 | endif |
| 138 | HiLink rhelpIdentifier Identifier |
| 139 | HiLink rhelpString String |
| 140 | HiLink rhelpKeyword Keyword |
Bram Moolenaar | f9393ef | 2006-04-24 19:47:27 +0000 | [diff] [blame] | 141 | HiLink rhelpDots Keyword |
Bram Moolenaar | 362e1a3 | 2006-03-06 23:29:24 +0000 | [diff] [blame] | 142 | HiLink rhelpLink Underlined |
Bram Moolenaar | f9393ef | 2006-04-24 19:47:27 +0000 | [diff] [blame] | 143 | HiLink rhelpType Type |
Bram Moolenaar | 362e1a3 | 2006-03-06 23:29:24 +0000 | [diff] [blame] | 144 | HiLink rhelpSection PreCondit |
| 145 | HiLink rhelpError Error |
| 146 | HiLink rhelpBraceError Error |
| 147 | HiLink rhelpCurlyError Error |
| 148 | HiLink rhelpParenError Error |
| 149 | HiLink rhelpDelimiter Delimiter |
| 150 | HiLink rhelpComment Comment |
| 151 | HiLink rhelpRComment Comment |
| 152 | HiLink rhelpSpecialChar SpecialChar |
| 153 | delcommand HiLink |
| 154 | endif |
| 155 | |
| 156 | let b:current_syntax = "rhelp" |
| 157 | " vim: foldmethod=marker: |