blob: 4667b3a2c1bbc6dc7b7905513610c2bb447be062 [file] [log] [blame]
Bram Moolenaardb6ea062014-07-10 22:01:47 +02001" reStructured Text with R statements
2" Language: reST with R code chunks
3" Maintainer: Alex Zvoleff, azvoleff@mail.sdsu.edu
4" Last Change: Wed Jul 09, 2014 10:29PM
5"
6" CONFIGURATION:
7" To highlight chunk headers as R code, put in your vimrc:
8" let rrst_syn_hl_chunk = 1
9
10" for portability
11if version < 600
12 syntax clear
13elseif exists("b:current_syntax")
14 finish
15endif
16
17" load all of the rst info
18runtime syntax/rst.vim
19unlet b:current_syntax
20
21" load all of the r syntax highlighting rules into @R
22syntax include @R syntax/r.vim
23
24setlocal iskeyword=@,48-57,_,.
25
26" highlight R chunks
27if exists("g:rrst_syn_hl_chunk")
28 " highlight R code inside chunk header
29 syntax match rrstChunkDelim "^\.\. {r" contained
30 syntax match rrstChunkDelim "}$" contained
31else
32 syntax match rrstChunkDelim "^\.\. {r .*}$" contained
33endif
34syntax match rrstChunkDelim "^\.\. \.\.$" contained
35syntax region rrstChunk start="^\.\. {r.*}$" end="^\.\. \.\.$" contains=@R,rrstChunkDelim keepend transparent fold
36
37" also highlight in-line R code
38syntax match rrstInlineDelim "`" contained
39syntax match rrstInlineDelim ":r:" contained
40syntax region rrstInline start=":r: *`" skip=/\\\\\|\\`/ end="`" contains=@R,rrstInlineDelim keepend
41
42hi def link rrstChunkDelim Special
43hi def link rrstInlineDelim Special
44
45let b:current_syntax = "rrst"
46
47" vim: ts=8 sw=2