]> ruderich.org/simon Gitweb - config/dotfiles.git/blob - vim/vim/syntax/asciidoc.vim
vim/setup.sh: correct/cleanup comments
[config/dotfiles.git] / vim / vim / syntax / asciidoc.vim
1 " Vim syntax file
2 " Language:     AsciiDoc
3 " Author:       Stuart Rackham <srackham@gmail.com> (inspired by Felix
4 "               Obenhuber's original asciidoc.vim script).
5 " URL:          http://www.methods.co.nz/asciidoc/
6 " Licence:      GPL (http://www.gnu.org)
7 " Remarks:      Vim 6 or greater
8 " Limitations:  See 'Appendix E: Vim Syntax Highlighter' in the AsciiDoc 'User
9 "               Guide'.
10
11 if exists("b:current_syntax")
12   finish
13 endif
14
15 syn clear
16 syn sync fromstart
17 syn sync linebreaks=1
18
19 " Run :help syn-priority to review syntax matching priority.
20 syn keyword asciidocToDo TODO FIXME CHECK TEST XXX ZZZ DEPRECATED
21 syn match asciidocBackslash /\\/
22 syn region asciidocIdMarker start=/^\$Id:\s/ end=/\s\$$/
23 syn match asciidocCallout /\\\@<!<\d\{1,2}>/
24 syn match asciidocListBlockDelimiter /^--$/
25 syn match asciidocLineBreak /[ \t]+$/
26 syn match asciidocRuler /^'\{3,}$/
27 syn match asciidocPagebreak /^<\{3,}$/
28 syn match asciidocEntityRef /\\\@<!&[#a-zA-Z]\S\{-};/
29 syn region asciidocLiteralParagraph start=/\(\%^\|\_^\n\)\@<=\s\+\S\+/ end=/\(^\(+\|--\)\?\s*$\)\@=/ contains=asciidocToDo
30 syn match asciidocURL /\\\@<!\<\(http\|https\|ftp\|file\|irc\):\/\/[^| \t]*\(\w\|\/\)/
31 syn match asciidocEmail /[\\.:]\@<!\(\<\|<\)\w\(\w\|[.-]\)*@\(\w\|[.-]\)*\w>\?[0-9A-Za-z_]\@!/
32 syn match asciidocAttributeRef /\\\@<!{\w\(\w\|[-,+]\)*\([=!@#$%?:].*\)\?}/
33
34 " As a damage control measure quoted patterns always terminate at a blank
35 " line (see 'Limitations' above).
36 syn match asciidocQuotedAttributeList /\\\@<!\[[a-zA-Z0-9_-][a-zA-Z0-9 _-]*\][+_'`#*]\@=/
37 syn match asciidocQuotedSubscript /\\\@<!\~\S\_.\{-}\(\~\|\n\s*\n\)/ contains=asciidocEntityRef
38 syn match asciidocQuotedSuperscript /\\\@<!\^\S\_.\{-}\(\^\|\n\s*\n\)/ contains=asciidocEntityRef
39
40 syn match asciidocQuotedMonospaced /\(^\|[| \t([.,=\]]\)\@<=+\([ )\n\t]\)\@!\(.\|\n\(\s*\n\)\@!\)\{-}\S\(+\([| \t)[\],.?!;:=]\|$\)\@=\)/ contains=asciidocEntityRef
41 syn match asciidocQuotedMonospaced2 /\(^\|[| \t([.,=\]]\)\@<=`\([ )\n\t]\)\@!\(.\|\n\(\s*\n\)\@!\)\{-}\S\(`\([| \t)[\],.?!;:=]\|$\)\@=\)/
42 syn match asciidocQuotedUnconstrainedMonospaced /[\\+]\@<!++\S\_.\{-}\(++\|\n\s*\n\)/ contains=asciidocEntityRef
43
44 syn match asciidocQuotedEmphasized /\(^\|[| \t([.,=\]]\)\@<=_\([ )\n\t]\)\@!\(.\|\n\(\s*\n\)\@!\)\{-}\S\(_\([| \t)[\],.?!;:=]\|$\)\@=\)/ contains=asciidocEntityRef
45 syn match asciidocQuotedEmphasized2 /\(^\|[| \t([.,=\]]\)\@<='\([ )\n\t]\)\@!\(.\|\n\(\s*\n\)\@!\)\{-}\S\('\([| \t)[\],.?!;:=]\|$\)\@=\)/ contains=asciidocEntityRef
46 syn match asciidocQuotedUnconstrainedEmphasized /\\\@<!__\S\_.\{-}\(__\|\n\s*\n\)/ contains=asciidocEntityRef
47
48 syn match asciidocQuotedBold /\(^\|[| \t([.,=\]]\)\@<=\*\([ )\n\t]\)\@!\(.\|\n\(\s*\n\)\@!\)\{-}\S\(\*\([| \t)[\],.?!;:=]\|$\)\@=\)/ contains=asciidocEntityRef
49 syn match asciidocQuotedUnconstrainedBold /\\\@<!\*\*\S\_.\{-}\(\*\*\|\n\s*\n\)/ contains=asciidocEntityRef
50
51 " Don't allow ` in single quoted (a kludge to stop confusion with `monospaced`).
52 syn match asciidocQuotedSingleQuoted /\(^\|[| \t([.,=\]]\)\@<=`\([ )\n\t]\)\@!\([^`]\|\n\(\s*\n\)\@!\)\{-}[^` \t]\('\([| \t)[\],.?!;:=]\|$\)\@=\)/ contains=asciidocEntityRef
53
54 syn match asciidocQuotedDoubleQuoted /\(^\|[| \t([.,=\]]\)\@<=``\([ )\n\t]\)\@!\(.\|\n\(\s*\n\)\@!\)\{-}\S\(''\([| \t)[\],.?!;:=]\|$\)\@=\)/ contains=asciidocEntityRef
55
56 syn match asciidocDoubleDollarPassthrough /\\\@<!\(^\|[^0-9a-zA-Z$]\)\@<=\$\$..\{-}\(\$\$\([^0-9a-zA-Z$]\|$\)\@=\|^$\)/
57 syn match asciidocTriplePlusPassthrough /\\\@<!\(^\|[^0-9a-zA-Z$]\)\@<=+++..\{-}\(+++\([^0-9a-zA-Z$]\|$\)\@=\|^$\)/
58
59 syn match asciidocAdmonition /^\u\{3,15}:\(\s\+.*\)\@=/
60
61 syn region asciidocTable_OLD start=/^\([`.']\d*[-~_]*\)\+[-~_]\+\d*$/ end=/^$/
62 syn match asciidocBlockTitle /^\.[^. \t].*[^-~_]$/ contains=asciidocQuoted.*,asciidocAttributeRef
63 syn match asciidocTitleUnderline /[-=~^+]\{2,}$/ transparent contained contains=NONE
64 syn match asciidocOneLineTitle /^=\{1,5}\s\+\S.*$/ contains=asciidocQuoted.*,asciidocMacroAttributes,asciidocAttributeRef,asciidocEntityRef,asciidocEmail,asciidocURL,asciidocBackslash
65 syn match asciidocTwoLineTitle /^[^. +/].*[^.]\n[-=~^+]\{2,}$/ contains=asciidocQuoted.*,asciidocMacroAttributes,asciidocAttributeRef,asciidocEntityRef,asciidocEmail,asciidocURL,asciidocBackslash,asciidocTitleUnderline
66
67 syn match asciidocAttributeList /^\[[^[ \t].*\]$/
68 syn match asciidocQuoteBlockDelimiter /^_\{4,}$/
69 syn match asciidocExampleBlockDelimiter /^=\{4,}$/
70 syn match asciidocSidebarDelimiter /^*\{4,}$/
71
72 " See http://vimdoc.sourceforge.net/htmldoc/usr_44.html for excluding region
73 " contents from highlighting.
74 syn match asciidocTablePrefix /\(\S\@<!\(\([0-9.]\+\)\([*+]\)\)\?\([<\^>.]\{,3}\)\?\([a-z]\)\?\)\?|/ containedin=asciidocTableBlock contained
75 syn region asciidocTableBlock matchgroup=asciidocTableDelimiter start=/^|=\{3,}$/ end=/^|=\{3,}$/ keepend contains=ALL
76 syn match asciidocTablePrefix /\(\S\@<!\(\([0-9.]\+\)\([*+]\)\)\?\([<\^>.]\{,3}\)\?\([a-z]\)\?\)\?!/ containedin=asciidocTableBlock contained
77 syn region asciidocTableBlock2 matchgroup=asciidocTableDelimiter2 start=/^!=\{3,}$/ end=/^!=\{3,}$/ keepend contains=ALL
78
79 syn match asciidocListContinuation /^+$/
80 syn region asciidocLiteralBlock start=/^\.\{4,}$/ end=/^\.\{4,}$/ contains=asciidocCallout,asciidocToDo keepend
81 syn region asciidocListingBlock start=/^-\{4,}$/ end=/^-\{4,}$/ contains=asciidocCallout,asciidocToDo keepend
82 syn region asciidocCommentBlock start="^/\{4,}$" end="^/\{4,}$" contains=asciidocToDo
83 syn region asciidocPassthroughBlock start="^+\{4,}$" end="^+\{4,}$"
84
85 " Allowing leading \w characters in the filter delimiter is to accomodate
86 " the pre version 8.2.7 syntax and may be removed in future releases.
87 syn region asciidocFilterBlock start=/^\w*\~\{4,}$/ end=/^\w*\~\{4,}$/
88
89 syn region asciidocMacroAttributes matchgroup=asciidocRefMacro start=/\\\@<!<<"\{-}\(\w\|-\|_\|:\|\.\)\+"\?,\?/ end=/\(>>\)\|^$/ contains=asciidocQuoted.* keepend
90 syn region asciidocMacroAttributes matchgroup=asciidocAnchorMacro start=/\\\@<!\[\{2}\(\w\|-\|_\|:\|\.\)\+,\?/ end=/\]\{2}/ keepend
91 syn region asciidocMacroAttributes matchgroup=asciidocAnchorMacro start=/\\\@<!\[\{3}\(\w\|-\|_\|:\|\.\)\+/ end=/\]\{3}/ keepend
92 syn region asciidocMacroAttributes matchgroup=asciidocMacro start=/[\\0-9a-zA-Z]\@<!\w\(\w\|-\)*:\S\{-}\[/ skip=/\\\]/ end=/\]\|^$/ contains=asciidocQuoted.*,asciidocAttributeRef keepend
93 " Highlight macro that starts with an attribute reference (a common idiom).
94 syn region asciidocMacroAttributes matchgroup=asciidocMacro start=/\(\\\@<!{\w\(\w\|[-,+]\)*\([=!@#$%?:].*\)\?}\)\@<=\S\{-}\[/ skip=/\\\]/ end=/\]\|^$/ contains=asciidocQuoted.*,asciidocAttributeRef keepend
95 syn region asciidocMacroAttributes matchgroup=asciidocIndexTerm start=/\\\@<!(\{2,3}/ end=/)\{2,3}/ contains=asciidocQuoted.*,asciidocAttributeRef keepend
96
97 syn match asciidocCommentLine "^//\([^/].*\|\)$" contains=asciidocToDo
98
99 syn region asciidocAttributeEntry start=/^:\w/ end=/:\(\s\|$\)/ oneline
100
101 " Lists.
102 syn match asciidocListBullet /^\s*\zs\(-\|\*\{1,5}\)\ze\s/
103 syn match asciidocListNumber /^\s*\zs\(\(\d\+\.\)\|\.\{1,5}\|\(\a\.\)\|\([ivxIVX]\+)\)\)\ze\s\+/
104 syn region asciidocListLabel start=/^\s*/ end=/\(:\{2,4}\|;;\)$/ oneline contains=asciidocQuoted.*,asciidocMacroAttributes,asciidocAttributeRef,asciidocEntityRef,asciidocEmail,asciidocURL,asciidocBackslash,asciidocToDo keepend
105 " DEPRECATED: Horizontal label.
106 syn region asciidocHLabel start=/^\s*/ end=/\(::\|;;\)\(\s\+\|\\$\)/ oneline contains=asciidocQuoted.*,asciidocMacroAttributes keepend
107 " Starts with any of the above.
108 syn region asciidocList start=/^\s*\(-\|\*\{1,5}\)\s/ start=/^\s*\(\(\d\+\.\)\|\.\{1,5}\|\(\a\.\)\|\([ivxIVX]\+)\)\)\s\+/ start=/.\+\(:\{2,4}\|;;\)$/ end=/\(^[=*]\{4,}$\)\@=/ end=/\(^+\?\s*$\)\@=/ contains=asciidocList.\+,asciidocQuoted.*,asciidocMacroAttributes,asciidocAttributeRef,asciidocEntityRef,asciidocEmail,asciidocURL,asciidocBackslash,asciidocCommentLine,asciidocAttributeList,asciidocToDo
109
110 highlight link asciidocAdmonition Special
111 highlight link asciidocAnchorMacro Macro
112 highlight link asciidocAttributeEntry Special
113 highlight link asciidocAttributeList Special
114 highlight link asciidocAttributeMacro Macro
115 highlight link asciidocAttributeRef Special
116 highlight link asciidocBackslash Special
117 highlight link asciidocBlockTitle Title
118 highlight link asciidocCallout Label
119 highlight link asciidocCommentBlock Comment
120 highlight link asciidocCommentLine Comment
121 highlight link asciidocDoubleDollarPassthrough Special
122 highlight link asciidocEmail Macro
123 highlight link asciidocEntityRef Special
124 highlight link asciidocExampleBlockDelimiter Type
125 highlight link asciidocFilterBlock Type
126 highlight link asciidocHLabel Label
127 highlight link asciidocIdMarker Special
128 highlight link asciidocIndexTerm Macro
129 highlight link asciidocLineBreak Special
130 highlight link asciidocListBlockDelimiter Label
131 highlight link asciidocListBullet Label
132 highlight link asciidocListContinuation Label
133 highlight link asciidocListingBlock Identifier
134 highlight link asciidocListLabel Label
135 highlight link asciidocListNumber Label
136 highlight link asciidocLiteralBlock Identifier
137 highlight link asciidocLiteralParagraph Identifier
138 highlight link asciidocMacroAttributes Label
139 highlight link asciidocMacro Macro
140 highlight link asciidocOneLineTitle Title
141 highlight link asciidocPagebreak Type
142 highlight link asciidocPassthroughBlock Identifier
143 highlight link asciidocQuoteBlockDelimiter Type
144 highlight link asciidocQuotedAttributeList Special
145 highlight link asciidocQuotedBold Special
146 highlight link asciidocQuotedDoubleQuoted Label
147 highlight link asciidocQuotedEmphasized2 Type
148 highlight link asciidocQuotedEmphasized Type
149 highlight link asciidocQuotedMonospaced2 Identifier
150 highlight link asciidocQuotedMonospaced Identifier
151 highlight link asciidocQuotedSingleQuoted Label
152 highlight link asciidocQuotedSubscript Type
153 highlight link asciidocQuotedSuperscript Type
154 highlight link asciidocQuotedUnconstrainedBold Special
155 highlight link asciidocQuotedUnconstrainedEmphasized Type
156 highlight link asciidocQuotedUnconstrainedMonospaced Identifier
157 highlight link asciidocRefMacro Macro
158 highlight link asciidocRuler Type
159 highlight link asciidocSidebarDelimiter Type
160 highlight link asciidocTableBlock2 NONE
161 highlight link asciidocTableBlock NONE
162 highlight link asciidocTableDelimiter2 Label
163 highlight link asciidocTableDelimiter Label
164 highlight link asciidocTable_OLD Type
165 highlight link asciidocTablePrefix2 Label
166 highlight link asciidocTablePrefix Label
167 highlight link asciidocToDo Todo
168 highlight link asciidocTriplePlusPassthrough Special
169 highlight link asciidocTwoLineTitle Title
170 highlight link asciidocURL Macro
171 let b:current_syntax = "asciidoc"
172
173 " vim: wrap et sw=2 sts=2: