annotate runtime/syntax/rst.vim @ 20423:8c98c74176ac v8.2.0766

patch 8.2.0766: display error when using 'number' and 'breakindent' Commit: https://github.com/vim/vim/commit/e882f7a73c8fa48707de71035eb0a7ccc6ac8548 Author: Bram Moolenaar <Bram@vim.org> Date: Sat May 16 14:07:39 2020 +0200 patch 8.2.0766: display error when using 'number' and 'breakindent' Problem: Display error when using 'number' and 'breakindent'. Solution: Adjust extra spaces in the first row. (Ken Takata, closes https://github.com/vim/vim/issues/6089, closes #5986)
author Bram Moolenaar <Bram@vim.org>
date Sat, 16 May 2020 14:15:06 +0200
parents 1908e92b02fd
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
19968
1908e92b02fd Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 15334
diff changeset
1 " Vim reST syntax file
6292
31f7581068a9 Update runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents: 6159
diff changeset
2 " Language: reStructuredText documentation format
31f7581068a9 Update runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents: 6159
diff changeset
3 " Maintainer: Marshall Ward <marshall.ward@gmail.com>
6159
babc6a1d4c27 Runtime file updates.
Bram Moolenaar <bram@vim.org>
parents: 5510
diff changeset
4 " Previous Maintainer: Nikolai Weibull <now@bitwi.se>
9908
2b6654519a7c commit https://github.com/vim/vim/commit/7571d55f7dcc009a375b2124cce2c8b21f361234
Christian Brabandt <cb@256bit.org>
parents: 9319
diff changeset
5 " Website: https://github.com/marshallward/vim-restructuredtext
19968
1908e92b02fd Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 15334
diff changeset
6 " Latest Revision: 2020-03-31
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7
375
f14cbd913415 updated for version 7.0097
vimboss
parents: 7
diff changeset
8 if exists("b:current_syntax")
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9 finish
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
10 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
11
375
f14cbd913415 updated for version 7.0097
vimboss
parents: 7
diff changeset
12 let s:cpo_save = &cpo
f14cbd913415 updated for version 7.0097
vimboss
parents: 7
diff changeset
13 set cpo&vim
f14cbd913415 updated for version 7.0097
vimboss
parents: 7
diff changeset
14
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
15 syn case ignore
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
16
2034
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1224
diff changeset
17 syn match rstTransition /^[=`:.'"~^_*+#-]\{4,}\s*$/
825
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
18
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
19 syn cluster rstCruft contains=rstEmphasis,rstStrongEmphasis,
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
20 \ rstInterpretedText,rstInlineLiteral,rstSubstitutionReference,
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
21 \ rstInlineInternalTargets,rstFootnoteReference,rstHyperlinkReference
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
22
825
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
23 syn region rstLiteralBlock matchgroup=rstDelimiter
19968
1908e92b02fd Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 15334
diff changeset
24 \ start='\(^\z(\s*\).*\)\@<=::\n\s*\n' skip='^\s*$' end='^\(\z1\s\+\)\@!'
825
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
25 \ contains=@NoSpell
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
26
825
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
27 syn region rstQuotedLiteralBlock matchgroup=rstDelimiter
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
28 \ start="::\_s*\n\ze\z([!\"#$%&'()*+,-./:;<=>?@[\]^_`{|}~]\)"
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
29 \ end='^\z1\@!' contains=@NoSpell
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
30
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
31 syn region rstDoctestBlock oneline display matchgroup=rstDelimiter
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
32 \ start='^>>>\s' end='^$'
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
33
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
34 syn region rstTable transparent start='^\n\s*+[-=+]\+' end='^$'
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
35 \ contains=rstTableLines,@rstCruft
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
36 syn match rstTableLines contained display '|\|+\%(=\+\|-\+\)\='
375
f14cbd913415 updated for version 7.0097
vimboss
parents: 7
diff changeset
37
825
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
38 syn region rstSimpleTable transparent
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
39 \ start='^\n\%(\s*\)\@>\%(\%(=\+\)\@>\%(\s\+\)\@>\)\%(\%(\%(=\+\)\@>\%(\s*\)\@>\)\+\)\@>$'
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
40 \ end='^$'
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
41 \ contains=rstSimpleTableLines,@rstCruft
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
42 syn match rstSimpleTableLines contained display
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
43 \ '^\%(\s*\)\@>\%(\%(=\+\)\@>\%(\s\+\)\@>\)\%(\%(\%(=\+\)\@>\%(\s*\)\@>\)\+\)\@>$'
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
44 syn match rstSimpleTableLines contained display
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
45 \ '^\%(\s*\)\@>\%(\%(-\+\)\@>\%(\s\+\)\@>\)\%(\%(\%(-\+\)\@>\%(\s*\)\@>\)\+\)\@>$'
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
46
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
47 syn cluster rstDirectives contains=rstFootnote,rstCitation,
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
48 \ rstHyperlinkTarget,rstExDirective
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
49
6159
babc6a1d4c27 Runtime file updates.
Bram Moolenaar <bram@vim.org>
parents: 5510
diff changeset
50 syn match rstExplicitMarkup '^\s*\.\.\_s'
825
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
51 \ nextgroup=@rstDirectives,rstComment,rstSubstitutionDefinition
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
52
14421
2f7e67dd088c Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 9908
diff changeset
53 " "Simple reference names are single words consisting of alphanumerics plus
2f7e67dd088c Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 9908
diff changeset
54 " isolated (no two adjacent) internal hyphens, underscores, periods, colons
2f7e67dd088c Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 9908
diff changeset
55 " and plus signs."
2f7e67dd088c Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 9908
diff changeset
56 let s:ReferenceName = '[[:alnum:]]\%([-_.:+]\?[[:alnum:]]\+\)*'
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
57
825
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
58 syn keyword rstTodo contained FIXME TODO XXX NOTE
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
59
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
60 execute 'syn region rstComment contained' .
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
61 \ ' start=/.*/'
15334
9d3d7b0f4861 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 14421
diff changeset
62 \ ' skip=+^$+' .
825
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
63 \ ' end=/^\s\@!/ contains=rstTodo'
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
64
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
65 execute 'syn region rstFootnote contained matchgroup=rstDirective' .
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
66 \ ' start=+\[\%(\d\+\|#\%(' . s:ReferenceName . '\)\=\|\*\)\]\_s+' .
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
67 \ ' skip=+^$+' .
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
68 \ ' end=+^\s\@!+ contains=@rstCruft,@NoSpell'
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
69
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
70 execute 'syn region rstCitation contained matchgroup=rstDirective' .
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
71 \ ' start=+\[' . s:ReferenceName . '\]\_s+' .
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
72 \ ' skip=+^$+' .
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
73 \ ' end=+^\s\@!+ contains=@rstCruft,@NoSpell'
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
74
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
75 syn region rstHyperlinkTarget contained matchgroup=rstDirective
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
76 \ start='_\%(_\|[^:\\]*\%(\\.[^:\\]*\)*\):\_s' skip=+^$+ end=+^\s\@!+
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
77
825
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
78 syn region rstHyperlinkTarget contained matchgroup=rstDirective
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
79 \ start='_`[^`\\]*\%(\\.[^`\\]*\)*`:\_s' skip=+^$+ end=+^\s\@!+
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
80
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
81 syn region rstHyperlinkTarget matchgroup=rstDirective
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
82 \ start=+^__\_s+ skip=+^$+ end=+^\s\@!+
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
83
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
84 execute 'syn region rstExDirective contained matchgroup=rstDirective' .
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
85 \ ' start=+' . s:ReferenceName . '::\_s+' .
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
86 \ ' skip=+^$+' .
7100
f717d96a39b3 commit https://github.com/vim/vim/commit/12969c04fe7bd27dc0cbf37709eb40a86d4a27f9
Christian Brabandt <cb@256bit.org>
parents: 6292
diff changeset
87 \ ' end=+^\s\@!+ contains=@rstCruft,rstLiteralBlock'
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
88
825
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
89 execute 'syn match rstSubstitutionDefinition contained' .
14421
2f7e67dd088c Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 9908
diff changeset
90 \ ' /|.*|\_s\+/ nextgroup=@rstDirectives'
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
91
825
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
92 function! s:DefineOneInlineMarkup(name, start, middle, end, char_left, char_right)
19968
1908e92b02fd Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 15334
diff changeset
93 " Only escape the first char of a multichar delimiter (e.g. \* inside **)
1908e92b02fd Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 15334
diff changeset
94 if a:start[0] == '\'
1908e92b02fd Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 15334
diff changeset
95 let first = a:start[0:1]
1908e92b02fd Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 15334
diff changeset
96 else
1908e92b02fd Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 15334
diff changeset
97 let first = a:start[0]
1908e92b02fd Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 15334
diff changeset
98 endif
1908e92b02fd Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 15334
diff changeset
99
1908e92b02fd Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 15334
diff changeset
100 execute 'syn match rstEscape'.a:name.' +\\\\\|\\'.first.'+'.' contained'
1908e92b02fd Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 15334
diff changeset
101
825
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
102 execute 'syn region rst' . a:name .
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
103 \ ' start=+' . a:char_left . '\zs' . a:start .
1224
edc1c9d6dab9 updated for version 7.1b
vimboss
parents: 825
diff changeset
104 \ '\ze[^[:space:]' . a:char_right . a:start[strlen(a:start) - 1] . ']+' .
825
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
105 \ a:middle .
19968
1908e92b02fd Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 15334
diff changeset
106 \ ' end=+' . a:end . '\ze\%($\|\s\|[''"’)\]}>/:.,;!?\\-]\)+' .
1908e92b02fd Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 15334
diff changeset
107 \ ' contains=rstEscape' . a:name
1908e92b02fd Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 15334
diff changeset
108
1908e92b02fd Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 15334
diff changeset
109 execute 'hi def link rstEscape'.a:name.' Special'
825
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
110 endfunction
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
111
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
112 function! s:DefineInlineMarkup(name, start, middle, end)
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
113 let middle = a:middle != "" ?
19968
1908e92b02fd Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 15334
diff changeset
114 \ (' skip=+\\\\\|\\' . a:middle . '\|\s' . a:middle . '+') :
825
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
115 \ ""
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
116
825
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
117 call s:DefineOneInlineMarkup(a:name, a:start, middle, a:end, "'", "'")
6159
babc6a1d4c27 Runtime file updates.
Bram Moolenaar <bram@vim.org>
parents: 5510
diff changeset
118 call s:DefineOneInlineMarkup(a:name, a:start, middle, a:end, '"', '"')
babc6a1d4c27 Runtime file updates.
Bram Moolenaar <bram@vim.org>
parents: 5510
diff changeset
119 call s:DefineOneInlineMarkup(a:name, a:start, middle, a:end, '(', ')')
babc6a1d4c27 Runtime file updates.
Bram Moolenaar <bram@vim.org>
parents: 5510
diff changeset
120 call s:DefineOneInlineMarkup(a:name, a:start, middle, a:end, '\[', '\]')
babc6a1d4c27 Runtime file updates.
Bram Moolenaar <bram@vim.org>
parents: 5510
diff changeset
121 call s:DefineOneInlineMarkup(a:name, a:start, middle, a:end, '{', '}')
babc6a1d4c27 Runtime file updates.
Bram Moolenaar <bram@vim.org>
parents: 5510
diff changeset
122 call s:DefineOneInlineMarkup(a:name, a:start, middle, a:end, '<', '>')
9908
2b6654519a7c commit https://github.com/vim/vim/commit/7571d55f7dcc009a375b2124cce2c8b21f361234
Christian Brabandt <cb@256bit.org>
parents: 9319
diff changeset
123 call s:DefineOneInlineMarkup(a:name, a:start, middle, a:end, '’', '’')
2b6654519a7c commit https://github.com/vim/vim/commit/7571d55f7dcc009a375b2124cce2c8b21f361234
Christian Brabandt <cb@256bit.org>
parents: 9319
diff changeset
124 " TODO: Additional Unicode Pd, Po, Pi, Pf, Ps characters
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
125
14421
2f7e67dd088c Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 9908
diff changeset
126 call s:DefineOneInlineMarkup(a:name, a:start, middle, a:end, '\%(^\|\s\|\%ua0\|[/:]\)', '')
825
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
127
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
128 execute 'syn match rst' . a:name .
14421
2f7e67dd088c Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 9908
diff changeset
129 \ ' +\%(^\|\s\|\%ua0\|[''"([{</:]\)\zs' . a:start .
825
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
130 \ '[^[:space:]' . a:start[strlen(a:start) - 1] . ']'
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
131 \ a:end . '\ze\%($\|\s\|[''")\]}>/:.,;!?\\-]\)+'
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
132
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
133 execute 'hi def link rst' . a:name . 'Delimiter' . ' rst' . a:name
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
134 endfunction
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
135
825
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
136 call s:DefineInlineMarkup('Emphasis', '\*', '\*', '\*')
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
137 call s:DefineInlineMarkup('StrongEmphasis', '\*\*', '\*', '\*\*')
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
138 call s:DefineInlineMarkup('InterpretedTextOrHyperlinkReference', '`', '`', '`_\{0,2}')
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
139 call s:DefineInlineMarkup('InlineLiteral', '``', "", '``')
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
140 call s:DefineInlineMarkup('SubstitutionReference', '|', '|', '|_\{0,2}')
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
141 call s:DefineInlineMarkup('InlineInternalTargets', '_`', '`', '`')
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
142
14421
2f7e67dd088c Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 9908
diff changeset
143 " Sections are identified through their titles, which are marked up with
2f7e67dd088c Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 9908
diff changeset
144 " adornment: "underlines" below the title text, or underlines and matching
2f7e67dd088c Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 9908
diff changeset
145 " "overlines" above the title. An underline/overline is a single repeated
2f7e67dd088c Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 9908
diff changeset
146 " punctuation character that begins in column 1 and forms a line extending at
2f7e67dd088c Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 9908
diff changeset
147 " least as far as the right edge of the title text.
2f7e67dd088c Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 9908
diff changeset
148 "
2f7e67dd088c Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 9908
diff changeset
149 " It is difficult to count characters in a regex, but we at least special-case
2f7e67dd088c Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 9908
diff changeset
150 " the case where the title has at least three characters to require the
2f7e67dd088c Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 9908
diff changeset
151 " adornment to have at least three characters as well, in order to handle
2f7e67dd088c Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 9908
diff changeset
152 " properly the case of a literal block:
2f7e67dd088c Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 9908
diff changeset
153 "
2f7e67dd088c Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 9908
diff changeset
154 " this is the end of a paragraph
2f7e67dd088c Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 9908
diff changeset
155 " ::
2f7e67dd088c Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 9908
diff changeset
156 " this is a literal block
2f7e67dd088c Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 9908
diff changeset
157 syn match rstSections "\v^%(([=`:.'"~^_*+#-])\1+\n)?.{1,2}\n([=`:.'"~^_*+#-])\2+$"
2f7e67dd088c Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 9908
diff changeset
158 \ contains=@Spell
2f7e67dd088c Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 9908
diff changeset
159 syn match rstSections "\v^%(([=`:.'"~^_*+#-])\1{2,}\n)?.{3,}\n([=`:.'"~^_*+#-])\2{2,}$"
2f7e67dd088c Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 9908
diff changeset
160 \ contains=@Spell
7597
3012eaddb6b2 commit https://github.com/vim/vim/commit/345efa013dc6d1754ba06e5596a26c48c9935937
Christian Brabandt <cb@256bit.org>
parents: 7100
diff changeset
161
825
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
162 " TODO: Can’t remember why these two can’t be defined like the ones above.
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
163 execute 'syn match rstFootnoteReference contains=@NoSpell' .
14421
2f7e67dd088c Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 9908
diff changeset
164 \ ' +\%(\s\|^\)\[\%(\d\+\|#\%(' . s:ReferenceName . '\)\=\|\*\)\]_+'
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
165
825
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
166 execute 'syn match rstCitationReference contains=@NoSpell' .
14421
2f7e67dd088c Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 9908
diff changeset
167 \ ' +\%(\s\|^\)\[' . s:ReferenceName . '\]_\ze\%($\|\s\|[''")\]}>/:.,;!?\\-]\)+'
825
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
168
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
169 execute 'syn match rstHyperlinkReference' .
1224
edc1c9d6dab9 updated for version 7.1b
vimboss
parents: 825
diff changeset
170 \ ' /\<' . s:ReferenceName . '__\=\ze\%($\|\s\|[''")\]}>/:.,;!?\\-]\)/'
375
f14cbd913415 updated for version 7.0097
vimboss
parents: 7
diff changeset
171
825
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
172 syn match rstStandaloneHyperlink contains=@NoSpell
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
173 \ "\<\%(\%(\%(https\=\|file\|ftp\|gopher\)://\|\%(mailto\|news\):\)[^[:space:]'\"<>]\+\|www[[:alnum:]_-]*\.[[:alnum:]_-]\+\.[^[:space:]'\"<>]\+\)[[:alnum:]/]"
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
174
3920
c53344bacabf Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3750
diff changeset
175 syn region rstCodeBlock contained matchgroup=rstDirective
19968
1908e92b02fd Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 15334
diff changeset
176 \ start=+\%(sourcecode\|code\%(-block\)\=\)::\s*\(\S*\)\?\s*\n\%(\s*:.*:\s*.*\s*\n\)*\n\ze\z(\s\+\)+
3920
c53344bacabf Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3750
diff changeset
177 \ skip=+^$+
6159
babc6a1d4c27 Runtime file updates.
Bram Moolenaar <bram@vim.org>
parents: 5510
diff changeset
178 \ end=+^\z1\@!+
3920
c53344bacabf Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3750
diff changeset
179 \ contains=@NoSpell
c53344bacabf Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3750
diff changeset
180 syn cluster rstDirectives add=rstCodeBlock
c53344bacabf Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3750
diff changeset
181
c53344bacabf Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3750
diff changeset
182 if !exists('g:rst_syntax_code_list')
14421
2f7e67dd088c Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 9908
diff changeset
183 " A mapping from a Vim filetype to a list of alias patterns (pattern
2f7e67dd088c Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 9908
diff changeset
184 " branches to be specific, see ':help /pattern'). E.g. given:
2f7e67dd088c Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 9908
diff changeset
185 "
2f7e67dd088c Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 9908
diff changeset
186 " let g:rst_syntax_code_list = {
2f7e67dd088c Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 9908
diff changeset
187 " \ 'cpp': ['cpp', 'c++'],
2f7e67dd088c Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 9908
diff changeset
188 " \ }
2f7e67dd088c Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 9908
diff changeset
189 "
2f7e67dd088c Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 9908
diff changeset
190 " then the respective contents of the following two rST directives:
2f7e67dd088c Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 9908
diff changeset
191 "
2f7e67dd088c Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 9908
diff changeset
192 " .. code:: cpp
2f7e67dd088c Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 9908
diff changeset
193 "
2f7e67dd088c Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 9908
diff changeset
194 " auto i = 42;
2f7e67dd088c Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 9908
diff changeset
195 "
2f7e67dd088c Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 9908
diff changeset
196 " .. code:: C++
2f7e67dd088c Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 9908
diff changeset
197 "
2f7e67dd088c Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 9908
diff changeset
198 " auto i = 42;
2f7e67dd088c Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 9908
diff changeset
199 "
2f7e67dd088c Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 9908
diff changeset
200 " will both be highlighted as C++ code. As shown by the latter block
2f7e67dd088c Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 9908
diff changeset
201 " pattern matching will be case-insensitive.
2f7e67dd088c Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 9908
diff changeset
202 let g:rst_syntax_code_list = {
2f7e67dd088c Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 9908
diff changeset
203 \ 'vim': ['vim'],
2f7e67dd088c Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 9908
diff changeset
204 \ 'java': ['java'],
2f7e67dd088c Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 9908
diff changeset
205 \ 'cpp': ['cpp', 'c++'],
2f7e67dd088c Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 9908
diff changeset
206 \ 'lisp': ['lisp'],
2f7e67dd088c Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 9908
diff changeset
207 \ 'php': ['php'],
2f7e67dd088c Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 9908
diff changeset
208 \ 'python': ['python'],
2f7e67dd088c Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 9908
diff changeset
209 \ 'perl': ['perl'],
2f7e67dd088c Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 9908
diff changeset
210 \ 'sh': ['sh'],
2f7e67dd088c Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 9908
diff changeset
211 \ }
2f7e67dd088c Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 9908
diff changeset
212 elseif type(g:rst_syntax_code_list) == type([])
2f7e67dd088c Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 9908
diff changeset
213 " backward compatibility with former list format
2f7e67dd088c Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 9908
diff changeset
214 let s:old_spec = g:rst_syntax_code_list
2f7e67dd088c Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 9908
diff changeset
215 let g:rst_syntax_code_list = {}
2f7e67dd088c Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 9908
diff changeset
216 for s:elem in s:old_spec
2f7e67dd088c Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 9908
diff changeset
217 let g:rst_syntax_code_list[s:elem] = [s:elem]
2f7e67dd088c Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 9908
diff changeset
218 endfor
3920
c53344bacabf Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3750
diff changeset
219 endif
c53344bacabf Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3750
diff changeset
220
14421
2f7e67dd088c Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 9908
diff changeset
221 for s:filetype in keys(g:rst_syntax_code_list)
3920
c53344bacabf Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3750
diff changeset
222 unlet! b:current_syntax
6292
31f7581068a9 Update runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents: 6159
diff changeset
223 " guard against setting 'isk' option which might cause problems (issue #108)
31f7581068a9 Update runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents: 6159
diff changeset
224 let prior_isk = &l:iskeyword
14421
2f7e67dd088c Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 9908
diff changeset
225 let s:alias_pattern = ''
2f7e67dd088c Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 9908
diff changeset
226 \.'\%('
2f7e67dd088c Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 9908
diff changeset
227 \.join(g:rst_syntax_code_list[s:filetype], '\|')
2f7e67dd088c Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 9908
diff changeset
228 \.'\)'
2f7e67dd088c Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 9908
diff changeset
229
2f7e67dd088c Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 9908
diff changeset
230 exe 'syn include @rst'.s:filetype.' syntax/'.s:filetype.'.vim'
2f7e67dd088c Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 9908
diff changeset
231 exe 'syn region rstDirective'.s:filetype
2f7e67dd088c Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 9908
diff changeset
232 \.' matchgroup=rstDirective fold'
2f7e67dd088c Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 9908
diff changeset
233 \.' start="\c\%(sourcecode\|code\%(-block\)\=\)::\s\+'.s:alias_pattern.'\_s*\n\ze\z(\s\+\)"'
9319
1472ed67c36f commit https://github.com/vim/vim/commit/a02a551e18209423584fcb923e93c6be18f3aa45
Christian Brabandt <cb@256bit.org>
parents: 7597
diff changeset
234 \.' skip=#^$#'
1472ed67c36f commit https://github.com/vim/vim/commit/a02a551e18209423584fcb923e93c6be18f3aa45
Christian Brabandt <cb@256bit.org>
parents: 7597
diff changeset
235 \.' end=#^\z1\@!#'
14421
2f7e67dd088c Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 9908
diff changeset
236 \.' contains=@NoSpell,@rst'.s:filetype
2f7e67dd088c Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 9908
diff changeset
237 exe 'syn cluster rstDirectives add=rstDirective'.s:filetype
2f7e67dd088c Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 9908
diff changeset
238
6292
31f7581068a9 Update runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents: 6159
diff changeset
239 " reset 'isk' setting, if it has been changed
31f7581068a9 Update runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents: 6159
diff changeset
240 if &l:iskeyword !=# prior_isk
31f7581068a9 Update runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents: 6159
diff changeset
241 let &l:iskeyword = prior_isk
31f7581068a9 Update runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents: 6159
diff changeset
242 endif
31f7581068a9 Update runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents: 6159
diff changeset
243 unlet! prior_isk
3920
c53344bacabf Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3750
diff changeset
244 endfor
c53344bacabf Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3750
diff changeset
245
14421
2f7e67dd088c Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 9908
diff changeset
246 " Enable top level spell checking
2f7e67dd088c Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 9908
diff changeset
247 syntax spell toplevel
2f7e67dd088c Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 9908
diff changeset
248
4780
2b11ac90d9e9 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3920
diff changeset
249 " TODO: Use better syncing.
2b11ac90d9e9 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3920
diff changeset
250 syn sync minlines=50 linebreaks=2
2b11ac90d9e9 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3920
diff changeset
251
825
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
252 hi def link rstTodo Todo
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
253 hi def link rstComment Comment
3750
536aa8b0c934 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2072
diff changeset
254 hi def link rstSections Title
536aa8b0c934 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2072
diff changeset
255 hi def link rstTransition rstSections
825
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
256 hi def link rstLiteralBlock String
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
257 hi def link rstQuotedLiteralBlock String
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
258 hi def link rstDoctestBlock PreProc
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
259 hi def link rstTableLines rstDelimiter
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
260 hi def link rstSimpleTableLines rstTableLines
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
261 hi def link rstExplicitMarkup rstDirective
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
262 hi def link rstDirective Keyword
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
263 hi def link rstFootnote String
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
264 hi def link rstCitation String
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
265 hi def link rstHyperlinkTarget String
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
266 hi def link rstExDirective String
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
267 hi def link rstSubstitutionDefinition rstDirective
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
268 hi def link rstDelimiter Delimiter
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
269 hi def link rstInterpretedTextOrHyperlinkReference Identifier
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
270 hi def link rstInlineLiteral String
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
271 hi def link rstSubstitutionReference PreProc
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
272 hi def link rstInlineInternalTargets Identifier
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
273 hi def link rstFootnoteReference Identifier
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
274 hi def link rstCitationReference Identifier
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
275 hi def link rstHyperLinkReference Identifier
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
276 hi def link rstStandaloneHyperlink Identifier
3920
c53344bacabf Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3750
diff changeset
277 hi def link rstCodeBlock String
14421
2f7e67dd088c Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 9908
diff changeset
278 if exists('g:rst_use_emphasis_colors')
2f7e67dd088c Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 9908
diff changeset
279 " TODO: Less arbitrary color selection
2f7e67dd088c Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 9908
diff changeset
280 hi def rstEmphasis ctermfg=13 term=italic cterm=italic gui=italic
2f7e67dd088c Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 9908
diff changeset
281 hi def rstStrongEmphasis ctermfg=1 term=bold cterm=bold gui=bold
2f7e67dd088c Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 9908
diff changeset
282 else
2f7e67dd088c Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 9908
diff changeset
283 hi def rstEmphasis term=italic cterm=italic gui=italic
2f7e67dd088c Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 9908
diff changeset
284 hi def rstStrongEmphasis term=bold cterm=bold gui=bold
2f7e67dd088c Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 9908
diff changeset
285 endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
286
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
287 let b:current_syntax = "rst"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
288
375
f14cbd913415 updated for version 7.0097
vimboss
parents: 7
diff changeset
289 let &cpo = s:cpo_save
f14cbd913415 updated for version 7.0097
vimboss
parents: 7
diff changeset
290 unlet s:cpo_save