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