annotate runtime/syntax/rst.vim @ 883:7c28790fa8b4 v7.0.009

updated for version 7.0-009
author vimboss
date Sat, 13 May 2006 12:09:24 +0000
parents 6675076019ae
children edc1c9d6dab9
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1 " Vim syntax file
375
f14cbd913415 updated for version 7.0097
vimboss
parents: 7
diff changeset
2 " Language: reStructuredText documentation format
825
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
3 " Maintainer: Nikolai Weibull <now@bitwi.se>
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
4 " Latest Revision: 2006-04-09
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5
375
f14cbd913415 updated for version 7.0097
vimboss
parents: 7
diff changeset
6 if exists("b:current_syntax")
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7 finish
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9
375
f14cbd913415 updated for version 7.0097
vimboss
parents: 7
diff changeset
10 let s:cpo_save = &cpo
f14cbd913415 updated for version 7.0097
vimboss
parents: 7
diff changeset
11 set cpo&vim
f14cbd913415 updated for version 7.0097
vimboss
parents: 7
diff changeset
12
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
13 syn case ignore
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
14
825
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
15 " FIXME: The problem with these two is that Vim doesn’t seem to like
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
16 " matching across line boundaries.
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
17 "
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
18 " syn match rstSections /^.*\n[=`:.'"~^_*+#-]\+$/
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
19
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
20 " syn match rstTransition /^\s*[=`:.'"~^_*+#-]\{4,}\s*$/
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
21
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
22 syn cluster rstCruft contains=rstEmphasis,rstStrongEmphasis,
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
23 \ rstInterpretedText,rstInlineLiteral,rstSubstitutionReference,
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
24 \ rstInlineInternalTargets,rstFootnoteReference,rstHyperlinkReference
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
25
825
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
26 syn region rstLiteralBlock matchgroup=rstDelimiter
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
27 \ start='::\_s*\n\ze\z(\s\+\)' skip='^$' end='^\z1\@!'
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
28 \ contains=@NoSpell
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
29
825
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
30 syn region rstQuotedLiteralBlock matchgroup=rstDelimiter
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
31 \ start="::\_s*\n\ze\z([!\"#$%&'()*+,-./:;<=>?@[\]^_`{|}~]\)"
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
32 \ end='^\z1\@!' contains=@NoSpell
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 rstDoctestBlock oneline display matchgroup=rstDelimiter
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
35 \ start='^>>>\s' end='^$'
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
36
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
37 syn region rstTable transparent start='^\n\s*+[-=+]\+' end='^$'
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
38 \ contains=rstTableLines,@rstCruft
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
39 syn match rstTableLines contained display '|\|+\%(=\+\|-\+\)\='
375
f14cbd913415 updated for version 7.0097
vimboss
parents: 7
diff changeset
40
825
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
41 syn region rstSimpleTable transparent
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
42 \ start='^\n\%(\s*\)\@>\%(\%(=\+\)\@>\%(\s\+\)\@>\)\%(\%(\%(=\+\)\@>\%(\s*\)\@>\)\+\)\@>$'
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
43 \ end='^$'
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
44 \ contains=rstSimpleTableLines,@rstCruft
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
45 syn match rstSimpleTableLines contained display
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
46 \ '^\%(\s*\)\@>\%(\%(=\+\)\@>\%(\s\+\)\@>\)\%(\%(\%(=\+\)\@>\%(\s*\)\@>\)\+\)\@>$'
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
47 syn match rstSimpleTableLines contained display
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
48 \ '^\%(\s*\)\@>\%(\%(-\+\)\@>\%(\s\+\)\@>\)\%(\%(\%(-\+\)\@>\%(\s*\)\@>\)\+\)\@>$'
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
49
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
50 syn cluster rstDirectives contains=rstFootnote,rstCitation,
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
51 \ rstHyperlinkTarget,rstExDirective
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
52
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
53 syn match rstExplicitMarkup '^\.\.\s'
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
54 \ nextgroup=@rstDirectives,rstComment,rstSubstitutionDefinition
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
55
6675076019ae updated for version 7.0d
vimboss
parents: 809
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=/.*/'
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
62 \ ' end=/^\s\@!/ contains=rstTodo'
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
63
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
64 execute 'syn region rstFootnote contained matchgroup=rstDirective' .
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
65 \ ' start=+\[\%(\d\+\|#\%(' . s:ReferenceName . '\)\=\|\*\)\]\_s+' .
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
66 \ ' skip=+^$+' .
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
67 \ ' end=+^\s\@!+ contains=@rstCruft,@NoSpell'
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
68
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
69 execute 'syn region rstCitation contained matchgroup=rstDirective' .
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
70 \ ' start=+\[' . s:ReferenceName . '\]\_s+' .
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
71 \ ' skip=+^$+' .
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
72 \ ' end=+^\s\@!+ contains=@rstCruft,@NoSpell'
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
73
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
74 syn region rstHyperlinkTarget contained matchgroup=rstDirective
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
75 \ start='_\%(_\|[^:\\]*\%(\\.[^:\\]*\)*\):\_s' skip=+^$+ end=+^\s\@!+
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
76
825
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
77 syn region rstHyperlinkTarget contained matchgroup=rstDirective
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
78 \ start='_`[^`\\]*\%(\\.[^`\\]*\)*`:\_s' skip=+^$+ end=+^\s\@!+
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
79
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
80 syn region rstHyperlinkTarget matchgroup=rstDirective
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
81 \ start=+^__\_s+ skip=+^$+ end=+^\s\@!+
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
82
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
83 execute 'syn region rstExDirective contained matchgroup=rstDirective' .
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
84 \ ' start=+' . s:ReferenceName . '::\_s+' .
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
85 \ ' skip=+^$+' .
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
86 \ ' end=+^\s\@!+ contains=@rstCruft'
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
87
825
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
88 execute 'syn match rstSubstitutionDefinition contained' .
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
89 \ ' /|' . s:ReferenceName . '|\_s\+/ nextgroup=@rstDirectives'
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
90
825
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
91 function! s:DefineOneInlineMarkup(name, start, middle, end, char_left, char_right)
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
92 execute 'syn region rst' . a:name .
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
93 \ ' start=+' . a:char_left . '\zs' . a:start .
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
94 \ '[^[:space:]' . a:char_right . a:start[strlen(a:start) - 1] . ']+' .
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
95 \ a:middle .
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
96 \ ' end=+\S' . a:end . '\ze\%($\|\s\|[''")\]}>/:.,;!?\\-]\)+'
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
97 endfunction
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
98
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
99 function! s:DefineInlineMarkup(name, start, middle, end)
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
100 let middle = a:middle != "" ?
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
101 \ (' skip=+\\\\\|\\' . a:middle . '+') :
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
102 \ ""
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
103
825
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
104 call s:DefineOneInlineMarkup(a:name, a:start, middle, a:end, "'", "'")
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
105 call s:DefineOneInlineMarkup(a:name, a:start, middle, a:end, '"', '"')
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
106 call s:DefineOneInlineMarkup(a:name, a:start, middle, a:end, '(', ')')
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
107 call s:DefineOneInlineMarkup(a:name, a:start, middle, a:end, '\[', '\]')
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
108 call s:DefineOneInlineMarkup(a:name, a:start, middle, a:end, '{', '}')
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
109 call s:DefineOneInlineMarkup(a:name, a:start, middle, a:end, '<', '>')
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
110
825
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
111 call s:DefineOneInlineMarkup(a:name, a:start, middle, a:end, '\%(^\|\s\|[/:]\)', '')
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
112
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
113 execute 'syn match rst' . a:name .
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
114 \ ' +\%(^\|\s\|[''"([{</:]\)\zs' . a:start .
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
115 \ '[^[:space:]' . a:start[strlen(a:start) - 1] . ']'
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
116 \ a:end . '\ze\%($\|\s\|[''")\]}>/:.,;!?\\-]\)+'
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
117
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
118 execute 'hi def link rst' . a:name . 'Delimiter' . ' rst' . a:name
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
119 endfunction
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
120
825
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
121 call s:DefineInlineMarkup('Emphasis', '\*', '\*', '\*')
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
122 call s:DefineInlineMarkup('StrongEmphasis', '\*\*', '\*', '\*\*')
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
123 call s:DefineInlineMarkup('InterpretedTextOrHyperlinkReference', '`', '`', '`_\{0,2}')
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
124 call s:DefineInlineMarkup('InlineLiteral', '``', "", '``')
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
125 call s:DefineInlineMarkup('SubstitutionReference', '|', '|', '|_\{0,2}')
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
126 call s:DefineInlineMarkup('InlineInternalTargets', '_`', '`', '`')
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
127
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
128 " 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
129 execute 'syn match rstFootnoteReference contains=@NoSpell' .
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
130 \ ' +\[\%(\d\+\|#\%(' . s:ReferenceName . '\)\=\|\*\)\]_+'
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
131
825
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
132 execute 'syn match rstCitationReference contains=@NoSpell' .
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
133 \ ' +\[' . s:ReferenceName . '\]_+'
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
134
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
135 execute 'syn match rstHyperlinkReference' .
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
136 \ ' /\<' . s:ReferenceName . '__\=/'
375
f14cbd913415 updated for version 7.0097
vimboss
parents: 7
diff changeset
137
825
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
138 syn match rstStandaloneHyperlink contains=@NoSpell
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
139 \ "\<\%(\%(\%(https\=\|file\|ftp\|gopher\)://\|\%(mailto\|news\):\)[^[:space:]'\"<>]\+\|www[[:alnum:]_-]*\.[[:alnum:]_-]\+\.[^[:space:]'\"<>]\+\)[[:alnum:]/]"
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
140
825
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
141 " TODO: Use better syncing. I don’t know the specifics of syncing well enough,
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
142 " though.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
143 syn sync minlines=50
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
144
825
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
145 hi def link rstTodo Todo
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
146 hi def link rstComment Comment
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
147 "hi def link rstSections Type
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
148 "hi def link rstTransition Type
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
149 hi def link rstLiteralBlock String
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
150 hi def link rstQuotedLiteralBlock String
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
151 hi def link rstDoctestBlock PreProc
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
152 hi def link rstTableLines rstDelimiter
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
153 hi def link rstSimpleTableLines rstTableLines
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
154 hi def link rstExplicitMarkup rstDirective
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
155 hi def link rstDirective Keyword
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
156 hi def link rstFootnote String
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
157 hi def link rstCitation String
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
158 hi def link rstHyperlinkTarget String
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
159 hi def link rstExDirective String
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
160 hi def link rstSubstitutionDefinition rstDirective
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
161 hi def link rstDelimiter Delimiter
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
162 " TODO: I dunno...
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
163 hi def rstEmphasis term=italic cterm=italic gui=italic
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
164 hi def link rstStrongEmphasis Special
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
165 "term=bold cterm=bold gui=bold
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
166 hi def link rstInterpretedTextOrHyperlinkReference Identifier
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
167 hi def link rstInlineLiteral String
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
168 hi def link rstSubstitutionReference PreProc
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
169 hi def link rstInlineInternalTargets Identifier
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
170 hi def link rstFootnoteReference Identifier
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
171 hi def link rstCitationReference Identifier
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
172 hi def link rstHyperLinkReference Identifier
6675076019ae updated for version 7.0d
vimboss
parents: 809
diff changeset
173 hi def link rstStandaloneHyperlink Identifier
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
174
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
175 let b:current_syntax = "rst"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
176
375
f14cbd913415 updated for version 7.0097
vimboss
parents: 7
diff changeset
177 let &cpo = s:cpo_save
f14cbd913415 updated for version 7.0097
vimboss
parents: 7
diff changeset
178 unlet s:cpo_save