diff options
author | Bram Moolenaar <Bram@vim.org> | 2011-03-22 14:05:35 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2011-03-22 14:05:35 +0100 |
commit | 662db673f9fca628d8e1a7ac4fae3be41dee5d1c (patch) | |
tree | b8224db3a196a36c87f40e55cfab5de5c936bee5 /runtime/syntax | |
parent | e9d4b58dda5ce38389617079722cf9bfcd966599 (diff) |
Updated runtime files.
Diffstat (limited to 'runtime/syntax')
-rw-r--r-- | runtime/syntax/r.vim | 111 | ||||
-rw-r--r-- | runtime/syntax/rhelp.vim | 58 | ||||
-rw-r--r-- | runtime/syntax/treetop.vim | 110 | ||||
-rw-r--r-- | runtime/syntax/upstart.vim | 112 |
4 files changed, 349 insertions, 42 deletions
diff --git a/runtime/syntax/r.vim b/runtime/syntax/r.vim index 7d98e92b74..8912ba191e 100644 --- a/runtime/syntax/r.vim +++ b/runtime/syntax/r.vim @@ -3,13 +3,18 @@ " Maintainer: Jakson Aquino <jalvesaq@gmail.com> " Former Maintainers: Vaidotas Zemlys <zemlys@gmail.com> " Tom Payne <tom@tompayne.org> -" Last Change: Wed Sep 29, 2010 09:31AM +" Last Change: Sun Feb 20, 2011 12:06PM " Filenames: *.R *.r *.Rhistory *.Rt " " NOTE: The highlighting of R functions is defined in the " r-plugin/functions.vim, which is part of vim-r-plugin2: " http://www.vim.org/scripts/script.php?script_id=2628 " +" CONFIGURATION: +" syntax folding can be turned on by +" +" let r_syntax_folding = 1 +" " Some lines of code were borrowed from Zhuojun Chen. if exists("b:current_syntax") @@ -18,18 +23,30 @@ endif setlocal iskeyword=@,48-57,_,. +if exists("g:r_syntax_folding") + setlocal foldmethod=syntax +endif + syn case match " Comment syn match rComment contains=@Spell "\#.*" -" string enclosed in double quotes -syn region rString contains=rSpecial,rStrError,@Spell start=/"/ skip=/\\\\\|\\"/ end=/"/ -" string enclosed in single quotes -syn region rString contains=rSpecial,rStrError,@Spell start=/'/ skip=/\\\\\|\\'/ end=/'/ +if &filetype == "rhelp" + " string enclosed in double quotes + syn region rString contains=rSpecial,@Spell start=/"/ skip=/\\\\\|\\"/ end=/"/ + " string enclosed in single quotes + syn region rString contains=rSpecial,@Spell start=/'/ skip=/\\\\\|\\'/ end=/'/ +else + " string enclosed in double quotes + syn region rString contains=rSpecial,rStrError,@Spell start=/"/ skip=/\\\\\|\\"/ end=/"/ + " string enclosed in single quotes + syn region rString contains=rSpecial,rStrError,@Spell start=/'/ skip=/\\\\\|\\'/ end=/'/ +endif syn match rStrError display contained "\\." + " New line, carriage return, tab, backspace, bell, feed, vertical tab, backslash syn match rSpecial display contained "\\\(n\|r\|t\|b\|a\|f\|v\|'\|\"\)\|\\\\" @@ -42,9 +59,6 @@ syn match rSpecial display contained "\\U\x\{1,8}" syn match rSpecial display contained "\\u{\x\{1,4}}" syn match rSpecial display contained "\\U{\x\{1,8}}" - -syn match rDollar "\$" - " Statement syn keyword rStatement break next return syn keyword rConditional if else @@ -54,26 +68,18 @@ syn keyword rRepeat for in repeat while syn keyword rConstant T F LETTERS letters month.ab month.name pi syn keyword rConstant R.version.string -" Constant +syn keyword rNumber NA_integer_ NA_real_ NA_complex_ NA_character_ + +" Constants syn keyword rConstant NULL syn keyword rBoolean FALSE TRUE -syn keyword rNumber NA NA_integer_ NA_real_ NA_complex_ NA_character_ -syn keyword rNumber Inf NaN +syn keyword rNumber NA Inf NaN " integer syn match rInteger "\<\d\+L" syn match rInteger "\<0x\([0-9]\|[a-f]\|[A-F]\)\+L" syn match rInteger "\<\d\+[Ee]+\=\d\+L" -syn match rOperator "[\*\!\&\+\-\<\>\=\^\|\~\`/:@]" -syn match rOperator "%\{2}\|%\*%\|%\/%\|%in%\|%o%\|%x%" - -syn match rComplex "\<\d\+i" -syn match rComplex "\<0x\([0-9]\|[a-f]\|[A-F]\)\+i" -syn match rComplex "\<\d\+\.\d*\([Ee][-+]\=\d\+\)\=i" -syn match rComplex "\<\.\d\+\([Ee][-+]\=\d\+\)\=i" -syn match rComplex "\<\d\+[Ee][-+]\=\d\+i" - " number with no fractional part or exponent syn match rNumber "\<\d\+\>" " hexadecimal number @@ -86,6 +92,28 @@ syn match rFloat "\<\.\d\+\([Ee][-+]\=\d\+\)\=" " floating point number with no fractional part and optional exponent syn match rFloat "\<\d\+[Ee][-+]\=\d\+" +" complex number +syn match rComplex "\<\d\+i" +syn match rComplex "\<\d\++\d\+i" +syn match rComplex "\<0x\([0-9]\|[a-f]\|[A-F]\)\+i" +syn match rComplex "\<\d\+\.\d*\([Ee][-+]\=\d\+\)\=i" +syn match rComplex "\<\.\d\+\([Ee][-+]\=\d\+\)\=i" +syn match rComplex "\<\d\+[Ee][-+]\=\d\+i" + +syn match rOperator "&" +syn match rOperator '-' +syn match rOperator '*' +syn match rOperator '+' +syn match rOperator '=' +syn match rOperator "[|!<>^~`/:@]" +syn match rOperator "%\{2}\|%\*%\|%\/%\|%in%\|%o%\|%x%" +syn match rOpError '*\{3}' +syn match rOpError '//' +syn match rOpError '&&&' +syn match rOpError '|||' +syn match rOpError '<<' +syn match rOpError '>>' + syn match rArrow "<\{1,2}-" syn match rArrow "->\{1,2}" @@ -93,20 +121,50 @@ syn match rArrow "->\{1,2}" syn match rDelimiter "[,;:]" " Error -syn region rRegion matchgroup=Delimiter start=/(/ matchgroup=Delimiter end=/)/ transparent contains=ALLBUT,rError,rBraceError,rCurlyError -syn region rRegion matchgroup=Delimiter start=/{/ matchgroup=Delimiter end=/}/ transparent contains=ALLBUT,rError,rBraceError,rParenError -syn region rRegion matchgroup=Delimiter start=/\[/ matchgroup=Delimiter end=/]/ transparent contains=ALLBUT,rError,rCurlyError,rParenError +if exists("g:r_syntax_folding") + syn region rRegion matchgroup=Delimiter start=/(/ matchgroup=Delimiter end=/)/ transparent contains=ALLBUT,rError,rBraceError,rCurlyError fold + syn region rRegion matchgroup=Delimiter start=/{/ matchgroup=Delimiter end=/}/ transparent contains=ALLBUT,rError,rBraceError,rParenError fold + syn region rRegion matchgroup=Delimiter start=/\[/ matchgroup=Delimiter end=/]/ transparent contains=ALLBUT,rError,rCurlyError,rParenError fold +else + syn region rRegion matchgroup=Delimiter start=/(/ matchgroup=Delimiter end=/)/ transparent contains=ALLBUT,rError,rBraceError,rCurlyError + syn region rRegion matchgroup=Delimiter start=/{/ matchgroup=Delimiter end=/}/ transparent contains=ALLBUT,rError,rBraceError,rParenError + syn region rRegion matchgroup=Delimiter start=/\[/ matchgroup=Delimiter end=/]/ transparent contains=ALLBUT,rError,rCurlyError,rParenError +endif + syn match rError "[)\]}]" syn match rBraceError "[)}]" contained syn match rCurlyError "[)\]]" contained syn match rParenError "[\]}]" contained +" Source list of R functions. The list is produced by the Vim-R-plugin +" http://www.vim.org/scripts/script.php?script_id=2628 +runtime r-plugin/functions.vim + +syn match rDollar display contained "\$" + +" List elements will not be highlighted as functions: +syn match rLstElmt "\$[a-zA-Z0-9\\._]*" contains=rDollar + " Functions that may add new objects syn keyword rPreProc library require attach detach source +if &filetype == "rhelp" + syn match rHelpIdent '\\method' + syn match rHelpIdent '\\S4method' +endif + " Type syn keyword rType array category character complex double function integer list logical matrix numeric vector data.frame +" Name of object with spaces +syn region rNameWSpace start="`" end="`" + +if &filetype == "rhelp" + syn match rhPreProc "^#ifdef.*" + syn match rhPreProc "^#endif.*" + syn match rhSection "\\dontrun\>" +endif + " Define the default highlighting. hi def link rArrow Statement hi def link rBoolean Boolean @@ -120,9 +178,16 @@ hi def link rDelimiter Delimiter hi def link rDollar SpecialChar hi def link rError Error hi def link rFloat Float +hi def link rFunction Function +hi def link rHelpIdent Identifier +hi def link rhPreProc PreProc +hi def link rhSection PreCondit hi def link rInteger Number +hi def link rLstElmt Normal +hi def link rNameWSpace Normal hi def link rNumber Number hi def link rOperator Operator +hi def link rOpError Error hi def link rParenError Error hi def link rPreProc PreProc hi def link rRepeat Repeat diff --git a/runtime/syntax/rhelp.vim b/runtime/syntax/rhelp.vim index 7550b1293e..9120d756b5 100644 --- a/runtime/syntax/rhelp.vim +++ b/runtime/syntax/rhelp.vim @@ -1,7 +1,8 @@ " Vim syntax file " Language: R Help File -" Maintainer: Johannes Ranke <jranke@uni-bremen.de> -" Last Change: 2010 Nov 22 +" Maintainer: Jakson Aquino <jalvesaq@gmail.com> +" Former Maintainer: Johannes Ranke <jranke@uni-bremen.de> +" Last Change: Sat Feb 19, 2011 02:13PM " Version: 0.7.4 " SVN: $Id: rhelp.vim 90 2010-11-22 10:58:11Z ranke $ " Remarks: - Includes R syntax highlighting in the appropriate @@ -24,36 +25,46 @@ endif syn case match -" R help identifiers {{{ +" R help identifiers {{{1 syn region rhelpIdentifier matchgroup=rhelpSection start="\\name{" end="}" syn region rhelpIdentifier matchgroup=rhelpSection start="\\alias{" end="}" -syn region rhelpIdentifier matchgroup=rhelpSection start="\\pkg{" end="}" +syn region rhelpIdentifier matchgroup=rhelpSection start="\\pkg{" end="}" contains=rhelpLink syn region rhelpIdentifier matchgroup=rhelpSection start="\\method{" end="}" contained syn region rhelpIdentifier matchgroup=rhelpSection start="\\Rdversion{" end="}" " Highlighting of R code using an existing r.vim syntax file if available {{{1 syn include @R syntax/r.vim + +" 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 syn match rhelpDots "\\dots" containedin=@R -syn region rhelpRcode matchgroup=Delimiter start="\\examples{" matchgroup=Delimiter transparent end="}" contains=@R,rhelpSection +syn region rhelpRcode matchgroup=Delimiter start="\\examples{" matchgroup=Delimiter transparent end="}" contains=@R,rhelpLink,rhelpIdentifier,rhelpString,rhelpSpecialChar,rhelpSection 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 -syn region rhelpRcode matchgroup=Delimiter start="\\special{" matchgroup=Delimiter transparent end="}" contains=@R contained -syn region rhelpRcode matchgroup=Delimiter start="\\code{" matchgroup=Delimiter transparent end="}" contains=@R,rhelpLink contained -syn region rhelpS4method matchgroup=Delimiter start="\\S4method{.*}(" matchgroup=Delimiter transparent end=")" contains=@R,rhelpDots contained +syn region rhelpRcode matchgroup=Delimiter start="\\special{" matchgroup=Delimiter transparent end="}" contains=@R +syn region rhelpRcode matchgroup=Delimiter start="\\code{" skip='\\\@<!{.\{-}\\\@<!}' transparent end="}" contains=@R,rhelpDots,rhelpString,rhelpSpecialChar,rhelpLink keepend +syn region rhelpS4method matchgroup=Delimiter start="\\S4method{.*}(" matchgroup=Delimiter transparent end=")" contains=@R,rhelpDots syn region rhelpSexpr matchgroup=Delimiter start="\\Sexpr{" matchgroup=Delimiter transparent end="}" contains=@R -" Strings {{{1 -syn region rhelpString start=/"/ end=/"/ - -" Special characters ( \$ \& \% \# \{ \} \_) {{{1 -syn match rhelpSpecialChar "\\[$&%#{}_]" +" PreProc {{{1 +syn match rhelpPreProc "^#ifdef.*" +syn match rhelpPreProc "^#endif.*" " Special Delimiters {{{1 syn match rhelpDelimiter "\\cr" syn match rhelpDelimiter "\\tab " " Keywords {{{1 -syn match rhelpKeyword "\\R" contained +syn match rhelpKeyword "\\R" syn match rhelpKeyword "\\ldots" syn match rhelpKeyword "--" syn match rhelpKeyword "---" @@ -111,9 +122,13 @@ syn match rhelpKeyword "\\Psi" syn match rhelpKeyword "\\Omega" " Links {{{1 -syn region rhelpLink matchgroup=rhelpSection start="\\link{" end="}" contained keepend -syn region rhelpLink matchgroup=rhelpSection start="\\link\[.\{-}\]{" end="}" contained keepend -syn region rhelpLink matchgroup=rhelpSection start="\\linkS4class{" end="}" contained keepend +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 +syn region rhelpVerbatim matchgroup=rhelpType start="\\samp{" skip='\\\@<!{.\{-}\\\@<!}' end="}" contains=rhelpSpecialChar,rhelpComment +syn region rhelpVerbatim matchgroup=rhelpType start="\\verb{" skip='\\\@<!{.\{-}\\\@<!}' end="}" contains=rhelpSpecialChar,rhelpComment " Type Styles {{{1 syn match rhelpType "\\emph\>" @@ -123,7 +138,6 @@ syn match rhelpType "\\sQuote\>" syn match rhelpType "\\dQuote\>" syn match rhelpType "\\preformatted\>" syn match rhelpType "\\kbd\>" -syn match rhelpType "\\samp\>" syn match rhelpType "\\eqn\>" syn match rhelpType "\\deqn\>" syn match rhelpType "\\file\>" @@ -172,6 +186,8 @@ syn match rhelpSection "\\donttest\>" syn region rhelpFreesec matchgroup=Delimiter start="\\section{" matchgroup=Delimiter transparent end="}" syn region rhelpFreesubsec matchgroup=Delimiter start="\\subsection{" matchgroup=Delimiter transparent end="}" +syn match rhelpDelimiter "{\|\[\|(\|)\|\]\|}" + " R help file comments {{{1 syn match rhelpComment /%.*$/ @@ -194,17 +210,21 @@ if version >= 508 || !exists("did_rhelp_syntax_inits") else command -nargs=+ HiLink hi def link <args> endif + HiLink rhelpVerbatim String + HiLink rhelpDelimiter Delimiter HiLink rhelpIdentifier Identifier HiLink rhelpString String + HiLink rhelpCodeSpecial Special HiLink rhelpKeyword Keyword HiLink rhelpDots Keyword HiLink rhelpLink Underlined - HiLink rhelpType Type + HiLink rhelpType Type HiLink rhelpSection PreCondit HiLink rhelpError Error HiLink rhelpBraceError Error HiLink rhelpCurlyError Error HiLink rhelpParenError Error + HiLink rhelpPreProc PreProc HiLink rhelpDelimiter Delimiter HiLink rhelpComment Comment HiLink rhelpRComment Comment diff --git a/runtime/syntax/treetop.vim b/runtime/syntax/treetop.vim new file mode 100644 index 0000000000..921c5bea1d --- /dev/null +++ b/runtime/syntax/treetop.vim @@ -0,0 +1,110 @@ +" Vim syntax file +" Language: Treetop +" Maintainer: Nikolai Weibull <now@bitwi.se> +" Latest Revision: 2011-03-14 + +if exists("b:current_syntax") + finish +endif + +let s:cpo_save = &cpo +set cpo&vim + +syn keyword treetopTodo + \ contained + \ TODO + \ FIXME + \ XXX + \ NOTE + +syn match treetopComment + \ '#.*' + \ display + \ contains=treetopTodo + +syn include @treetopRuby syntax/ruby.vim +unlet b:current_syntax + +syn keyword treetopKeyword + \ require + \ end +syn region treetopKeyword + \ matchgroup=treetopKeyword + \ start='\<\%(grammar\|include\|module\)\>\ze\s' + \ end='$' + \ transparent + \ oneline + \ keepend + \ contains=@treetopRuby +syn keyword treetopKeyword + \ rule + \ nextgroup=treetopRuleName + \ skipwhite skipnl + +syn match treetopGrammarName + \ '\u\w*' + \ contained + +syn match treetopRubyModuleName + \ '\u\w*' + \ contained + +syn match treetopRuleName + \ '\h\w*' + \ contained + +syn region treetopString + \ matchgroup=treetopStringDelimiter + \ start=+"+ + \ end=+"+ +syn region treetopString + \ matchgroup=treetopStringDelimiter + \ start=+'+ + \ end=+'+ + +syn region treetopCharacterClass + \ matchgroup=treetopCharacterClassDelimiter + \ start=+\[+ + \ skip=+\\\]+ + \ end=+\]+ + +syn region treetopRubyBlock + \ matchgroup=treetopRubyBlockDelimiter + \ start=+{+ + \ end=+}+ + \ contains=@treetopRuby + +syn region treetopSemanticPredicate + \ matchgroup=treetopSemanticPredicateDelimiter + \ start=+[!&]{+ + \ end=+}+ + \ contains=@treetopRuby + +syn region treetopSubclassDeclaration + \ matchgroup=treetopSubclassDeclarationDelimiter + \ start=+<+ + \ end=+>+ + \ contains=@treetopRuby + +syn match treetopEllipsis + \ +''+ + +hi def link treetopTodo Todo +hi def link treetopComment Comment +hi def link treetopKeyword Keyword +hi def link treetopGrammarName Constant +hi def link treetopRubyModuleName Constant +hi def link treetopRuleName Identifier +hi def link treetopString String +hi def link treetopStringDelimiter treetopString +hi def link treetopCharacterClass treetopString +hi def link treetopCharacterClassDelimiter treetopCharacterClass +hi def link treetopRubyBlockDelimiter PreProc +hi def link treetopSemanticPredicateDelimiter PreProc +hi def link treetopSubclassDeclarationDelimiter PreProc +hi def link treetopEllipsis Special + +let b:current_syntax = 'treetop' + +let &cpo = s:cpo_save +unlet s:cpo_save diff --git a/runtime/syntax/upstart.vim b/runtime/syntax/upstart.vim new file mode 100644 index 0000000000..9db8bcbd41 --- /dev/null +++ b/runtime/syntax/upstart.vim @@ -0,0 +1,112 @@ +" Vim syntax file +" Language: Upstart job files +" Maintainer: Michael Biebl <biebl@debian.org> +" James Hunt <james.hunt@ubuntu.com> +" Last Change: 2011 Mar 22 +" License: GPL v2 +" Version: 0.4 +" Remark: Syntax highlighting for Upstart (init(8)) job files. +" +" It is inspired by the initng syntax file and includes sh.vim to do the +" highlighting of script blocks. + +if version < 600 + syntax clear +elseif exists("b:current_syntax") + finish +endif + +let is_bash = 1 +syn include @Shell syntax/sh.vim + +syn case match + +" avoid need to use 'match' for most events +setlocal iskeyword+=- + +syn match upstartComment /#.*$/ contains=upstartTodo +syn keyword upstartTodo TODO FIXME contained + +syn region upstartString start=/"/ end=/"/ skip=/\\"/ + +syn region upstartScript matchgroup=upstartStatement start="script" end="end script" contains=@upstartShellCluster + +syn cluster upstartShellCluster contains=@Shell + +" one argument +syn keyword upstartStatement description author version instance expect +syn keyword upstartStatement pid kill normal console env exit export +syn keyword upstartStatement umask nice oom chroot chdir exec + +" two arguments +syn keyword upstartStatement limit + +" one or more arguments (events) +syn keyword upstartStatement emits + +syn keyword upstartStatement on start stop + +" flag, no parameter +syn keyword upstartStatement respawn service instance manual debug task + +" prefix for exec or script +syn keyword upstartOption pre-start post-start pre-stop post-stop + +" option for kill +syn keyword upstartOption timeout +" option for oom +syn keyword upstartOption never +" options for console +syn keyword upstartOption output owner +" options for expect +syn keyword upstartOption fork daemon +" options for limit +syn keyword upstartOption unlimited + +" 'options' for start/stop on +syn keyword upstartOption and or + +" Upstart itself and associated utilities +syn keyword upstartEvent runlevel +syn keyword upstartEvent started +syn keyword upstartEvent starting +syn keyword upstartEvent startup +syn keyword upstartEvent stopped +syn keyword upstartEvent stopping +syn keyword upstartEvent control-alt-delete +syn keyword upstartEvent keyboard-request +syn keyword upstartEvent power-status-changed + +" D-Bus +syn keyword upstartEvent dbus-activation + +" Display Manager (ie gdm) +syn keyword upstartEvent desktop-session-start +syn keyword upstartEvent login-session-start + +" mountall +syn keyword upstartEvent all-swaps +syn keyword upstartEvent filesystem +syn keyword upstartEvent mounted +syn keyword upstartEvent mounting +syn keyword upstartEvent local-filesystems +syn keyword upstartEvent remote-filesystems +syn keyword upstartEvent virtual-filesystems + +" SysV umountnfs.sh +syn keyword upstartEvent mounted-remote-filesystems + +" upstart-udev-bridge and ifup/down +syn match upstartEvent /\<\i\{-1,}-device-\(added\|removed\|up\|down\)/ + +" upstart-socket-bridge +syn keyword upstartEvent socket + +hi def link upstartComment Comment +hi def link upstartTodo Todo +hi def link upstartString String +hi def link upstartStatement Statement +hi def link upstartOption Type +hi def link upstartEvent Define + +let b:current_syntax = "upstart" |