annotate runtime/syntax/rmd.vim @ 20559:533bbd1917be v8.2.0833

patch 8.2.0833: mapping <C-bslash> doesn't work in the GUI Commit: https://github.com/vim/vim/commit/ca5bc746073b6fd4b7651bc02f7a18b1b43bd4ca Author: Bram Moolenaar <Bram@vim.org> Date: Wed May 27 22:08:34 2020 +0200 patch 8.2.0833: mapping <C-bslash> doesn't work in the GUI Problem: Mapping <C-bslash> doesn't work in the GUI. Solution: Reset seenModifyOtherKeys when starting the GUI. (closes https://github.com/vim/vim/issues/6150)
author Bram Moolenaar <Bram@vim.org>
date Wed, 27 May 2020 22:15:04 +0200
parents 1eaf34420bb3
children 5bda4653aced
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
16610
1eaf34420bb3 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 14637
diff changeset
4 " Last Change: Thu Apr 18, 2019 09:17PM
11347
4aae8146c21f Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 9975
diff changeset
5 "
4aae8146c21f Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 9975
diff changeset
6 " For highlighting pandoc extensions to markdown like citations and TeX and
4aae8146c21f Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 9975
diff changeset
7 " many other advanced features like folding of markdown sections, it is
4aae8146c21f Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 9975
diff changeset
8 " 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
9 " vim-pandoc-syntax filetype plugin from https://github.com/vim-pandoc.
14637
0ecb909e3249 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11347
diff changeset
10
6051
0efec12f52ac Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
11
8497
da01d5da2cfa commit https://github.com/vim/vim/commit/77cdfd10382e01cc51f4ba1a9177032351843151
Christian Brabandt <cb@256bit.org>
parents: 6051
diff changeset
12 if exists("b:current_syntax")
6051
0efec12f52ac Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
13 finish
0efec12f52ac Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
14 endif
0efec12f52ac Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
15
14637
0ecb909e3249 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11347
diff changeset
16 " Configuration if not using pandoc syntax:
0ecb909e3249 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11347
diff changeset
17 " Add syntax highlighting of YAML header
0ecb909e3249 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11347
diff changeset
18 let g:rmd_syn_hl_yaml = get(g:, 'rmd_syn_hl_yaml', 1)
0ecb909e3249 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11347
diff changeset
19 " Add syntax highlighting of citation keys
0ecb909e3249 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11347
diff changeset
20 let g:rmd_syn_hl_citations = get(g:, 'rmd_syn_hl_citations', 1)
0ecb909e3249 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11347
diff changeset
21 " Highlight the header of the chunk of R code
0ecb909e3249 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11347
diff changeset
22 let g:rmd_syn_hl_chunk = get(g:, 'g:rmd_syn_hl_chunk', 0)
0ecb909e3249 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11347
diff changeset
23
0ecb909e3249 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11347
diff changeset
24 " Pandoc-syntax has more features, but it is slower.
11347
4aae8146c21f Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 9975
diff changeset
25 " https://github.com/vim-pandoc/vim-pandoc-syntax
14637
0ecb909e3249 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11347
diff changeset
26 let g:pandoc#syntax#codeblocks#embeds#langs = get(g:, 'pandoc#syntax#codeblocks#embeds#langs', ['r'])
6051
0efec12f52ac Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
27 runtime syntax/pandoc.vim
0efec12f52ac Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
28 if exists("b:current_syntax")
14637
0ecb909e3249 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11347
diff changeset
29 " Fix recognition of R code
0ecb909e3249 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11347
diff changeset
30 syn region pandocDelimitedCodeBlock_r start=/^```{r\>.*}$/ end=/^```$/ contained containedin=pandocDelimitedCodeBlock contains=@R
0ecb909e3249 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11347
diff changeset
31 syn region rmdrInline matchgroup=rmdInlineDelim start="`r " end="`" contains=@R containedin=pandocLaTeXRegion,yamlFlowString keepend
0ecb909e3249 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11347
diff changeset
32 hi def link rmdInlineDelim Delimiter
0ecb909e3249 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11347
diff changeset
33 let b:current_syntax = "rmd"
0ecb909e3249 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11347
diff changeset
34 finish
6051
0efec12f52ac Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
35 endif
0efec12f52ac Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
36
14637
0ecb909e3249 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11347
diff changeset
37 let s:cpo_save = &cpo
0ecb909e3249 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11347
diff changeset
38 set cpo&vim
0ecb909e3249 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11347
diff changeset
39
0ecb909e3249 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11347
diff changeset
40 " R chunks will not be highlighted by syntax/markdown because their headers
0ecb909e3249 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11347
diff changeset
41 " follow a non standard pattern: "```{lang" instead of "^```lang".
0ecb909e3249 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11347
diff changeset
42 " Make a copy of g:markdown_fenced_languages to highlight the chunks later:
0ecb909e3249 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11347
diff changeset
43 if exists('g:markdown_fenced_languages')
0ecb909e3249 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11347
diff changeset
44 if !exists('g:rmd_fenced_languages')
0ecb909e3249 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11347
diff changeset
45 let g:rmd_fenced_languages = deepcopy(g:markdown_fenced_languages)
0ecb909e3249 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11347
diff changeset
46 let g:markdown_fenced_languages = []
0ecb909e3249 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11347
diff changeset
47 endif
6051
0efec12f52ac Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
48 else
14637
0ecb909e3249 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11347
diff changeset
49 let g:rmd_fenced_languages = ['r']
6051
0efec12f52ac Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
50 endif
11347
4aae8146c21f Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 9975
diff changeset
51
14637
0ecb909e3249 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11347
diff changeset
52 runtime syntax/markdown.vim
6051
0efec12f52ac Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
53
14637
0ecb909e3249 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11347
diff changeset
54 " Now highlight chunks:
0ecb909e3249 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11347
diff changeset
55 for s:type in g:rmd_fenced_languages
0ecb909e3249 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11347
diff changeset
56 if s:type =~ '='
16610
1eaf34420bb3 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 14637
diff changeset
57 let s:ft = substitute(s:type, '.*=', '', '')
1eaf34420bb3 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 14637
diff changeset
58 let s:nm = substitute(s:type, '=.*', '', '')
14637
0ecb909e3249 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11347
diff changeset
59 else
16610
1eaf34420bb3 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 14637
diff changeset
60 let s:ft = s:type
14637
0ecb909e3249 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11347
diff changeset
61 let s:nm = s:type
0ecb909e3249 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11347
diff changeset
62 endif
0ecb909e3249 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11347
diff changeset
63 unlet! b:current_syntax
16610
1eaf34420bb3 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 14637
diff changeset
64 exe 'syn include @Rmd'.s:nm.' syntax/'.s:ft.'.vim'
14637
0ecb909e3249 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11347
diff changeset
65 if g:rmd_syn_hl_chunk
0ecb909e3249 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11347
diff changeset
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
0ecb909e3249 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11347
diff changeset
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
0ecb909e3249 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11347
diff changeset
68 else
0ecb909e3249 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11347
diff changeset
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
6051
0efec12f52ac Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
70 endif
14637
0ecb909e3249 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11347
diff changeset
71 exe 'syn region rmd'.s:nm.'Inline matchgroup=rmdInlineDelim start="`'.s:nm.' " end="`" contains=@Rmd'.s:nm.' keepend'
0ecb909e3249 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11347
diff changeset
72 endfor
0ecb909e3249 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11347
diff changeset
73 unlet! s:type
0ecb909e3249 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11347
diff changeset
74
0ecb909e3249 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11347
diff changeset
75 hi def link rmdInlineDelim Delimiter
0ecb909e3249 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11347
diff changeset
76 hi def link rmdCodeDelim Delimiter
0ecb909e3249 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11347
diff changeset
77
0ecb909e3249 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11347
diff changeset
78 " You don't need this if either your markdown/syntax.vim already highlights
0ecb909e3249 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11347
diff changeset
79 " the YAML header or you are writing standard markdown
0ecb909e3249 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11347
diff changeset
80 if g:rmd_syn_hl_yaml
0ecb909e3249 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11347
diff changeset
81 " Minimum highlighting of yaml header
0ecb909e3249 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11347
diff changeset
82 syn match rmdYamlFieldTtl /^\s*\zs\w*\ze:/ contained
0ecb909e3249 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11347
diff changeset
83 syn match rmdYamlFieldTtl /^\s*-\s*\zs\w*\ze:/ contained
0ecb909e3249 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11347
diff changeset
84 syn region yamlFlowString matchgroup=yamlFlowStringDelimiter start='"' skip='\\"' end='"' contains=yamlEscape,rmdrInline contained
0ecb909e3249 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11347
diff changeset
85 syn region yamlFlowString matchgroup=yamlFlowStringDelimiter start="'" skip="''" end="'" contains=yamlSingleEscape,rmdrInline contained
0ecb909e3249 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11347
diff changeset
86 syn match yamlEscape contained '\\\%([\\"abefnrtv\^0_ NLP\n]\|x\x\x\|u\x\{4}\|U\x\{8}\)'
0ecb909e3249 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11347
diff changeset
87 syn match yamlSingleEscape contained "''"
0ecb909e3249 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11347
diff changeset
88 syn region pandocYAMLHeader matchgroup=rmdYamlBlockDelim start=/\%(\%^\|\_^\s*\n\)\@<=\_^-\{3}\ze\n.\+/ end=/^\([-.]\)\1\{2}$/ keepend contains=rmdYamlFieldTtl,yamlFlowString
0ecb909e3249 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11347
diff changeset
89 hi def link rmdYamlBlockDelim Delimiter
0ecb909e3249 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11347
diff changeset
90 hi def link rmdYamlFieldTtl Identifier
0ecb909e3249 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11347
diff changeset
91 hi def link yamlFlowString String
6051
0efec12f52ac Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
92 endif
0efec12f52ac Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
93
14637
0ecb909e3249 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11347
diff changeset
94 " You don't need this if either your markdown/syntax.vim already highlights
0ecb909e3249 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11347
diff changeset
95 " citations or you are writing standard markdown
0ecb909e3249 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11347
diff changeset
96 if g:rmd_syn_hl_citations
0ecb909e3249 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11347
diff changeset
97 " From vim-pandoc-syntax
0ecb909e3249 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11347
diff changeset
98 " parenthetical citations
0ecb909e3249 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11347
diff changeset
99 syn match pandocPCite /\^\@<!\[[^\[\]]\{-}-\{0,1}@[[:alnum:]_][[:alnum:]à-öø-ÿÀ-ÖØ-ß_:.#$%&\-+?<>~\/]*.\{-}\]/ contains=pandocEmphasis,pandocStrong,pandocLatex,pandocCiteKey,@Spell,pandocAmpersandEscape display
0ecb909e3249 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11347
diff changeset
100 " in-text citations with location
0ecb909e3249 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11347
diff changeset
101 syn match pandocICite /@[[:alnum:]_][[:alnum:]à-öø-ÿÀ-ÖØ-ß_:.#$%&\-+?<>~\/]*\s\[.\{-1,}\]/ contains=pandocCiteKey,@Spell display
0ecb909e3249 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11347
diff changeset
102 " cite keys
0ecb909e3249 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11347
diff changeset
103 syn match pandocCiteKey /\(-\=@[[:alnum:]_][[:alnum:]à-öø-ÿÀ-ÖØ-ß_:.#$%&\-+?<>~\/]*\)/ containedin=pandocPCite,pandocICite contains=@NoSpell display
0ecb909e3249 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11347
diff changeset
104 syn match pandocCiteAnchor /[-@]/ contained containedin=pandocCiteKey display
0ecb909e3249 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11347
diff changeset
105 syn match pandocCiteLocator /[\[\]]/ contained containedin=pandocPCite,pandocICite
0ecb909e3249 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11347
diff changeset
106 hi def link pandocPCite Operator
0ecb909e3249 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11347
diff changeset
107 hi def link pandocICite Operator
0ecb909e3249 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11347
diff changeset
108 hi def link pandocCiteKey Label
0ecb909e3249 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11347
diff changeset
109 hi def link pandocCiteAnchor Operator
0ecb909e3249 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11347
diff changeset
110 hi def link pandocCiteLocator Operator
0ecb909e3249 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11347
diff changeset
111 endif
6051
0efec12f52ac Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
112
0efec12f52ac Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
113 let b:current_syntax = "rmd"
0efec12f52ac Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
114
14637
0ecb909e3249 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11347
diff changeset
115 let &cpo = s:cpo_save
0ecb909e3249 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11347
diff changeset
116 unlet s:cpo_save
0ecb909e3249 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11347
diff changeset
117
6051
0efec12f52ac Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
118 " vim: ts=8 sw=2