Mercurial > vim
annotate runtime/syntax/rmd.vim @ 14216:12bdbf9f7e20 v8.1.0125
patch 8.1.0125: virtual edit replace with multi-byte fails at end of line
commit https://github.com/vim/vim/commit/630afe889a2a02b367ea8eaaa48e66ed81e77ff3
Author: Bram Moolenaar <Bram@vim.org>
Date: Thu Jun 28 19:26:28 2018 +0200
patch 8.1.0125: virtual edit replace with multi-byte fails at end of line
Problem: Virtual edit replace with multi-byte fails at end of line. (Lukas
Werling)
Solution: use ins_char() to add the character. (Christian Brabandt,
closes #3114) Rename PCHAR() to PBYTE() to avoid mistakes like
this.
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Thu, 28 Jun 2018 19:30:07 +0200 |
parents | 4aae8146c21f |
children | 0ecb909e3249 |
rev | line source |
---|---|
6051 | 1 " markdown Text with R statements |
2 " Language: markdown with R code chunks | |
8497
da01d5da2cfa
commit https://github.com/vim/vim/commit/77cdfd10382e01cc51f4ba1a9177032351843151
Christian Brabandt <cb@256bit.org>
parents:
6051
diff
changeset
|
3 " Homepage: https://github.com/jalvesaq/R-Vim-runtime |
11347 | 4 " Last Change: Sat Jan 28, 2017 10:06PM |
6051 | 5 " |
6 " CONFIGURATION: | |
11347 | 7 " To highlight chunk headers as R code, put in your vimrc (e.g. .config/nvim/init.vim): |
6051 | 8 " let rmd_syn_hl_chunk = 1 |
11347 | 9 " |
10 " For highlighting pandoc extensions to markdown like citations and TeX and | |
11 " many other advanced features like folding of markdown sections, it is | |
12 " recommended to install the vim-pandoc filetype plugin as well as the | |
13 " vim-pandoc-syntax filetype plugin from https://github.com/vim-pandoc. | |
14 " | |
15 " TODO: | |
16 " - Provide highlighting for rmarkdown parameters in yaml header | |
6051 | 17 |
8497
da01d5da2cfa
commit https://github.com/vim/vim/commit/77cdfd10382e01cc51f4ba1a9177032351843151
Christian Brabandt <cb@256bit.org>
parents:
6051
diff
changeset
|
18 if exists("b:current_syntax") |
6051 | 19 finish |
20 endif | |
21 | |
11347 | 22 " load all of pandoc info, e.g. from |
23 " https://github.com/vim-pandoc/vim-pandoc-syntax | |
6051 | 24 runtime syntax/pandoc.vim |
25 if exists("b:current_syntax") | |
26 let rmdIsPandoc = 1 | |
27 unlet b:current_syntax | |
28 else | |
29 let rmdIsPandoc = 0 | |
30 runtime syntax/markdown.vim | |
31 if exists("b:current_syntax") | |
32 unlet b:current_syntax | |
33 endif | |
34 | |
11347 | 35 " load all of the yaml syntax highlighting rules into @yaml |
36 syntax include @yaml syntax/yaml.vim | |
37 if exists("b:current_syntax") | |
38 unlet b:current_syntax | |
39 endif | |
40 | |
41 " highlight yaml block commonly used for front matter | |
42 syntax region rmdYamlBlock matchgroup=rmdYamlBlockDelim start="^---" matchgroup=rmdYamlBlockDelim end="^---" contains=@yaml keepend fold | |
6051 | 43 endif |
44 | |
11347 | 45 if !exists("g:rmd_syn_langs") |
46 let g:rmd_syn_langs = ["r"] | |
6051 | 47 else |
11347 | 48 let s:hasr = 0 |
49 for s:lng in g:rmd_syn_langs | |
50 if s:lng == "r" | |
51 let s:hasr = 1 | |
52 endif | |
53 endfor | |
54 if s:hasr == 0 | |
55 let g:rmd_syn_langs += ["r"] | |
56 endif | |
6051 | 57 endif |
11347 | 58 |
59 for s:lng in g:rmd_syn_langs | |
60 exe 'syntax include @' . toupper(s:lng) . ' syntax/'. s:lng . '.vim' | |
61 if exists("b:current_syntax") | |
62 unlet b:current_syntax | |
63 endif | |
64 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' | |
65 | |
66 if exists("g:rmd_syn_hl_chunk") && s:lng == "r" | |
67 " highlight R code inside chunk header | |
68 syntax match rmdRChunkDelim "^[ \t]*```{r" contained | |
69 syntax match rmdRChunkDelim "}$" contained | |
70 else | |
71 exe 'syntax match rmd' . toupper(s:lng) . 'ChunkDelim "^[ \t]*```{\(' . s:lng . '\|r.*engine\s*=\s*["' . "']" . s:lng . "['" . '"]\).*}$" contained' | |
72 endif | |
73 exe 'syntax match rmd' . toupper(s:lng) . 'ChunkDelim "^[ \t]*```$" contained' | |
74 endfor | |
75 | |
6051 | 76 |
77 " also match and syntax highlight in-line R code | |
11347 | 78 syntax region rmdrInline matchgroup=rmdInlineDelim start="`r " end="`" contains=@R containedin=pandocLaTeXRegion,yamlFlowString keepend |
79 " I was not able to highlight rmdrInline inside a pandocLaTeXCommand, although | |
80 " highlighting works within pandocLaTeXRegion and yamlFlowString. | |
81 syntax cluster texMathZoneGroup add=rmdrInline | |
6051 | 82 |
83 " match slidify special marker | |
84 syntax match rmdSlidifySpecial "\*\*\*" | |
85 | |
86 | |
87 if rmdIsPandoc == 0 | |
88 syn match rmdBlockQuote /^\s*>.*\n\(.*\n\@<!\n\)*/ skipnl | |
89 " LaTeX | |
90 syntax include @LaTeX syntax/tex.vim | |
91 if exists("b:current_syntax") | |
92 unlet b:current_syntax | |
93 endif | |
94 " Inline | |
95 syntax match rmdLaTeXInlDelim "\$" | |
96 syntax match rmdLaTeXInlDelim "\\\$" | |
97 syn region texMathZoneX matchgroup=Delimiter start="\$" skip="\\\\\|\\\$" matchgroup=Delimiter end="\$" end="%stopzone\>" contains=@texMathZoneGroup | |
98 " Region | |
99 syntax match rmdLaTeXRegDelim "\$\$" contained | |
100 syntax match rmdLaTeXRegDelim "\$\$latex$" contained | |
11347 | 101 syntax match rmdLaTeXSt "\\[a-zA-Z]\+" |
102 syntax region rmdLaTeXRegion start="^\$\$" skip="\\\$" end="\$\$$" contains=@LaTeX,rmdLaTeXRegDelim keepend | |
103 syntax region rmdLaTeXRegion2 start="^\\\[" end="\\\]" contains=@LaTeX,rmdLaTeXRegDelim keepend | |
104 hi def link rmdBlockQuote Comment | |
6051 | 105 hi def link rmdLaTeXSt Statement |
106 hi def link rmdLaTeXInlDelim Special | |
107 hi def link rmdLaTeXRegDelim Special | |
108 endif | |
109 | |
11347 | 110 for s:lng in g:rmd_syn_langs |
111 exe 'syn sync match rmd' . toupper(s:lng) . 'SyncChunk grouphere rmd' . toupper(s:lng) . 'Chunk /^[ \t]*``` *{\(' . s:lng . '\|r.*engine\s*=\s*["' . "']" . s:lng . "['" . '"]\)/' | |
112 endfor | |
6051 | 113 |
11347 | 114 hi def link rmdYamlBlockDelim Delim |
115 for s:lng in g:rmd_syn_langs | |
116 exe 'hi def link rmd' . toupper(s:lng) . 'ChunkDelim Special' | |
117 endfor | |
118 hi def link rmdInlineDelim Special | |
6051 | 119 hi def link rmdSlidifySpecial Special |
120 | |
121 let b:current_syntax = "rmd" | |
122 | |
123 " vim: ts=8 sw=2 |