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