Mercurial > vim
annotate runtime/syntax/rst.vim @ 6695:6529590f6c43 v7.4.672
updated for version 7.4.672
Problem: When completing a shell command, directories in the current
directory are not listed.
Solution: When "." is not in $PATH also look in the current directory for
directories.
author | Bram Moolenaar <bram@vim.org> |
---|---|
date | Sat, 21 Mar 2015 17:32:19 +0100 |
parents | 31f7581068a9 |
children | f717d96a39b3 |
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> |
6292
31f7581068a9
Update runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
6159
diff
changeset
|
5 " Latest Revision: 2014-10-03 |
7 | 6 |
375 | 7 if exists("b:current_syntax") |
7 | 8 finish |
9 endif | |
10 | |
375 | 11 let s:cpo_save = &cpo |
12 set cpo&vim | |
13 | |
7 | 14 syn case ignore |
15 | |
2034 | 16 syn match rstSections "^\%(\([=`:.'"~^_*+#-]\)\1\+\n\)\=.\+\n\([=`:.'"~^_*+#-]\)\2\+$" |
825 | 17 |
2034 | 18 syn match rstTransition /^[=`:.'"~^_*+#-]\{4,}\s*$/ |
825 | 19 |
20 syn cluster rstCruft contains=rstEmphasis,rstStrongEmphasis, | |
21 \ rstInterpretedText,rstInlineLiteral,rstSubstitutionReference, | |
22 \ rstInlineInternalTargets,rstFootnoteReference,rstHyperlinkReference | |
7 | 23 |
825 | 24 syn region rstLiteralBlock matchgroup=rstDelimiter |
25 \ start='::\_s*\n\ze\z(\s\+\)' skip='^$' end='^\z1\@!' | |
26 \ contains=@NoSpell | |
7 | 27 |
825 | 28 syn region rstQuotedLiteralBlock matchgroup=rstDelimiter |
29 \ start="::\_s*\n\ze\z([!\"#$%&'()*+,-./:;<=>?@[\]^_`{|}~]\)" | |
30 \ end='^\z1\@!' contains=@NoSpell | |
31 | |
32 syn region rstDoctestBlock oneline display matchgroup=rstDelimiter | |
33 \ start='^>>>\s' end='^$' | |
34 | |
35 syn region rstTable transparent start='^\n\s*+[-=+]\+' end='^$' | |
36 \ contains=rstTableLines,@rstCruft | |
37 syn match rstTableLines contained display '|\|+\%(=\+\|-\+\)\=' | |
375 | 38 |
825 | 39 syn region rstSimpleTable transparent |
40 \ start='^\n\%(\s*\)\@>\%(\%(=\+\)\@>\%(\s\+\)\@>\)\%(\%(\%(=\+\)\@>\%(\s*\)\@>\)\+\)\@>$' | |
41 \ end='^$' | |
42 \ contains=rstSimpleTableLines,@rstCruft | |
43 syn match rstSimpleTableLines contained display | |
44 \ '^\%(\s*\)\@>\%(\%(=\+\)\@>\%(\s\+\)\@>\)\%(\%(\%(=\+\)\@>\%(\s*\)\@>\)\+\)\@>$' | |
45 syn match rstSimpleTableLines contained display | |
46 \ '^\%(\s*\)\@>\%(\%(-\+\)\@>\%(\s\+\)\@>\)\%(\%(\%(-\+\)\@>\%(\s*\)\@>\)\+\)\@>$' | |
47 | |
48 syn cluster rstDirectives contains=rstFootnote,rstCitation, | |
49 \ rstHyperlinkTarget,rstExDirective | |
50 | |
6159 | 51 syn match rstExplicitMarkup '^\s*\.\.\_s' |
825 | 52 \ nextgroup=@rstDirectives,rstComment,rstSubstitutionDefinition |
53 | |
54 let s:ReferenceName = '[[:alnum:]]\+\%([_.-][[:alnum:]]\+\)*' | |
7 | 55 |
825 | 56 syn keyword rstTodo contained FIXME TODO XXX NOTE |
57 | |
58 execute 'syn region rstComment contained' . | |
59 \ ' start=/.*/' | |
60 \ ' end=/^\s\@!/ contains=rstTodo' | |
61 | |
62 execute 'syn region rstFootnote contained matchgroup=rstDirective' . | |
63 \ ' start=+\[\%(\d\+\|#\%(' . s:ReferenceName . '\)\=\|\*\)\]\_s+' . | |
64 \ ' skip=+^$+' . | |
65 \ ' end=+^\s\@!+ contains=@rstCruft,@NoSpell' | |
66 | |
67 execute 'syn region rstCitation contained matchgroup=rstDirective' . | |
68 \ ' start=+\[' . s:ReferenceName . '\]\_s+' . | |
69 \ ' skip=+^$+' . | |
70 \ ' end=+^\s\@!+ contains=@rstCruft,@NoSpell' | |
71 | |
72 syn region rstHyperlinkTarget contained matchgroup=rstDirective | |
73 \ start='_\%(_\|[^:\\]*\%(\\.[^:\\]*\)*\):\_s' skip=+^$+ end=+^\s\@!+ | |
7 | 74 |
825 | 75 syn region rstHyperlinkTarget contained matchgroup=rstDirective |
76 \ start='_`[^`\\]*\%(\\.[^`\\]*\)*`:\_s' skip=+^$+ end=+^\s\@!+ | |
77 | |
78 syn region rstHyperlinkTarget matchgroup=rstDirective | |
79 \ start=+^__\_s+ skip=+^$+ end=+^\s\@!+ | |
80 | |
81 execute 'syn region rstExDirective contained matchgroup=rstDirective' . | |
82 \ ' start=+' . s:ReferenceName . '::\_s+' . | |
83 \ ' skip=+^$+' . | |
84 \ ' end=+^\s\@!+ contains=@rstCruft' | |
7 | 85 |
825 | 86 execute 'syn match rstSubstitutionDefinition contained' . |
87 \ ' /|' . s:ReferenceName . '|\_s\+/ nextgroup=@rstDirectives' | |
7 | 88 |
825 | 89 function! s:DefineOneInlineMarkup(name, start, middle, end, char_left, char_right) |
90 execute 'syn region rst' . a:name . | |
91 \ ' start=+' . a:char_left . '\zs' . a:start . | |
1224 | 92 \ '\ze[^[:space:]' . a:char_right . a:start[strlen(a:start) - 1] . ']+' . |
825 | 93 \ a:middle . |
94 \ ' end=+\S' . a:end . '\ze\%($\|\s\|[''")\]}>/:.,;!?\\-]\)+' | |
95 endfunction | |
96 | |
97 function! s:DefineInlineMarkup(name, start, middle, end) | |
98 let middle = a:middle != "" ? | |
99 \ (' skip=+\\\\\|\\' . a:middle . '+') : | |
100 \ "" | |
7 | 101 |
825 | 102 call s:DefineOneInlineMarkup(a:name, a:start, middle, a:end, "'", "'") |
6159 | 103 call s:DefineOneInlineMarkup(a:name, a:start, middle, a:end, '"', '"') |
104 call s:DefineOneInlineMarkup(a:name, a:start, middle, a:end, '(', ')') | |
105 call s:DefineOneInlineMarkup(a:name, a:start, middle, a:end, '\[', '\]') | |
106 call s:DefineOneInlineMarkup(a:name, a:start, middle, a:end, '{', '}') | |
107 call s:DefineOneInlineMarkup(a:name, a:start, middle, a:end, '<', '>') | |
7 | 108 |
825 | 109 call s:DefineOneInlineMarkup(a:name, a:start, middle, a:end, '\%(^\|\s\|[/:]\)', '') |
110 | |
111 execute 'syn match rst' . a:name . | |
112 \ ' +\%(^\|\s\|[''"([{</:]\)\zs' . a:start . | |
113 \ '[^[:space:]' . a:start[strlen(a:start) - 1] . ']' | |
114 \ a:end . '\ze\%($\|\s\|[''")\]}>/:.,;!?\\-]\)+' | |
115 | |
116 execute 'hi def link rst' . a:name . 'Delimiter' . ' rst' . a:name | |
117 endfunction | |
7 | 118 |
825 | 119 call s:DefineInlineMarkup('Emphasis', '\*', '\*', '\*') |
120 call s:DefineInlineMarkup('StrongEmphasis', '\*\*', '\*', '\*\*') | |
121 call s:DefineInlineMarkup('InterpretedTextOrHyperlinkReference', '`', '`', '`_\{0,2}') | |
122 call s:DefineInlineMarkup('InlineLiteral', '``', "", '``') | |
123 call s:DefineInlineMarkup('SubstitutionReference', '|', '|', '|_\{0,2}') | |
124 call s:DefineInlineMarkup('InlineInternalTargets', '_`', '`', '`') | |
125 | |
126 " TODO: Can’t remember why these two can’t be defined like the ones above. | |
127 execute 'syn match rstFootnoteReference contains=@NoSpell' . | |
128 \ ' +\[\%(\d\+\|#\%(' . s:ReferenceName . '\)\=\|\*\)\]_+' | |
7 | 129 |
825 | 130 execute 'syn match rstCitationReference contains=@NoSpell' . |
1224 | 131 \ ' +\[' . s:ReferenceName . '\]_\ze\%($\|\s\|[''")\]}>/:.,;!?\\-]\)+' |
825 | 132 |
133 execute 'syn match rstHyperlinkReference' . | |
1224 | 134 \ ' /\<' . s:ReferenceName . '__\=\ze\%($\|\s\|[''")\]}>/:.,;!?\\-]\)/' |
375 | 135 |
825 | 136 syn match rstStandaloneHyperlink contains=@NoSpell |
137 \ "\<\%(\%(\%(https\=\|file\|ftp\|gopher\)://\|\%(mailto\|news\):\)[^[:space:]'\"<>]\+\|www[[:alnum:]_-]*\.[[:alnum:]_-]\+\.[^[:space:]'\"<>]\+\)[[:alnum:]/]" | |
7 | 138 |
3920 | 139 syn region rstCodeBlock contained matchgroup=rstDirective |
6159 | 140 \ start=+\%(sourcecode\|code\%(-block\)\=\)::\_s*\n\ze\z(\s\+\)+ |
3920 | 141 \ skip=+^$+ |
6159 | 142 \ end=+^\z1\@!+ |
3920 | 143 \ contains=@NoSpell |
144 syn cluster rstDirectives add=rstCodeBlock | |
145 | |
146 if !exists('g:rst_syntax_code_list') | |
6159 | 147 let g:rst_syntax_code_list = ['vim', 'java', 'cpp', 'lisp', 'php', |
148 \ 'python', 'perl', 'sh'] | |
3920 | 149 endif |
150 | |
151 for code in g:rst_syntax_code_list | |
152 unlet! b:current_syntax | |
6292
31f7581068a9
Update runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
6159
diff
changeset
|
153 " 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
|
154 let prior_isk = &l:iskeyword |
3920 | 155 exe 'syn include @rst'.code.' syntax/'.code.'.vim' |
156 exe 'syn region rstDirective'.code.' matchgroup=rstDirective fold ' | |
6159 | 157 \.'start=#\%(sourcecode\|code\%(-block\)\=\)::\s\+'.code.'\_s*\n\ze\z(\s\+\)# ' |
3920 | 158 \.'skip=#^$# ' |
6159 | 159 \.'end=#^\z1\@!# contains=@NoSpell,@rst'.code |
3920 | 160 exe 'syn cluster rstDirectives add=rstDirective'.code |
6292
31f7581068a9
Update runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
6159
diff
changeset
|
161 " reset 'isk' setting, if it has been changed |
31f7581068a9
Update runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
6159
diff
changeset
|
162 if &l:iskeyword !=# prior_isk |
31f7581068a9
Update runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
6159
diff
changeset
|
163 let &l:iskeyword = prior_isk |
31f7581068a9
Update runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
6159
diff
changeset
|
164 endif |
31f7581068a9
Update runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
6159
diff
changeset
|
165 unlet! prior_isk |
3920 | 166 endfor |
167 | |
4780 | 168 " TODO: Use better syncing. |
169 syn sync minlines=50 linebreaks=2 | |
170 | |
825 | 171 hi def link rstTodo Todo |
172 hi def link rstComment Comment | |
3750 | 173 hi def link rstSections Title |
174 hi def link rstTransition rstSections | |
825 | 175 hi def link rstLiteralBlock String |
176 hi def link rstQuotedLiteralBlock String | |
177 hi def link rstDoctestBlock PreProc | |
178 hi def link rstTableLines rstDelimiter | |
179 hi def link rstSimpleTableLines rstTableLines | |
180 hi def link rstExplicitMarkup rstDirective | |
181 hi def link rstDirective Keyword | |
182 hi def link rstFootnote String | |
183 hi def link rstCitation String | |
184 hi def link rstHyperlinkTarget String | |
185 hi def link rstExDirective String | |
186 hi def link rstSubstitutionDefinition rstDirective | |
187 hi def link rstDelimiter Delimiter | |
188 " TODO: I dunno... | |
189 hi def rstEmphasis term=italic cterm=italic gui=italic | |
190 hi def link rstStrongEmphasis Special | |
191 "term=bold cterm=bold gui=bold | |
192 hi def link rstInterpretedTextOrHyperlinkReference Identifier | |
193 hi def link rstInlineLiteral String | |
194 hi def link rstSubstitutionReference PreProc | |
195 hi def link rstInlineInternalTargets Identifier | |
196 hi def link rstFootnoteReference Identifier | |
197 hi def link rstCitationReference Identifier | |
198 hi def link rstHyperLinkReference Identifier | |
199 hi def link rstStandaloneHyperlink Identifier | |
3920 | 200 hi def link rstCodeBlock String |
7 | 201 |
202 let b:current_syntax = "rst" | |
203 | |
375 | 204 let &cpo = s:cpo_save |
205 unlet s:cpo_save |