0
0
mirror of https://github.com/vim/vim.git synced 2025-07-04 23:07:33 -04:00
vim/runtime/syntax/rhelp.vim

250 lines
10 KiB
VimL
Raw Normal View History

2006-03-06 23:29:24 +00:00
" Vim syntax file
" Language: R Help File
2011-03-22 14:05:35 +01:00
" Maintainer: Jakson Aquino <jalvesaq@gmail.com>
" Former Maintainer: Johannes Ranke <jranke@uni-bremen.de>
2014-07-10 22:01:47 +02:00
" Last Change: Wed Jul 09, 2014 10:28PM
2010-12-10 20:35:50 +01:00
" Remarks: - Includes R syntax highlighting in the appropriate
2006-03-06 23:29:24 +00:00
" sections if an r.vim file is in the same directory or in the
" default debian location.
" - There is no Latex markup in equations
2010-01-06 20:54:52 +01:00
" - Thanks to Will Gray for finding and fixing a bug
2010-05-14 23:24:24 +02:00
" - No support for \if, \ifelse and \out as I don't understand
" them and have no examples at hand (help welcome).
" - No support for \var tag within quoted string (dito)
2006-03-06 23:29:24 +00:00
" Version Clears: {{{1
" For version 5.x: Clear all syntax items
2006-04-05 20:41:53 +00:00
" For version 6.x and 7.x: Quit when a syntax file was already loaded
2006-03-06 23:29:24 +00:00
if version < 600
syntax clear
elseif exists("b:current_syntax")
finish
endif
2014-07-10 22:01:47 +02:00
setlocal iskeyword=@,48-57,_,.
2006-03-06 23:29:24 +00:00
syn case match
2011-03-22 14:05:35 +01:00
" R help identifiers {{{1
2006-03-06 23:29:24 +00:00
syn region rhelpIdentifier matchgroup=rhelpSection start="\\name{" end="}"
syn region rhelpIdentifier matchgroup=rhelpSection start="\\alias{" end="}"
2011-03-22 14:05:35 +01:00
syn region rhelpIdentifier matchgroup=rhelpSection start="\\pkg{" end="}" contains=rhelpLink
2010-12-10 20:35:50 +01:00
syn region rhelpIdentifier matchgroup=rhelpSection start="\\method{" end="}" contained
syn region rhelpIdentifier matchgroup=rhelpSection start="\\Rdversion{" end="}"
2006-03-06 23:29:24 +00:00
" Highlighting of R code using an existing r.vim syntax file if available {{{1
2006-04-12 21:52:12 +00:00
syn include @R syntax/r.vim
2011-03-22 14:05:35 +01:00
" Strings {{{1
syn region rhelpString start=/"/ skip=/\\"/ end=/"/ contains=rhelpSpecialChar,rhelpCodeSpecial,rhelpLink contained
" Special characters in R strings
syn match rhelpCodeSpecial display contained "\\\\\(n\|r\|t\|b\|a\|f\|v\|'\|\"\)\|\\\\"
" Special characters ( \$ \& \% \# \{ \} \_)
syn match rhelpSpecialChar "\\[$&%#{}_]"
" R code {{{1
2006-04-24 19:47:27 +00:00
syn match rhelpDots "\\dots" containedin=@R
2011-03-22 14:05:35 +01:00
syn region rhelpRcode matchgroup=Delimiter start="\\examples{" matchgroup=Delimiter transparent end="}" contains=@R,rhelpLink,rhelpIdentifier,rhelpString,rhelpSpecialChar,rhelpSection
2010-12-10 20:35:50 +01:00
syn region rhelpRcode matchgroup=Delimiter start="\\usage{" matchgroup=Delimiter transparent end="}" contains=@R,rhelpIdentifier,rhelpS4method
syn region rhelpRcode matchgroup=Delimiter start="\\synopsis{" matchgroup=Delimiter transparent end="}" contains=@R
2011-03-22 14:05:35 +01:00
syn region rhelpRcode matchgroup=Delimiter start="\\special{" matchgroup=Delimiter transparent end="}" contains=@R
2014-07-10 22:01:47 +02:00
if v:version > 703
syn region rhelpRcode matchgroup=Delimiter start="\\code{" skip='\\\@1<!{.\{-}\\\@1<!}' transparent end="}" contains=@R,rhelpDots,rhelpString,rhelpSpecialChar,rhelpLink keepend
else
syn region rhelpRcode matchgroup=Delimiter start="\\code{" skip='\\\@<!{.\{-}\\\@<!}' transparent end="}" contains=@R,rhelpDots,rhelpString,rhelpSpecialChar,rhelpLink keepend
endif
2011-03-22 14:05:35 +01:00
syn region rhelpS4method matchgroup=Delimiter start="\\S4method{.*}(" matchgroup=Delimiter transparent end=")" contains=@R,rhelpDots
2010-12-10 20:35:50 +01:00
syn region rhelpSexpr matchgroup=Delimiter start="\\Sexpr{" matchgroup=Delimiter transparent end="}" contains=@R
2006-03-06 23:29:24 +00:00
2011-03-22 14:05:35 +01:00
" PreProc {{{1
syn match rhelpPreProc "^#ifdef.*"
syn match rhelpPreProc "^#endif.*"
2006-03-06 23:29:24 +00:00
" Special Delimiters {{{1
syn match rhelpDelimiter "\\cr"
syn match rhelpDelimiter "\\tab "
" Keywords {{{1
2011-03-22 14:05:35 +01:00
syn match rhelpKeyword "\\R"
2006-03-06 23:29:24 +00:00
syn match rhelpKeyword "\\ldots"
2006-04-24 19:47:27 +00:00
syn match rhelpKeyword "--"
syn match rhelpKeyword "---"
syn match rhelpKeyword "<"
syn match rhelpKeyword ">"
2010-05-14 23:24:24 +02:00
syn match rhelpKeyword "\\ge"
syn match rhelpKeyword "\\le"
syn match rhelpKeyword "\\alpha"
syn match rhelpKeyword "\\beta"
syn match rhelpKeyword "\\gamma"
syn match rhelpKeyword "\\delta"
syn match rhelpKeyword "\\epsilon"
syn match rhelpKeyword "\\zeta"
syn match rhelpKeyword "\\eta"
syn match rhelpKeyword "\\theta"
syn match rhelpKeyword "\\iota"
syn match rhelpKeyword "\\kappa"
syn match rhelpKeyword "\\lambda"
syn match rhelpKeyword "\\mu"
syn match rhelpKeyword "\\nu"
syn match rhelpKeyword "\\xi"
syn match rhelpKeyword "\\omicron"
syn match rhelpKeyword "\\pi"
syn match rhelpKeyword "\\rho"
syn match rhelpKeyword "\\sigma"
syn match rhelpKeyword "\\tau"
syn match rhelpKeyword "\\upsilon"
syn match rhelpKeyword "\\phi"
syn match rhelpKeyword "\\chi"
syn match rhelpKeyword "\\psi"
syn match rhelpKeyword "\\omega"
syn match rhelpKeyword "\\Alpha"
syn match rhelpKeyword "\\Beta"
syn match rhelpKeyword "\\Gamma"
syn match rhelpKeyword "\\Delta"
syn match rhelpKeyword "\\Epsilon"
syn match rhelpKeyword "\\Zeta"
syn match rhelpKeyword "\\Eta"
syn match rhelpKeyword "\\Theta"
syn match rhelpKeyword "\\Iota"
syn match rhelpKeyword "\\Kappa"
syn match rhelpKeyword "\\Lambda"
syn match rhelpKeyword "\\Mu"
syn match rhelpKeyword "\\Nu"
syn match rhelpKeyword "\\Xi"
syn match rhelpKeyword "\\Omicron"
syn match rhelpKeyword "\\Pi"
syn match rhelpKeyword "\\Rho"
syn match rhelpKeyword "\\Sigma"
syn match rhelpKeyword "\\Tau"
syn match rhelpKeyword "\\Upsilon"
syn match rhelpKeyword "\\Phi"
syn match rhelpKeyword "\\Chi"
syn match rhelpKeyword "\\Psi"
syn match rhelpKeyword "\\Omega"
2006-03-06 23:29:24 +00:00
" Links {{{1
2011-03-22 14:05:35 +01:00
syn region rhelpLink matchgroup=rhelpSection start="\\link{" end="}" contained keepend extend
syn region rhelpLink matchgroup=rhelpSection start="\\link\[.\{-}\]{" end="}" contained keepend extend
syn region rhelpLink matchgroup=rhelpSection start="\\linkS4class{" end="}" contained keepend extend
" Verbatim like {{{1
2014-07-10 22:01:47 +02:00
if v:version > 703
syn region rhelpVerbatim matchgroup=rhelpType start="\\samp{" skip='\\\@1<!{.\{-}\\\@1<!}' end="}" contains=rhelpSpecialChar,rhelpComment
syn region rhelpVerbatim matchgroup=rhelpType start="\\verb{" skip='\\\@1<!{.\{-}\\\@1<!}' end="}" contains=rhelpSpecialChar,rhelpComment
else
syn region rhelpVerbatim matchgroup=rhelpType start="\\samp{" skip='\\\@<!{.\{-}\\\@<!}' end="}" contains=rhelpSpecialChar,rhelpComment
syn region rhelpVerbatim matchgroup=rhelpType start="\\verb{" skip='\\\@<!{.\{-}\\\@<!}' end="}" contains=rhelpSpecialChar,rhelpComment
endif
2006-03-06 23:29:24 +00:00
" Type Styles {{{1
syn match rhelpType "\\emph\>"
syn match rhelpType "\\strong\>"
syn match rhelpType "\\bold\>"
syn match rhelpType "\\sQuote\>"
syn match rhelpType "\\dQuote\>"
syn match rhelpType "\\preformatted\>"
syn match rhelpType "\\kbd\>"
syn match rhelpType "\\eqn\>"
syn match rhelpType "\\deqn\>"
syn match rhelpType "\\file\>"
syn match rhelpType "\\email\>"
syn match rhelpType "\\url\>"
2010-12-10 20:35:50 +01:00
syn match rhelpType "\\href\>"
2006-03-06 23:29:24 +00:00
syn match rhelpType "\\var\>"
syn match rhelpType "\\env\>"
syn match rhelpType "\\option\>"
syn match rhelpType "\\command\>"
2010-12-10 20:35:50 +01:00
syn match rhelpType "\\newcommand\>"
syn match rhelpType "\\renewcommand\>"
2006-03-06 23:29:24 +00:00
syn match rhelpType "\\dfn\>"
syn match rhelpType "\\cite\>"
syn match rhelpType "\\acronym\>"
" rhelp sections {{{1
syn match rhelpSection "\\encoding\>"
syn match rhelpSection "\\title\>"
2010-12-10 20:35:50 +01:00
syn match rhelpSection "\\item\>"
2006-03-06 23:29:24 +00:00
syn match rhelpSection "\\description\>"
syn match rhelpSection "\\concept\>"
syn match rhelpSection "\\arguments\>"
syn match rhelpSection "\\details\>"
syn match rhelpSection "\\value\>"
syn match rhelpSection "\\references\>"
syn match rhelpSection "\\note\>"
syn match rhelpSection "\\author\>"
syn match rhelpSection "\\seealso\>"
syn match rhelpSection "\\keyword\>"
syn match rhelpSection "\\docType\>"
syn match rhelpSection "\\format\>"
syn match rhelpSection "\\source\>"
2010-12-10 20:35:50 +01:00
syn match rhelpSection "\\itemize\>"
syn match rhelpSection "\\describe\>"
syn match rhelpSection "\\enumerate\>"
syn match rhelpSection "\\item "
syn match rhelpSection "\\item$"
2006-03-06 23:29:24 +00:00
syn match rhelpSection "\\tabular{[lcr]*}"
syn match rhelpSection "\\dontrun\>"
syn match rhelpSection "\\dontshow\>"
syn match rhelpSection "\\testonly\>"
2008-06-24 21:56:24 +00:00
syn match rhelpSection "\\donttest\>"
2006-03-06 23:29:24 +00:00
" Freely named Sections {{{1
2010-12-10 20:35:50 +01:00
syn region rhelpFreesec matchgroup=Delimiter start="\\section{" matchgroup=Delimiter transparent end="}"
syn region rhelpFreesubsec matchgroup=Delimiter start="\\subsection{" matchgroup=Delimiter transparent end="}"
2006-03-06 23:29:24 +00:00
2011-03-22 14:05:35 +01:00
syn match rhelpDelimiter "{\|\[\|(\|)\|\]\|}"
2006-04-24 19:47:27 +00:00
" R help file comments {{{1
2010-12-10 20:35:50 +01:00
syn match rhelpComment /%.*$/
2006-03-06 23:29:24 +00:00
" Error {{{1
2011-10-20 22:22:38 +02:00
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
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
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
2006-03-06 23:29:24 +00:00
syn match rhelpError /[)\]}]/
syn match rhelpBraceError /[)}]/ contained
syn match rhelpCurlyError /[)\]]/ contained
syn match rhelpParenError /[\]}]/ contained
2014-07-10 22:01:47 +02:00
syntax sync match rhelpSyncRcode grouphere rhelpRcode "\\examples{"
2006-03-06 23:29:24 +00:00
" Define the default highlighting {{{1
" For version 5.7 and earlier: only when not done already
" For version 5.8 and later: only when an item doesn't have highlighting yet
if version >= 508 || !exists("did_rhelp_syntax_inits")
if version < 508
let did_rhelp_syntax_inits = 1
command -nargs=+ HiLink hi link <args>
else
command -nargs=+ HiLink hi def link <args>
endif
2011-03-22 14:05:35 +01:00
HiLink rhelpVerbatim String
HiLink rhelpDelimiter Delimiter
2006-03-06 23:29:24 +00:00
HiLink rhelpIdentifier Identifier
HiLink rhelpString String
2011-03-22 14:05:35 +01:00
HiLink rhelpCodeSpecial Special
2006-03-06 23:29:24 +00:00
HiLink rhelpKeyword Keyword
2006-04-24 19:47:27 +00:00
HiLink rhelpDots Keyword
2006-03-06 23:29:24 +00:00
HiLink rhelpLink Underlined
2011-03-22 14:05:35 +01:00
HiLink rhelpType Type
2006-03-06 23:29:24 +00:00
HiLink rhelpSection PreCondit
HiLink rhelpError Error
HiLink rhelpBraceError Error
HiLink rhelpCurlyError Error
HiLink rhelpParenError Error
2011-03-22 14:05:35 +01:00
HiLink rhelpPreProc PreProc
2006-03-06 23:29:24 +00:00
HiLink rhelpDelimiter Delimiter
HiLink rhelpComment Comment
HiLink rhelpRComment Comment
HiLink rhelpSpecialChar SpecialChar
delcommand HiLink
endif
let b:current_syntax = "rhelp"
2014-07-10 22:01:47 +02:00
" vim: foldmethod=marker sw=2