Update runtime files.
This commit is contained in:
@ -1,17 +1,26 @@
|
||||
" markdown Text with R statements
|
||||
" Language: markdown with R code chunks
|
||||
" Homepage: https://github.com/jalvesaq/R-Vim-runtime
|
||||
" Last Change: Tue Jun 28, 2016 10:09AM
|
||||
" Last Change: Sat Jan 28, 2017 10:06PM
|
||||
"
|
||||
" CONFIGURATION:
|
||||
" To highlight chunk headers as R code, put in your vimrc:
|
||||
" To highlight chunk headers as R code, put in your vimrc (e.g. .config/nvim/init.vim):
|
||||
" let rmd_syn_hl_chunk = 1
|
||||
"
|
||||
" For highlighting pandoc extensions to markdown like citations and TeX and
|
||||
" many other advanced features like folding of markdown sections, it is
|
||||
" recommended to install the vim-pandoc filetype plugin as well as the
|
||||
" vim-pandoc-syntax filetype plugin from https://github.com/vim-pandoc.
|
||||
"
|
||||
" TODO:
|
||||
" - Provide highlighting for rmarkdown parameters in yaml header
|
||||
|
||||
if exists("b:current_syntax")
|
||||
finish
|
||||
endif
|
||||
|
||||
" load all of pandoc info
|
||||
" load all of pandoc info, e.g. from
|
||||
" https://github.com/vim-pandoc/vim-pandoc-syntax
|
||||
runtime syntax/pandoc.vim
|
||||
if exists("b:current_syntax")
|
||||
let rmdIsPandoc = 1
|
||||
@ -22,28 +31,54 @@ else
|
||||
if exists("b:current_syntax")
|
||||
unlet b:current_syntax
|
||||
endif
|
||||
|
||||
" load all of the yaml syntax highlighting rules into @yaml
|
||||
syntax include @yaml syntax/yaml.vim
|
||||
if exists("b:current_syntax")
|
||||
unlet b:current_syntax
|
||||
endif
|
||||
|
||||
" highlight yaml block commonly used for front matter
|
||||
syntax region rmdYamlBlock matchgroup=rmdYamlBlockDelim start="^---" matchgroup=rmdYamlBlockDelim end="^---" contains=@yaml keepend fold
|
||||
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
|
||||
if !exists("g:rmd_syn_langs")
|
||||
let g:rmd_syn_langs = ["r"]
|
||||
else
|
||||
syntax match rmdChunkDelim "^[ \t]*```{r.*}$" contained
|
||||
let s:hasr = 0
|
||||
for s:lng in g:rmd_syn_langs
|
||||
if s:lng == "r"
|
||||
let s:hasr = 1
|
||||
endif
|
||||
endfor
|
||||
if s:hasr == 0
|
||||
let g:rmd_syn_langs += ["r"]
|
||||
endif
|
||||
endif
|
||||
syntax match rmdChunkDelim "^[ \t]*```$" contained
|
||||
syntax region rmdChunk start="^[ \t]*``` *{r.*}$" end="^[ \t]*```$" contains=@R,rmdChunkDelim keepend fold
|
||||
|
||||
for s:lng in g:rmd_syn_langs
|
||||
exe 'syntax include @' . toupper(s:lng) . ' syntax/'. s:lng . '.vim'
|
||||
if exists("b:current_syntax")
|
||||
unlet b:current_syntax
|
||||
endif
|
||||
exe 'syntax region rmd' . toupper(s:lng) . 'Chunk start="^[ \t]*``` *{\(' . s:lng . '\|r.*engine\s*=\s*["' . "']" . s:lng . "['" . '"]\).*}$" end="^[ \t]*```$" contains=@' . toupper(s:lng) . ',rmd' . toupper(s:lng) . 'ChunkDelim keepend fold'
|
||||
|
||||
if exists("g:rmd_syn_hl_chunk") && s:lng == "r"
|
||||
" highlight R code inside chunk header
|
||||
syntax match rmdRChunkDelim "^[ \t]*```{r" contained
|
||||
syntax match rmdRChunkDelim "}$" contained
|
||||
else
|
||||
exe 'syntax match rmd' . toupper(s:lng) . 'ChunkDelim "^[ \t]*```{\(' . s:lng . '\|r.*engine\s*=\s*["' . "']" . s:lng . "['" . '"]\).*}$" contained'
|
||||
endif
|
||||
exe 'syntax match rmd' . toupper(s:lng) . 'ChunkDelim "^[ \t]*```$" contained'
|
||||
endfor
|
||||
|
||||
|
||||
" 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
|
||||
syntax region rmdrInline matchgroup=rmdInlineDelim start="`r " end="`" contains=@R containedin=pandocLaTeXRegion,yamlFlowString keepend
|
||||
" I was not able to highlight rmdrInline inside a pandocLaTeXCommand, although
|
||||
" highlighting works within pandocLaTeXRegion and yamlFlowString.
|
||||
syntax cluster texMathZoneGroup add=rmdrInline
|
||||
|
||||
" match slidify special marker
|
||||
syntax match rmdSlidifySpecial "\*\*\*"
|
||||
@ -56,8 +91,6 @@ if rmdIsPandoc == 0
|
||||
if exists("b:current_syntax")
|
||||
unlet b:current_syntax
|
||||
endif
|
||||
" Extend cluster
|
||||
syn cluster texMathZoneGroup add=rmdrInline
|
||||
" Inline
|
||||
syntax match rmdLaTeXInlDelim "\$"
|
||||
syntax match rmdLaTeXInlDelim "\\\$"
|
||||
@ -65,19 +98,24 @@ if rmdIsPandoc == 0
|
||||
" 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
|
||||
syntax match rmdLaTeXSt "\\[a-zA-Z]\+"
|
||||
syntax region rmdLaTeXRegion start="^\$\$" skip="\\\$" end="\$\$$" contains=@LaTeX,rmdLaTeXRegDelim keepend
|
||||
syntax region rmdLaTeXRegion2 start="^\\\[" end="\\\]" contains=@LaTeX,rmdLaTeXRegDelim keepend
|
||||
hi def link rmdBlockQuote Comment
|
||||
hi def link rmdLaTeXSt Statement
|
||||
hi def link rmdLaTeXInlDelim Special
|
||||
hi def link rmdLaTeXRegDelim Special
|
||||
endif
|
||||
|
||||
syn sync match rmdSyncChunk grouphere rmdChunk "^[ \t]*``` *{r"
|
||||
for s:lng in g:rmd_syn_langs
|
||||
exe 'syn sync match rmd' . toupper(s:lng) . 'SyncChunk grouphere rmd' . toupper(s:lng) . 'Chunk /^[ \t]*``` *{\(' . s:lng . '\|r.*engine\s*=\s*["' . "']" . s:lng . "['" . '"]\)/'
|
||||
endfor
|
||||
|
||||
hi def link rmdChunkDelim Special
|
||||
hi def link rmdBeginInline Special
|
||||
hi def link rmdEndInline Special
|
||||
hi def link rmdBlockQuote Comment
|
||||
hi def link rmdYamlBlockDelim Delim
|
||||
for s:lng in g:rmd_syn_langs
|
||||
exe 'hi def link rmd' . toupper(s:lng) . 'ChunkDelim Special'
|
||||
endfor
|
||||
hi def link rmdInlineDelim Special
|
||||
hi def link rmdSlidifySpecial Special
|
||||
|
||||
let b:current_syntax = "rmd"
|
||||
|
||||
Reference in New Issue
Block a user