Mercurial > vim
comparison runtime/syntax/rmd.vim @ 24520:5bda4653aced
Update runtime files
Commit: https://github.com/vim/vim/commit/11e3c5ba820325b69cb56f70e13c21d7b8808d33
Author: Bram Moolenaar <Bram@vim.org>
Date: Wed Apr 21 18:09:37 2021 +0200
Update runtime files
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Wed, 21 Apr 2021 18:15:04 +0200 |
parents | 1eaf34420bb3 |
children | b2412874362f |
comparison
equal
deleted
inserted
replaced
24519:da748a66a65a | 24520:5bda4653aced |
---|---|
1 " markdown Text with R statements | 1 " markdown Text with R statements |
2 " Language: markdown with R code chunks | 2 " Language: markdown with R code chunks |
3 " Homepage: https://github.com/jalvesaq/R-Vim-runtime | 3 " Homepage: https://github.com/jalvesaq/R-Vim-runtime |
4 " Last Change: Thu Apr 18, 2019 09:17PM | 4 " Last Change: Wed Apr 21, 2021 09:55AM |
5 " | 5 " |
6 " For highlighting pandoc extensions to markdown like citations and TeX and | 6 " For highlighting pandoc extensions to markdown like citations and TeX and |
7 " many other advanced features like folding of markdown sections, it is | 7 " many other advanced features like folding of markdown sections, it is |
8 " recommended to install the vim-pandoc filetype plugin as well as the | 8 " recommended to install the vim-pandoc filetype plugin as well as the |
9 " vim-pandoc-syntax filetype plugin from https://github.com/vim-pandoc. | 9 " vim-pandoc-syntax filetype plugin from https://github.com/vim-pandoc. |
11 | 11 |
12 if exists("b:current_syntax") | 12 if exists("b:current_syntax") |
13 finish | 13 finish |
14 endif | 14 endif |
15 | 15 |
16 " Configuration if not using pandoc syntax: | 16 " Highlight the header of the chunks as R code |
17 " Add syntax highlighting of YAML header | 17 let g:rmd_syn_hl_chunk = get(g:, 'rmd_syn_hl_chunk', 0) |
18 let g:rmd_syn_hl_yaml = get(g:, 'rmd_syn_hl_yaml', 1) | |
19 " Add syntax highlighting of citation keys | |
20 let g:rmd_syn_hl_citations = get(g:, 'rmd_syn_hl_citations', 1) | |
21 " Highlight the header of the chunk of R code | |
22 let g:rmd_syn_hl_chunk = get(g:, 'g:rmd_syn_hl_chunk', 0) | |
23 | 18 |
24 " Pandoc-syntax has more features, but it is slower. | 19 " Pandoc-syntax has more features, but it is slower. |
25 " https://github.com/vim-pandoc/vim-pandoc-syntax | 20 " https://github.com/vim-pandoc/vim-pandoc-syntax |
26 let g:pandoc#syntax#codeblocks#embeds#langs = get(g:, 'pandoc#syntax#codeblocks#embeds#langs', ['r']) | 21 let g:pandoc#syntax#codeblocks#embeds#langs = get(g:, 'pandoc#syntax#codeblocks#embeds#langs', ['r']) |
27 runtime syntax/pandoc.vim | 22 runtime syntax/pandoc.vim |
28 if exists("b:current_syntax") | 23 if exists("b:current_syntax") |
29 " Fix recognition of R code | 24 " Recognize inline R code |
30 syn region pandocDelimitedCodeBlock_r start=/^```{r\>.*}$/ end=/^```$/ contained containedin=pandocDelimitedCodeBlock contains=@R | |
31 syn region rmdrInline matchgroup=rmdInlineDelim start="`r " end="`" contains=@R containedin=pandocLaTeXRegion,yamlFlowString keepend | 25 syn region rmdrInline matchgroup=rmdInlineDelim start="`r " end="`" contains=@R containedin=pandocLaTeXRegion,yamlFlowString keepend |
32 hi def link rmdInlineDelim Delimiter | 26 hi def link rmdInlineDelim Delimiter |
27 | |
28 " Fix recognition of language chunks (code adapted from pandoc, 2021-03-28) | |
29 " Knitr requires braces in the block's header | |
30 for s:lng in g:pandoc#syntax#codeblocks#embeds#langs | |
31 let s:nm = matchstr(s:lng, '^[^=]*') | |
32 exe 'syn clear pandocDelimitedCodeBlock_'.s:nm | |
33 exe 'syn clear pandocDelimitedCodeBlockinBlockQuote_'.s:nm | |
34 if g:rmd_syn_hl_chunk | |
35 exe 'syn region rmd'.s:nm.'ChunkDelim matchgroup=rmdCodeDelim start="^\s*```\s*{\s*'.s:nm.'\>" matchgroup=rmdCodeDelim end="}$" keepend containedin=rmd'.s:nm.'Chunk contains=@R' | |
36 exe 'syn region rmd'.s:nm.'Chunk start="^\s*```\s*{\s*'.s:nm.'\>.*$" matchgroup=rmdCodeDelim end="^\s*```\ze\s*$" keepend contains=rmd'.s:nm.'ChunkDelim,@'.toupper(s:nm) | |
37 else | |
38 exe 'syn region rmd'.s:nm.'Chunk matchgroup=rmdCodeDelim start="^\s*```\s*{\s*'.s:nm.'\>.*$" matchgroup=rmdCodeDelim end="^\s*```\ze\s*$" keepend contains=@'.toupper(s:nm) | |
39 endif | |
40 endfor | |
41 unlet s:lng | |
42 unlet s:nm | |
43 hi def link rmdInlineDelim Delimiter | |
44 hi def link rmdCodeDelim Delimiter | |
33 let b:current_syntax = "rmd" | 45 let b:current_syntax = "rmd" |
34 finish | 46 finish |
35 endif | 47 endif |
48 | |
49 " Configuration if not using pandoc syntax: | |
50 " Add syntax highlighting of YAML header | |
51 let g:rmd_syn_hl_yaml = get(g:, 'rmd_syn_hl_yaml', 1) | |
52 " Add syntax highlighting of citation keys | |
53 let g:rmd_syn_hl_citations = get(g:, 'rmd_syn_hl_citations', 1) | |
36 | 54 |
37 let s:cpo_save = &cpo | 55 let s:cpo_save = &cpo |
38 set cpo&vim | 56 set cpo&vim |
39 | 57 |
40 " R chunks will not be highlighted by syntax/markdown because their headers | 58 " R chunks will not be highlighted by syntax/markdown because their headers |
61 let s:nm = s:type | 79 let s:nm = s:type |
62 endif | 80 endif |
63 unlet! b:current_syntax | 81 unlet! b:current_syntax |
64 exe 'syn include @Rmd'.s:nm.' syntax/'.s:ft.'.vim' | 82 exe 'syn include @Rmd'.s:nm.' syntax/'.s:ft.'.vim' |
65 if g:rmd_syn_hl_chunk | 83 if g:rmd_syn_hl_chunk |
66 exe 'syn region rmd'.s:nm.'ChunkDelim matchgroup=rmdCodeDelim start="^\s*```\s*{\s*'.s:nm.'\>" matchgroup=rmdCodeDelim end="}$" keepend containedin=rmd'.s:nm.'Chunk contains=@Rmd'.s:nm | 84 exe 'syn region rmd'.s:nm.'ChunkDelim matchgroup=rmdCodeDelim start="^\s*```\s*{\s*'.s:nm.'\>" matchgroup=rmdCodeDelim end="}$" keepend containedin=rmd'.s:nm.'Chunk contains=@Rmdr' |
67 exe 'syn region rmd'.s:nm.'Chunk start="^\s*```\s*{\s*'.s:nm.'\>.*$" matchgroup=rmdCodeDelim end="^\s*```\ze\s*$" keepend contains=rmd'.s:nm.'ChunkDelim,@Rmd'.s:nm | 85 exe 'syn region rmd'.s:nm.'Chunk start="^\s*```\s*{\s*'.s:nm.'\>.*$" matchgroup=rmdCodeDelim end="^\s*```\ze\s*$" keepend contains=rmd'.s:nm.'ChunkDelim,@Rmd'.s:nm |
68 else | 86 else |
69 exe 'syn region rmd'.s:nm.'Chunk matchgroup=rmdCodeDelim start="^\s*```\s*{\s*'.s:nm.'\>.*$" matchgroup=rmdCodeDelim end="^\s*```\ze\s*$" keepend contains=@Rmd'.s:nm | 87 exe 'syn region rmd'.s:nm.'Chunk matchgroup=rmdCodeDelim start="^\s*```\s*{\s*'.s:nm.'\>.*$" matchgroup=rmdCodeDelim end="^\s*```\ze\s*$" keepend contains=@Rmd'.s:nm |
70 endif | 88 endif |
71 exe 'syn region rmd'.s:nm.'Inline matchgroup=rmdInlineDelim start="`'.s:nm.' " end="`" contains=@Rmd'.s:nm.' keepend' | |
72 endfor | 89 endfor |
73 unlet! s:type | 90 unlet! s:type |
91 | |
92 " Recognize inline R code | |
93 syn region rmdrInline matchgroup=rmdInlineDelim start="`r " end="`" contains=@Rmdr keepend | |
74 | 94 |
75 hi def link rmdInlineDelim Delimiter | 95 hi def link rmdInlineDelim Delimiter |
76 hi def link rmdCodeDelim Delimiter | 96 hi def link rmdCodeDelim Delimiter |
77 | 97 |
78 " You don't need this if either your markdown/syntax.vim already highlights | 98 " You don't need this if either your markdown/syntax.vim already highlights |