# HG changeset patch # User Bram Moolenaar # Date 1405022507 -7200 # Node ID 0efec12f52acd812b1c03e42347a4ef275c0e74d # Parent f5c7483cbbb40a30c46977a8785326f04f5dadbf Updated runtime files. diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt --- a/runtime/doc/eval.txt +++ b/runtime/doc/eval.txt @@ -1,4 +1,4 @@ -*eval.txt* For Vim version 7.4. Last change: 2014 Jul 02 +*eval.txt* For Vim version 7.4. Last change: 2014 Jul 06 VIM REFERENCE MANUAL by Bram Moolenaar @@ -5653,7 +5653,7 @@ sort({list} [, {func} [, {dict}]]) *so The sort is stable, items which compare equal (as number or as string) will keep their relative position. E.g., when sorting - on numbers, text strings will sort next to eachother, in the + on numbers, text strings will sort next to each other, in the same order as they were originally. Also see |uniq()|. diff --git a/runtime/doc/insert.txt b/runtime/doc/insert.txt --- a/runtime/doc/insert.txt +++ b/runtime/doc/insert.txt @@ -1,4 +1,4 @@ -*insert.txt* For Vim version 7.4. Last change: 2013 Jul 12 +*insert.txt* For Vim version 7.4. Last change: 2014 Jul 06 VIM REFERENCE MANUAL by Bram Moolenaar @@ -1302,7 +1302,7 @@ HTML *ft-html-omni* XHTML *ft-xhtml-omni* CTRL-X CTRL-O provides completion of various elements of (X)HTML files. It is -designed to support writing of XHTML 1.0 Strict files but will also works for +designed to support writing of XHTML 1.0 Strict files but will also work for other versions of HTML. Features: - after "<" complete tag name depending on context (no div suggestion inside diff --git a/runtime/doc/starting.txt b/runtime/doc/starting.txt --- a/runtime/doc/starting.txt +++ b/runtime/doc/starting.txt @@ -1,4 +1,4 @@ -*starting.txt* For Vim version 7.4. Last change: 2014 Jun 14 +*starting.txt* For Vim version 7.4. Last change: 2014 Jul 09 VIM REFERENCE MANUAL by Bram Moolenaar @@ -1506,7 +1506,7 @@ most of the information will be restored already set (registers, marks, |v:oldfiles|, etc.) will be overwritten {not in Vi} - *:wv* *:wviminfo* *E137* *E138* *E574* + *:wv* *:wviminfo* *E137* *E138* *E574* *E886* :wv[iminfo][!] [file] Write to viminfo file [file] (default: see above). The information in the file is first read in to make a merge between old and new info. When [!] is used, diff --git a/runtime/doc/tags b/runtime/doc/tags --- a/runtime/doc/tags +++ b/runtime/doc/tags @@ -4323,6 +4323,7 @@ E882 eval.txt /*E882* E883 eval.txt /*E883* E884 eval.txt /*E884* E885 sign.txt /*E885* +E886 starting.txt /*E886* E89 message.txt /*E89* E90 message.txt /*E90* E91 options.txt /*E91* diff --git a/runtime/doc/todo.txt b/runtime/doc/todo.txt --- a/runtime/doc/todo.txt +++ b/runtime/doc/todo.txt @@ -1,4 +1,4 @@ -*todo.txt* For Vim version 7.4. Last change: 2014 Jul 04 +*todo.txt* For Vim version 7.4. Last change: 2014 Jul 10 VIM REFERENCE MANUAL by Bram Moolenaar @@ -34,13 +34,7 @@ not be repeated below, unless there is e *known-bugs* -------------------- Known bugs and current work ----------------------- -Sort is still not stable, add an index in the array. -See patch from Takimoto. - -Another follow-up patch for breakindent. (Christian, 2014 Jun 28) - -After patch 7.4.305 the termresponse isn't requested at all? -(Tomas Janousek, 2014 Jul 1, Jul 2) +Forfeit test_listlbr when encoding is not utf8? (Danek Duvall) Regexp problems: - Bug with pattern: '\vblock (\d+)\.\n.*\d+%(\1)@ -" Last Change: 2014 Jun 12 +" Last Change: 2014 Jul 09 " Listen very carefully, I will say this only once if exists("did_load_filetypes") @@ -864,7 +864,7 @@ func! s:FThtml() setf xhtml return endif - if getline(n) =~ '{%\s*\(extends\|block\)\>' + if getline(n) =~ '{%\s*\(extends\|block\|load\)\>' setf htmldjango return endif @@ -1649,6 +1649,20 @@ else au BufNewFile,BufRead *.rnw,*.snw setf rnoweb endif +" R Markdown file +if has("fname_case") + au BufNewFile,BufRead *.Rmd,*.rmd,*.Smd,*.smd setf rmd +else + au BufNewFile,BufRead *.rmd,*.smd setf rmd +endif + +" R reStructuredText file +if has("fname_case") + au BufNewFile,BufRead *.Rrst,*.rrst,*.Srst,*.srst setf rrst +else + au BufNewFile,BufRead *.rrst,*.srst setf rrst +endif + " Rexx, Rebol or R au BufNewFile,BufRead *.r,*.R call s:FTr() @@ -2664,7 +2678,7 @@ au BufNewFile,BufRead zsh*,zlog* call s " Plain text files, needs to be far down to not override others. This avoids " the "conf" type being used if there is a line starting with '#'. -au BufNewFile,BufRead *.txt,*.text setf text +au BufNewFile,BufRead *.txt,*.text,README setf text " Use the filetype detect plugins. They may overrule any of the previously diff --git a/runtime/ftplugin/r.vim b/runtime/ftplugin/r.vim new file mode 100644 --- /dev/null +++ b/runtime/ftplugin/r.vim @@ -0,0 +1,31 @@ +" Vim filetype plugin file +" Language: R +" Maintainer: Jakson Alves de Aquino +" Last Change: Sun Feb 23, 2014 04:07PM + +" Only do this when not yet done for this buffer +if exists("b:did_ftplugin") + finish +endif + +" Don't load another plugin for this buffer +let b:did_ftplugin = 1 + +let s:cpo_save = &cpo +set cpo&vim + +setlocal iskeyword=@,48-57,_,. +setlocal formatoptions-=t +setlocal commentstring=#\ %s +setlocal comments=:#',:###,:##,:# + +if has("gui_win32") && !exists("b:browsefilter") + let b:browsefilter = "R Source Files (*.R)\t*.R\n" . + \ "Files that include R (*.Rnw *.Rd *.Rmd *.Rrst)\t*.Rnw;*.Rd;*.Rmd;*.Rrst\n" . + \ "All Files (*.*)\t*.*\n" +endif + +let b:undo_ftplugin = "setl cms< com< fo< isk< | unlet! b:browsefilter" + +let &cpo = s:cpo_save +unlet s:cpo_save diff --git a/runtime/ftplugin/rhelp.vim b/runtime/ftplugin/rhelp.vim new file mode 100644 --- /dev/null +++ b/runtime/ftplugin/rhelp.vim @@ -0,0 +1,29 @@ +" Vim filetype plugin file +" Language: R help file +" Maintainer: Jakson Alves de Aquino +" Last Change: Wed Jul 09, 2014 06:23PM + +" Only do this when not yet done for this buffer +if exists("b:did_ftplugin") + finish +endif + +" Don't load another plugin for this buffer +let b:did_ftplugin = 1 + +let s:cpo_save = &cpo +set cpo&vim + +setlocal iskeyword=@,48-57,_,. + +if has("gui_win32") && !exists("b:browsefilter") + let b:browsefilter = "R Source Files (*.R *.Rnw *.Rd *.Rmd *.Rrst)\t*.R;*.Rnw;*.Rd;*.Rmd;*.Rrst\n" . + \ "All Files (*.*)\t*.*\n" +endif + +let b:undo_ftplugin = "setl isk< | unlet! b:browsefilter" + +let &cpo = s:cpo_save +unlet s:cpo_save + +" vim: sw=2 diff --git a/runtime/ftplugin/rmd.vim b/runtime/ftplugin/rmd.vim new file mode 100644 --- /dev/null +++ b/runtime/ftplugin/rmd.vim @@ -0,0 +1,43 @@ +" Vim filetype plugin file +" Language: R help file +" Maintainer: Jakson Alves de Aquino +" Last Change: Wed Jul 09, 2014 06:23PM +" Original work by Alex Zvoleff (adjusted for rmd by Michel Kuhlmann) + +" Only do this when not yet done for this buffer +if exists("b:did_ftplugin") + finish +endif + +runtime! ftplugin/html.vim ftplugin/html_*.vim ftplugin/html/*.vim + +setlocal comments=fb:*,fb:-,fb:+,n:> commentstring=>\ %s +setlocal formatoptions+=tcqln +setlocal formatlistpat=^\\s*\\d\\+\\.\\s\\+\\\|^\\s*[-*+]\\s\\+ +setlocal iskeyword=@,48-57,_,. + +let s:cpo_save = &cpo +set cpo&vim + +" Enables pandoc if it is installed +unlet! b:did_ftplugin +runtime ftplugin/pandoc.vim + +" Don't load another plugin for this buffer +let b:did_ftplugin = 1 + +if has("gui_win32") && !exists("b:browsefilter") + let b:browsefilter = "R Source Files (*.R *.Rnw *.Rd *.Rmd *.Rrst)\t*.R;*.Rnw;*.Rd;*.Rmd;*.Rrst\n" . + \ "All Files (*.*)\t*.*\n" +endif + +if exists('b:undo_ftplugin') + let b:undo_ftplugin .= " | setl cms< com< fo< flp< isk< | unlet! b:browsefilter" +else + let b:undo_ftplugin = "setl cms< com< fo< flp< isk< | unlet! b:browsefilter" +endif + +let &cpo = s:cpo_save +unlet s:cpo_save + +" vim: sw=2 diff --git a/runtime/ftplugin/rnoweb.vim b/runtime/ftplugin/rnoweb.vim new file mode 100644 --- /dev/null +++ b/runtime/ftplugin/rnoweb.vim @@ -0,0 +1,40 @@ +" Vim filetype plugin file +" Language: Rnoweb +" Maintainer: Jakson Alves de Aquino +" Last Change: Wed Jul 09, 2014 06:23PM + +" Only do this when not yet done for this buffer +if exists("b:did_ftplugin") + finish +endif + +let s:cpo_save = &cpo +set cpo&vim + +runtime! ftplugin/tex.vim + +" Don't load another plugin for this buffer +let b:did_ftplugin = 1 + +" Enables Vim-Latex-Suite, LaTeX-Box if installed +runtime ftplugin/tex_*.vim + +setlocal iskeyword=@,48-57,_,. +setlocal suffixesadd=.bib,.tex +setlocal comments=b:%,b:#,b:##,b:###,b:#' + +if has("gui_win32") && !exists("b:browsefilter") + let b:browsefilter = "R Source Files (*.R *.Rnw *.Rd *.Rmd *.Rrst)\t*.R;*.Rnw;*.Rd;*.Rmd;*.Rrst\n" . + \ "All Files (*.*)\t*.*\n" +endif + +if exists('b:undo_ftplugin') + let b:undo_ftplugin .= " | setl isk< sua< com< | unlet! b:browsefilter" +else + let b:undo_ftplugin = "setl isk< sua< com< | unlet! b:browsefilter" +endif + +let &cpo = s:cpo_save +unlet s:cpo_save + +" vim: sw=2 diff --git a/runtime/ftplugin/rrst.vim b/runtime/ftplugin/rrst.vim new file mode 100644 --- /dev/null +++ b/runtime/ftplugin/rrst.vim @@ -0,0 +1,37 @@ +" Vim filetype plugin file +" Language: reStructuredText documentation format with R code +" Maintainer: Jakson Alves de Aquino +" Last Change: Wed Jul 09, 2014 06:23PM +" Original work by Alex Zvoleff + +" Only do this when not yet done for this buffer +if exists("b:did_ftplugin") + finish +endif + +" Don't load another plugin for this buffer +let b:did_ftplugin = 1 + +let s:cpo_save = &cpo +set cpo&vim + +setlocal comments=fb:*,fb:-,fb:+,n:> commentstring=>\ %s +setlocal formatoptions+=tcqln +setlocal formatlistpat=^\\s*\\d\\+\\.\\s\\+\\\|^\\s*[-*+]\\s\\+ +setlocal iskeyword=@,48-57,_,. + +if has("gui_win32") && !exists("b:browsefilter") + let b:browsefilter = "R Source Files (*.R *.Rnw *.Rd *.Rmd *.Rrst)\t*.R;*.Rnw;*.Rd;*.Rmd;*.Rrst\n" . + \ "All Files (*.*)\t*.*\n" +endif + +if exists('b:undo_ftplugin') + let b:undo_ftplugin .= " | setl cms< com< fo< flp< isk< | unlet! b:browsefilter" +else + let b:undo_ftplugin = "setl cms< com< fo< flp< isk< | unlet! b:browsefilter" +endif + +let &cpo = s:cpo_save +unlet s:cpo_save + +" vim: sw=2 diff --git a/runtime/ftplugin/text.vim b/runtime/ftplugin/text.vim new file mode 100644 --- /dev/null +++ b/runtime/ftplugin/text.vim @@ -0,0 +1,17 @@ +" Vim filetype plugin +" Language: Text +" Maintainer: David Barnett +" Last Change: 2014 Jul 09 + +if exists('b:did_ftplugin') + finish +endif +let b:did_ftplugin = 1 + +let b:undo_ftplugin = 'setlocal comments< commentstring<' + +" We intentionally don't set formatoptions-=t since text should wrap as text. + +" Pseudo comment leaders to indent bulleted lists. +setlocal comments=fb:-,fb:* +setlocal commentstring= diff --git a/runtime/indent/rhelp.vim b/runtime/indent/rhelp.vim new file mode 100644 --- /dev/null +++ b/runtime/indent/rhelp.vim @@ -0,0 +1,111 @@ +" Vim indent file +" Language: R Documentation (Help), *.Rd +" Author: Jakson Alves de Aquino +" Last Change: Wed Jul 09, 2014 07:34PM + + +" Only load this indent file when no other was loaded. +if exists("b:did_indent") + finish +endif +runtime indent/r.vim +let s:RIndent = function(substitute(&indentexpr, "()", "", "")) +let b:did_indent = 1 + +setlocal indentkeys=0{,0},:,!^F,o,O,e +setlocal indentexpr=GetRHelpIndent() + +" Only define the function once. +if exists("*GetRHelpIndent") + finish +endif + +setlocal noautoindent +setlocal nocindent +setlocal nosmartindent +setlocal nolisp + +setlocal indentkeys=0{,0},:,!^F,o,O,e +setlocal indentexpr=GetCorrectRHelpIndent() + +function s:SanitizeRHelpLine(line) + let newline = substitute(a:line, '\\\\', "x", "g") + let newline = substitute(newline, '\\{', "x", "g") + let newline = substitute(newline, '\\}', "x", "g") + let newline = substitute(newline, '\\%', "x", "g") + let newline = substitute(newline, '%.*', "", "") + let newline = substitute(newline, '\s*$', "", "") + return newline +endfunction + +function GetRHelpIndent() + + let clnum = line(".") " current line + if clnum == 1 + return 0 + endif + let cline = getline(clnum) + + if cline =~ '^\s*}\s*$' + let i = clnum + let bb = -1 + while bb != 0 && i > 1 + let i -= 1 + let line = s:SanitizeRHelpLine(getline(i)) + let line2 = substitute(line, "{", "", "g") + let openb = strlen(line) - strlen(line2) + let line3 = substitute(line2, "}", "", "g") + let closeb = strlen(line2) - strlen(line3) + let bb += openb - closeb + endwhile + return indent(i) + endif + + if cline =~ '^\s*#ifdef\>' || cline =~ '^\s*#endif\>' + return 0 + endif + + let lnum = clnum - 1 + let line = getline(lnum) + if line =~ '^\s*#ifdef\>' || line =~ '^\s*#endif\>' + let lnum -= 1 + let line = getline(lnum) + endif + while lnum > 1 && (line =~ '^\s*$' || line =~ '^#ifdef' || line =~ '^#endif') + let lnum -= 1 + let line = getline(lnum) + endwhile + if lnum == 1 + return 0 + endif + let line = s:SanitizeRHelpLine(line) + let line2 = substitute(line, "{", "", "g") + let openb = strlen(line) - strlen(line2) + let line3 = substitute(line2, "}", "", "g") + let closeb = strlen(line2) - strlen(line3) + let bb = openb - closeb + + let ind = indent(lnum) + (bb * &sw) + + if line =~ '^\s*}\s*$' + let ind = indent(lnum) + endif + + if ind < 0 + return 0 + endif + + return ind +endfunction + +function GetCorrectRHelpIndent() + let lastsection = search('^\\[a-z]*{', "bncW") + let secname = getline(lastsection) + if secname =~ '^\\usage{' || secname =~ '^\\examples{' || secname =~ '^\\dontshow{' || secname =~ '^\\dontrun{' || secname =~ '^\\donttest{' || secname =~ '^\\testonly{' || secname =~ '^\\method{.*}{.*}(' + return s:RIndent() + else + return GetRHelpIndent() + endif +endfunction + +" vim: sw=2 diff --git a/runtime/indent/rmd.vim b/runtime/indent/rmd.vim new file mode 100644 --- /dev/null +++ b/runtime/indent/rmd.vim @@ -0,0 +1,46 @@ +" Vim indent file +" Language: Rmd +" Author: Jakson Alves de Aquino +" Last Change: Wed Jul 09, 2014 07:33PM + + +" Only load this indent file when no other was loaded. +if exists("b:did_indent") + finish +endif +runtime indent/r.vim +let s:RIndent = function(substitute(&indentexpr, "()", "", "")) +let b:did_indent = 1 + +setlocal indentkeys=0{,0},:,!^F,o,O,e +setlocal indentexpr=GetRmdIndent() + +if exists("*GetRmdIndent") + finish +endif + +function GetMdIndent() + let pline = getline(v:lnum - 1) + let cline = getline(v:lnum) + if prevnonblank(v:lnum - 1) < v:lnum - 1 || cline =~ '^\s*[-\+\*]\s' || cline =~ '^\s*\d\+\.\s\+' + return indent(v:lnum) + elseif pline =~ '^\s*[-\+\*]\s' + return indent(v:lnum - 1) + 2 + elseif pline =~ '^\s*\d\+\.\s\+' + return indent(v:lnum - 1) + 3 + endif + return indent(prevnonblank(v:lnum - 1)) +endfunction + +function GetRmdIndent() + if getline(".") =~ '^```{r .*}$' || getline(".") =~ '^```$' + return 0 + endif + if search('^```{r', "bncW") > search('^```$', "bncW") + return s:RIndent() + else + return GetMdIndent() + endif +endfunction + +" vim: sw=2 diff --git a/runtime/indent/rnoweb.vim b/runtime/indent/rnoweb.vim new file mode 100644 --- /dev/null +++ b/runtime/indent/rnoweb.vim @@ -0,0 +1,35 @@ +" Vim indent file +" Language: Rnoweb +" Author: Jakson Alves de Aquino +" Last Change: Wed Jul 09, 2014 07:28PM + + +" Only load this indent file when no other was loaded. +if exists("b:did_indent") + finish +endif +runtime indent/tex.vim +let s:TeXIndent = function(substitute(&indentexpr, "()", "", "")) +unlet b:did_indent +runtime indent/r.vim +let s:RIndent = function(substitute(&indentexpr, "()", "", "")) +let b:did_indent = 1 + +setlocal indentkeys=0{,0},!^F,o,O,e,},=\bibitem,=\item +setlocal indentexpr=GetRnowebIndent() + +if exists("*GetRnowebIndent") + finish +endif + +function GetRnowebIndent() + if getline(".") =~ "^<<.*>>=$" + return 0 + endif + if search("^<<", "bncW") > search("^@", "bncW") + return s:RIndent() + endif + return s:TeXIndent() +endfunction + +" vim: sw=2 diff --git a/runtime/indent/rrst.vim b/runtime/indent/rrst.vim new file mode 100644 --- /dev/null +++ b/runtime/indent/rrst.vim @@ -0,0 +1,46 @@ +" Vim indent file +" Language: Rrst +" Author: Jakson Alves de Aquino +" Last Change: Wed Jul 09, 2014 07:33PM + + +" Only load this indent file when no other was loaded. +if exists("b:did_indent") + finish +endif +runtime indent/r.vim +let s:RIndent = function(substitute(&indentexpr, "()", "", "")) +let b:did_indent = 1 + +setlocal indentkeys=0{,0},:,!^F,o,O,e +setlocal indentexpr=GetRrstIndent() + +if exists("*GetRrstIndent") + finish +endif + +function GetRstIndent() + let pline = getline(v:lnum - 1) + let cline = getline(v:lnum) + if prevnonblank(v:lnum - 1) < v:lnum - 1 || cline =~ '^\s*[-\+\*]\s' || cline =~ '^\s*\d\+\.\s\+' + return indent(v:lnum) + elseif pline =~ '^\s*[-\+\*]\s' + return indent(v:lnum - 1) + 2 + elseif pline =~ '^\s*\d\+\.\s\+' + return indent(v:lnum - 1) + 3 + endif + return indent(prevnonblank(v:lnum - 1)) +endfunction + +function GetRrstIndent() + if getline(".") =~ '^\.\. {r .*}$' || getline(".") =~ '^\.\. \.\.$' + return 0 + endif + if search('^\.\. {r', "bncW") > search('^\.\. \.\.$', "bncW") + return s:RIndent() + else + return GetRstIndent() + endif +endfunction + +" vim: sw=2 diff --git a/runtime/plugin/matchparen.vim b/runtime/plugin/matchparen.vim --- a/runtime/plugin/matchparen.vim +++ b/runtime/plugin/matchparen.vim @@ -1,6 +1,6 @@ " Vim plugin for showing matching parens " Maintainer: Bram Moolenaar -" Last Change: 2014 Jun 17 +" Last Change: 2014 Jul 09 " Exit quickly when: " - this plugin was already loaded (or disabled) @@ -54,14 +54,15 @@ function! s:Highlight_Matching_Pair() let c_col = col('.') let before = 0 - let c = getline(c_lnum)[c_col - 1] + let text = getline(c_lnum) + let c = text[c_col - 1] let plist = split(&matchpairs, '.\zs[:,]') let i = index(plist, c) if i < 0 " not found, in Insert mode try character before the cursor if c_col > 1 && (mode() == 'i' || mode() == 'R') let before = 1 - let c = getline(c_lnum)[c_col - 2] + let c = text[c_col - 2] let i = index(plist, c) endif if i < 0 @@ -87,7 +88,7 @@ function! s:Highlight_Matching_Pair() " Find the match. When it was just before the cursor move it there for a " moment. if before > 0 - let save_cursor = winsaveview() + let save_cursor = getcurpos() call cursor(c_lnum, c_col - before) endif @@ -147,7 +148,7 @@ function! s:Highlight_Matching_Pair() endtry if before > 0 - call winrestview(save_cursor) + call setpos('.', save_cursor) endif " If a match is found setup match highlighting. diff --git a/runtime/syntax/r.vim b/runtime/syntax/r.vim --- a/runtime/syntax/r.vim +++ b/runtime/syntax/r.vim @@ -3,7 +3,7 @@ " Maintainer: Jakson Aquino " Former Maintainers: Vaidotas Zemlys " Tom Payne -" Last Change: Sun May 19, 2013 05:59PM +" Last Change: Wed Jul 09, 2014 10:29PM " Filenames: *.R *.r *.Rhistory *.Rt " " NOTE: The highlighting of R functions is defined in the @@ -30,14 +30,16 @@ endif syn case match " Comment -syn match rComment contains=@Spell "#.*" +syn match rCommentTodo contained "\(BUG\|FIXME\|NOTE\|TODO\):" +syn match rComment contains=@Spell,rCommentTodo "#.*" " Roxygen syn match rOKeyword contained "@\(param\|return\|name\|rdname\|examples\|include\|docType\)" syn match rOKeyword contained "@\(S3method\|TODO\|aliases\|alias\|assignee\|author\|callGraphDepth\|callGraph\)" syn match rOKeyword contained "@\(callGraphPrimitives\|concept\|exportClass\|exportMethod\|exportPattern\|export\|formals\)" syn match rOKeyword contained "@\(format\|importClassesFrom\|importFrom\|importMethodsFrom\|import\|keywords\)" -syn match rOKeyword contained "@\(method\|nord\|note\|references\|seealso\|setClass\|slot\|source\|title\|usage\)" +syn match rOKeyword contained "@\(method\|noRd\|note\|references\|seealso\|setClass\|slot\|source\|title\|usage\)" +syn match rOKeyword contained "@\(family\|template\|templateVar\|description\|details\|inheritsParams\)" syn match rOComment contains=@Spell,rOKeyword "#'.*" @@ -119,7 +121,7 @@ if &filetype != "rmd" && &filetype != "r else syn match rOperator "[|!<>^~`/:]" endif -syn match rOperator "%\{2}\|%\S*%" +syn match rOperator "%\{2}\|%\S\{-}%" syn match rOpError '\*\{3}' syn match rOpError '//' syn match rOpError '&&&' @@ -164,8 +166,8 @@ syn match rLstElmt "@[a-zA-Z0-9\\._]*" c syn keyword rPreProc library require attach detach source if &filetype == "rhelp" - syn match rHelpIdent '\\method' - syn match rHelpIdent '\\S4method' + syn match rHelpIdent '\\method' + syn match rHelpIdent '\\S4method' endif " Type @@ -187,6 +189,7 @@ hi def link rArrow Statement hi def link rBoolean Boolean hi def link rBraceError Error hi def link rComment Comment +hi def link rCommentTodo Todo hi def link rOComment Comment hi def link rComplex Number hi def link rConditional Conditional diff --git a/runtime/syntax/rhelp.vim b/runtime/syntax/rhelp.vim --- a/runtime/syntax/rhelp.vim +++ b/runtime/syntax/rhelp.vim @@ -2,9 +2,7 @@ " Language: R Help File " Maintainer: Jakson Aquino " Former Maintainer: Johannes Ranke -" Last Change: Fri Oct 14, 2011 09:54PM -" Version: 0.7.4 -" SVN: $Id: rhelp.vim 90 2010-11-22 10:58:11Z ranke $ +" Last Change: Wed Jul 09, 2014 10:28PM " Remarks: - Includes R syntax highlighting in the appropriate " sections if an r.vim file is in the same directory or in the " default debian location. @@ -23,6 +21,8 @@ elseif exists("b:current_syntax") finish endif +setlocal iskeyword=@,48-57,_,. + syn case match " R help identifiers {{{1 @@ -51,7 +51,12 @@ syn region rhelpRcode matchgroup=Delimit 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 -syn region rhelpRcode matchgroup=Delimiter start="\\code{" skip='\\\@ 703 + syn region rhelpRcode matchgroup=Delimiter start="\\code{" skip='\\\@1 703 + syn region rhelpVerbatim matchgroup=rhelpType start="\\samp{" skip='\\\@1" @@ -200,6 +210,8 @@ syn match rhelpBraceError /[)}]/ contain syn match rhelpCurlyError /[)\]]/ contained syn match rhelpParenError /[\]}]/ contained +syntax sync match rhelpSyncRcode grouphere rhelpRcode "\\examples{" + " 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 @@ -233,4 +245,5 @@ if version >= 508 || !exists("did_rhelp_ endif let b:current_syntax = "rhelp" -" vim: foldmethod=marker: + +" vim: foldmethod=marker sw=2 diff --git a/runtime/syntax/rmd.vim b/runtime/syntax/rmd.vim new file mode 100644 --- /dev/null +++ b/runtime/syntax/rmd.vim @@ -0,0 +1,87 @@ +" markdown Text with R statements +" Language: markdown with R code chunks +" Last Change: Wed Jul 09, 2014 10:29PM +" +" CONFIGURATION: +" To highlight chunk headers as R code, put in your vimrc: +" let rmd_syn_hl_chunk = 1 + +" for portability +if version < 600 + syntax clear +elseif exists("b:current_syntax") + finish +endif + +" load all of pandoc info +runtime syntax/pandoc.vim +if exists("b:current_syntax") + let rmdIsPandoc = 1 + unlet b:current_syntax +else + let rmdIsPandoc = 0 + runtime syntax/markdown.vim + if exists("b:current_syntax") + unlet b:current_syntax + endif +endif + +" load all of the r syntax highlighting rules into @R +syntax include @R syntax/r.vim +if exists("b:current_syntax") + unlet b:current_syntax +endif + +if exists("g:rmd_syn_hl_chunk") + " highlight R code inside chunk header + syntax match rmdChunkDelim "^[ \t]*```{r" contained + syntax match rmdChunkDelim "}$" contained +else + syntax match rmdChunkDelim "^[ \t]*```{r.*}$" contained +endif +syntax match rmdChunkDelim "^[ \t]*```$" contained +syntax region rmdChunk start="^[ \t]*``` *{r.*}$" end="^[ \t]*```$" contains=@R,rmdChunkDelim keepend fold + +" also match and syntax highlight in-line R code +syntax match rmdEndInline "`" contained +syntax match rmdBeginInline "`r " contained +syntax region rmdrInline start="`r " end="`" contains=@R,rmdBeginInline,rmdEndInline keepend + +" match slidify special marker +syntax match rmdSlidifySpecial "\*\*\*" + + +if rmdIsPandoc == 0 + syn match rmdBlockQuote /^\s*>.*\n\(.*\n\@" contains=@texMathZoneGroup + " Region + syntax match rmdLaTeXRegDelim "\$\$" contained + syntax match rmdLaTeXRegDelim "\$\$latex$" contained + syntax region rmdLaTeXRegion start="^\$\$" skip="\\\$" end="\$\$$" contains=@LaTeX,rmdLaTeXSt,rmdLaTeXRegDelim keepend + syntax region rmdLaTeXRegion2 start="^\\\[" end="\\\]" contains=@LaTeX,rmdLaTeXSt,rmdLaTeXRegDelim keepend + hi def link rmdLaTeXSt Statement + hi def link rmdLaTeXInlDelim Special + hi def link rmdLaTeXRegDelim Special +endif + +setlocal iskeyword=@,48-57,_,. + +syn sync match rmdSyncChunk grouphere rmdChunk "^[ \t]*``` *{r" + +hi def link rmdChunkDelim Special +hi def link rmdBeginInline Special +hi def link rmdEndInline Special +hi def link rmdBlockQuote Comment +hi def link rmdSlidifySpecial Special + +let b:current_syntax = "rmd" + +" vim: ts=8 sw=2 diff --git a/runtime/syntax/rrst.vim b/runtime/syntax/rrst.vim new file mode 100644 --- /dev/null +++ b/runtime/syntax/rrst.vim @@ -0,0 +1,47 @@ +" reStructured Text with R statements +" Language: reST with R code chunks +" Maintainer: Alex Zvoleff, azvoleff@mail.sdsu.edu +" Last Change: Wed Jul 09, 2014 10:29PM +" +" CONFIGURATION: +" To highlight chunk headers as R code, put in your vimrc: +" let rrst_syn_hl_chunk = 1 + +" for portability +if version < 600 + syntax clear +elseif exists("b:current_syntax") + finish +endif + +" load all of the rst info +runtime syntax/rst.vim +unlet b:current_syntax + +" load all of the r syntax highlighting rules into @R +syntax include @R syntax/r.vim + +setlocal iskeyword=@,48-57,_,. + +" highlight R chunks +if exists("g:rrst_syn_hl_chunk") + " highlight R code inside chunk header + syntax match rrstChunkDelim "^\.\. {r" contained + syntax match rrstChunkDelim "}$" contained +else + syntax match rrstChunkDelim "^\.\. {r .*}$" contained +endif +syntax match rrstChunkDelim "^\.\. \.\.$" contained +syntax region rrstChunk start="^\.\. {r.*}$" end="^\.\. \.\.$" contains=@R,rrstChunkDelim keepend transparent fold + +" also highlight in-line R code +syntax match rrstInlineDelim "`" contained +syntax match rrstInlineDelim ":r:" contained +syntax region rrstInline start=":r: *`" skip=/\\\\\|\\`/ end="`" contains=@R,rrstInlineDelim keepend + +hi def link rrstChunkDelim Special +hi def link rrstInlineDelim Special + +let b:current_syntax = "rrst" + +" vim: ts=8 sw=2