blob: 70ec47ed5f4da73245744c5abbb98327f3931e55 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
|
" Vim syntax file
" Language: reStructuredText documentation format
" Maintainer: Nikolai Weibull <nikolai+work.vim@bitwi.se>
" Latest Revision: 2006-03-26
if exists("b:current_syntax")
finish
endif
let s:cpo_save = &cpo
set cpo&vim
syn keyword rstTodo contained FIXME TODO XXX NOTE
syn case ignore
syn region rstComment start='^\.\.\%( \%([a-z0-9_.-]\+::\)\@!\|$\)'
\ end='^\s\@!' contains=rstTodo
syn cluster rstCruft contains=rstFootnoteLabel,rstCitationLabel,
\ rstSubstitutionLabel,rstInline,
\ rstHyperlinks,rstInternalTarget
syn region rstBlock matchgroup=rstDelimiter
\ start='::$' skip='^$' end='^\s\@!'
syn region rstDoctestBlock matchgroup=rstDelimiter
\ start='^>>>\s' end='^$'
" TODO: these may actually be a bit too complicated to match correctly and
" should perhaps be removed. We won't really needs it anyway?
syn region rstTable transparent start='^\n\s*+[-=+]\+' end='^$'
\ contains=rstTableLines,@rstCruft
syn match rstTableLines contained '^\s*[|+=-]\+$'
syn region rstSimpleTable transparent
\ start='^\n\%(\s*\)\@>\%(\%(=\+\)\@>\%(\s\+\)\@>\)\%(\%(\%(=\+\)\@>\%(\s*\)\@>\)\+\)\@>$'
\ end='^$'
\ contains=rstSimpleTableLines,@rstCruft
syn match rstSimpleTableLines contained display
\ '^\%(\s*\)\@>\%(\%(=\+\)\@>\%(\s\+\)\@>\)\%(\%(\%(=\+\)\@>\%(\s*\)\@>\)\+\)\@>$'
syn region rstFootnote matchgroup=rstDirective
\ start='^\.\. \[\%([#*]\|[0-9]\+\|#[a-z0-9_.-]\+\)\]\s'
\ end='^\s\@!' contains=@rstCruft
syn match rstFootnoteLabel '\[\%([#*]\|[0-9]\+\|#[a-z0-9_.-]\+\)\]_'
syn region rstCitation matchgroup=rstDirective
\ start='^\.\. \[[a-z0-9_.-]\+\]\s'
\ end='^\s\@!' contains=@rstCruft
syn match rstCitationLabel '\[[a-z0-9_.-]\+\]_'
syn region rstDirectiveBody matchgroup=rstDirective
\ start='^\.\. [a-z0-9_.-]\+::'
\ end='^\s\@!'
syn region rstSubstitution matchgroup=rstDirective
\ start='^\.\. |[a-z0-9_.-]|\s[a-z0-9_.-]\+::\s'
\ end='^\s\@!' contains=@rstCruft
syn match rstSubstitutionLbl '|[a-z0-9_.-]|'
syn match rstInline '\*\{1,2}\S\%([^*]*\S\)\=\*\{1,2}'
syn match rstInline '`\{1,2}\S\%([^`]*\S\)\=`\{1,2}'
syn region rstHyperlinks matchgroup=RstDirective
\ start='^\.\. _[a-z0-9_. -]\+:\s'
\ end='^\s\@!' contains=@rstCruft
syn match rstHyperlinksLabel '`\S\%([^`]*\S\)\=`__\=\>'
syn match rstHyperlinksLabel '\w\+__\=\>'
syn match rstInternalTarget '_`\S\%([^`]*\S\)\=`'
syn match rstListItem '^:\w\+\%(\s\+\w\+\)*:'
syn match rstListItem '^\s*[-*+]\s\+'
syn sync minlines=50
hi def link rstTodo Todo
hi def link rstComment Comment
hi def link rstDelimiter Delimiter
hi def link rstBlock String
hi def link rstDoctestBlock PreProc
hi def link rstTableLines Delimiter
hi def link rstSimpleTableLines rstTableLines
hi def link rstFootnote String
hi def link rstFootnoteLabel Identifier
hi def link rstCitation String
hi def link rstCitationLabel Identifier
hi def link rstDirective Keyword
hi def link rstDirectiveBody Type
hi def link rstSubstitution String
hi def link rstSubstitutionLbl Identifier
hi def link rstHyperlinks String
hi def link rstHyperlinksLabel Identifier
hi def link rstListItem Identifier
hi def rstInline term=italic cterm=italic gui=italic
hi def rstInternalTarget term=italic cterm=italic gui=italic
let b:current_syntax = "rst"
let &cpo = s:cpo_save
unlet s:cpo_save
|