xref: /vim-8.2.3635/runtime/syntax/rmd.vim (revision cb03397a)
1" markdown Text with R statements
2" Language: markdown with R code chunks
3" Homepage: https://github.com/jalvesaq/R-Vim-runtime
4" Last Change: Tue Jun 28, 2016  10:09AM
5"
6" CONFIGURATION:
7"   To highlight chunk headers as R code, put in your vimrc:
8"   let rmd_syn_hl_chunk = 1
9
10if exists("b:current_syntax")
11  finish
12endif
13
14" load all of pandoc info
15runtime syntax/pandoc.vim
16if exists("b:current_syntax")
17  let rmdIsPandoc = 1
18  unlet b:current_syntax
19else
20  let rmdIsPandoc = 0
21  runtime syntax/markdown.vim
22  if exists("b:current_syntax")
23    unlet b:current_syntax
24  endif
25endif
26
27" load all of the r syntax highlighting rules into @R
28syntax include @R syntax/r.vim
29if exists("b:current_syntax")
30  unlet b:current_syntax
31endif
32
33if exists("g:rmd_syn_hl_chunk")
34  " highlight R code inside chunk header
35  syntax match rmdChunkDelim "^[ \t]*```{r" contained
36  syntax match rmdChunkDelim "}$" contained
37else
38  syntax match rmdChunkDelim "^[ \t]*```{r.*}$" contained
39endif
40syntax match rmdChunkDelim "^[ \t]*```$" contained
41syntax region rmdChunk start="^[ \t]*``` *{r.*}$" end="^[ \t]*```$" contains=@R,rmdChunkDelim keepend fold
42
43" also match and syntax highlight in-line R code
44syntax match rmdEndInline "`" contained
45syntax match rmdBeginInline "`r " contained
46syntax region rmdrInline start="`r "  end="`" contains=@R,rmdBeginInline,rmdEndInline keepend
47
48" match slidify special marker
49syntax match rmdSlidifySpecial "\*\*\*"
50
51
52if rmdIsPandoc == 0
53  syn match rmdBlockQuote /^\s*>.*\n\(.*\n\@<!\n\)*/ skipnl
54  " LaTeX
55  syntax include @LaTeX syntax/tex.vim
56  if exists("b:current_syntax")
57    unlet b:current_syntax
58  endif
59  " Extend cluster
60  syn cluster texMathZoneGroup add=rmdrInline
61  " Inline
62  syntax match rmdLaTeXInlDelim "\$"
63  syntax match rmdLaTeXInlDelim "\\\$"
64  syn region texMathZoneX	matchgroup=Delimiter start="\$" skip="\\\\\|\\\$"	matchgroup=Delimiter end="\$" end="%stopzone\>"	contains=@texMathZoneGroup
65  " Region
66  syntax match rmdLaTeXRegDelim "\$\$" contained
67  syntax match rmdLaTeXRegDelim "\$\$latex$" contained
68  syntax region rmdLaTeXRegion start="^\$\$" skip="\\\$" end="\$\$$" contains=@LaTeX,rmdLaTeXSt,rmdLaTeXRegDelim keepend
69  syntax region rmdLaTeXRegion2 start="^\\\[" end="\\\]" contains=@LaTeX,rmdLaTeXSt,rmdLaTeXRegDelim keepend
70  hi def link rmdLaTeXSt Statement
71  hi def link rmdLaTeXInlDelim Special
72  hi def link rmdLaTeXRegDelim Special
73endif
74
75syn sync match rmdSyncChunk grouphere rmdChunk "^[ \t]*``` *{r"
76
77hi def link rmdChunkDelim Special
78hi def link rmdBeginInline Special
79hi def link rmdEndInline Special
80hi def link rmdBlockQuote Comment
81hi def link rmdSlidifySpecial Special
82
83let b:current_syntax = "rmd"
84
85" vim: ts=8 sw=2
86