blob: 44439cb2cdb4f36a1491abf0192fc27634978792 [file] [log] [blame]
Bram Moolenaar071d4272004-06-13 20:20:40 +00001" Vim syntax file
Bram Moolenaar543b7ef2013-06-01 14:50:56 +02002" Language: Perl POD format
3" Maintainer: vim-perl <vim-perl@googlegroups.com>
4" Previously: Scott Bigham <dsb@killerbunnies.org>
Bram Moolenaar8c1b8cb2022-06-14 17:41:28 +01005" Homepage: https://github.com/vim-perl/vim-perl
6" Bugs/requests: https://github.com/vim-perl/vim-perl/issues
7" License: Vim License (see :help license)
8" Last Change: 2021 Oct 8
Bram Moolenaar071d4272004-06-13 20:20:40 +00009
10" To add embedded POD documentation highlighting to your syntax file, add
11" the commands:
12"
13" syn include @Pod <sfile>:p:h/pod.vim
14" syn region myPOD start="^=pod" start="^=head" end="^=cut" keepend contained contains=@Pod
15"
16" and add myPod to the contains= list of some existing region, probably a
17" comment. The "keepend" flag is needed because "=cut" is matched as a
18" pattern in its own right.
19
20
21" Remove any old syntax stuff hanging around (this is suppressed
22" automatically by ":syn include" if necessary).
Bram Moolenaar89bcfda2016-08-30 23:26:57 +020023" quit when a syntax file was already loaded
24if exists("b:current_syntax")
Bram Moolenaar071d4272004-06-13 20:20:40 +000025 finish
26endif
27
Bram Moolenaar543b7ef2013-06-01 14:50:56 +020028let s:cpo_save = &cpo
29set cpo&vim
30
Bram Moolenaar8c1b8cb2022-06-14 17:41:28 +010031" TODO: add supported encodings when we can utilize better performing Vim 8 features
32syn match podEncoding "[0-9A-Za-z_-]\+" contained contains=@NoSpell
Bram Moolenaar071d4272004-06-13 20:20:40 +000033
34" Text of a =head1, =head2 or =item command
Bram Moolenaar8c1b8cb2022-06-14 17:41:28 +010035syn region podCmdText start="\S.*$" end="^\ze\s*$" end="^\ze=cut\>" contained contains=podFormat,@NoSpell
Bram Moolenaar071d4272004-06-13 20:20:40 +000036
37" Indent amount of =over command
Bram Moolenaar8c1b8cb2022-06-14 17:41:28 +010038syn match podOverIndent "\d*\.\=\d\+\>" contained contains=@NoSpell
Bram Moolenaar071d4272004-06-13 20:20:40 +000039
40" Formatter identifier keyword for =for, =begin and =end commands
Bram Moolenaar97409f12005-07-08 22:17:29 +000041syn match podForKeywd "\S\+" contained contains=@NoSpell
Bram Moolenaar071d4272004-06-13 20:20:40 +000042
43" An indented line, to be displayed verbatim
Bram Moolenaar8c1b8cb2022-06-14 17:41:28 +010044syn region podVerbatim start="^\s\+\S.*$" end="^\ze\s*$" end="^\ze=cut\>" contains=@NoSpell
45
46syn region podOrdinary start="^\S.*$" end="^\ze\s*$" end="^\ze=cut\>" contains=podFormat,podSpecial,@Spell
Bram Moolenaar071d4272004-06-13 20:20:40 +000047
48" Inline textual items handled specially by POD
Bram Moolenaar97409f12005-07-08 22:17:29 +000049syn match podSpecial "\(\<\|&\)\I\i*\(::\I\i*\)*([^)]*)" contains=@NoSpell
50syn match podSpecial "[$@%]\I\i*\(::\I\i*\)*\>" contains=@NoSpell
Bram Moolenaar071d4272004-06-13 20:20:40 +000051
52" Special formatting sequences
Bram Moolenaar8c1b8cb2022-06-14 17:41:28 +010053
54syn cluster podFormat contains=podFormat,podFormatError
55
56syn match podFormatError "[ADGHJKM-RT-WY]<"
57
58syn region podFormat matchgroup=podFormatDelimiter start="[IBSCLFX]<" end=">" contains=@podFormat,@NoSpell
59syn region podFormat matchgroup=podFormatDelimiter start="[IBSCLFX]<<\%(\s\+\|$\)" end="\%(\s\+\|^\)>>" contains=@podFormat,@NoSpell
60
Bram Moolenaar3fdfa4a2004-10-07 21:02:47 +000061syn match podFormat "Z<>"
Bram Moolenaar8c1b8cb2022-06-14 17:41:28 +010062
63syn region podFormat matchgroup=podFormatDelimiter start="E<" end=">" oneline contains=podEscape,podEscape2,@NoSpell
64
65" HTML entities {{{1
66" Source: Pod/Escapes.pm
67syn keyword podEscape contained lt gt quot amp apos sol verbar lchevron rchevron nbsp iexcl cent pound curren yen brvbar sect uml copy ordf laquo not shy reg macr deg plusmn sup2 sup3 acute micro para middot cedil sup1 ordm raquo frac14 frac12 frac34 iquest Agrave Aacute Acirc Atilde Auml Aring AElig Ccedil Egrave Eacute Ecirc Euml Igrave Iacute Icirc Iuml ETH Ntilde Ograve Oacute Ocirc Otilde Ouml times Oslash Ugrave Uacute Ucirc Uuml Yacute THORN szlig agrave aacute acirc atilde auml aring aelig ccedil egrave eacute ecirc euml igrave iacute icirc iuml eth ntilde ograve oacute ocirc otilde ouml divide oslash ugrave uacute ucirc uuml yacute thorn yuml fnof Alpha Beta Gamma Delta Epsilon Zeta Eta Theta Iota Kappa Lambda Mu Nu Xi Omicron Pi Rho Sigma Tau Upsilon Phi Chi Psi Omega alpha beta gamma delta epsilon zeta eta theta iota kappa lambda mu nu xi omicron pi rho sigmaf sigma tau upsilon phi chi psi omega thetasym upsih piv bull hellip prime Prime oline frasl weierp image real trade alefsym larr uarr rarr darr harr crarr lArr uArr rArr dArr hArr forall part exist empty nabla isin notin ni prod sum minus lowast radic prop infin ang and or cap cup int there4 sim cong asymp ne equiv le ge sub sup nsub sube supe oplus otimes perp sdot lceil rceil lfloor rfloor lang rang loz spades clubs hearts diams OElig oelig Scaron scaron Yuml circ tilde ensp emsp thinsp zwnj zwj lrm rlm ndash mdash lsquo rsquo sbquo ldquo rdquo bdquo dagger Dagger permil lsaquo rsaquo
68" }}}
69
70syn match podEscape2 "\d\+" contained contains=@NoSpell
71syn match podEscape2 "0\=x\x\+" contained contains=@NoSpell
72syn match podEscape2 "0\o\+" contained contains=@NoSpell
73
74
75" POD commands
76syn match podCommand "^=encoding\>" nextgroup=podEncoding skipwhite contains=@NoSpell
77syn match podCommand "^=head[1234]\>" nextgroup=podCmdText skipwhite skipnl contains=@NoSpell
78syn match podCommand "^=item\>" nextgroup=podCmdText skipwhite skipnl contains=@NoSpell
79syn match podCommand "^=over\>" nextgroup=podOverIndent skipwhite contains=@NoSpell
80syn match podCommand "^=back" contains=@NoSpell
81syn match podCommand "^=cut" contains=@NoSpell
82syn match podCommand "^=pod" contains=@NoSpell
83syn match podCommand "^=for" nextgroup=podForKeywd skipwhite contains=@NoSpell
84syn match podCommand "^=begin" nextgroup=podForKeywd skipwhite contains=@NoSpell
85syn match podCommand "^=end" nextgroup=podForKeywd skipwhite contains=@NoSpell
86
87" Comments
88
89syn keyword podForKeywd comment contained nextgroup=podForComment skipwhite skipnl
90
91if exists("perl_pod_no_comment_fold")
92 syn region podBeginComment start="^=begin\s\+comment\s*$" end="^=end\s\+comment\ze\s*$" keepend extend contains=podCommand
93 syn region podForComment start="\S.*$" end="^\ze\s*$" end="^\ze=cut\>" contained contains=@Spell,podTodo
94else
95 syn region podBeginComment start="^=begin\s\+comment\s*$" end="^=end\s\+comment\ze\s*$" keepend extend contains=podCommand,podTodo fold
96 syn region podForComment start="\S.*$" end="^\ze\s*$" end="^\ze=cut\>" contained contains=@Spell,podTodo fold
97endif
98
99syn keyword podTodo contained TODO FIXME XXX
100
101" Plain Pod files
102syn region podNonPod start="\%^\%(=\w\+\>\)\@!" end="^\ze=\a\w*\>"
103syn region podNonPod matchgroup=podCommand start="^=cut\>" end="\%$"
104syn region podNonPod matchgroup=podCommand start="^=cut\>" end="^\ze=\a\w*\>"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000105
106" Define the default highlighting.
Bram Moolenaar89bcfda2016-08-30 23:26:57 +0200107" Only when an item doesn't have highlighting yet
Bram Moolenaar071d4272004-06-13 20:20:40 +0000108
Bram Moolenaarf37506f2016-08-31 22:22:10 +0200109hi def link podCommand Statement
Bram Moolenaar8c1b8cb2022-06-14 17:41:28 +0100110hi def link podBeginComment Comment
111hi def link podForComment Comment
112hi def link podNonPod Comment
113hi def link podTodo Todo
Bram Moolenaarf37506f2016-08-31 22:22:10 +0200114hi def link podCmdText String
Bram Moolenaar8c1b8cb2022-06-14 17:41:28 +0100115hi def link podEncoding Constant
Bram Moolenaar37c64c72017-09-19 22:06:03 +0200116hi def link podOverIndent Number
Bram Moolenaarf37506f2016-08-31 22:22:10 +0200117hi def link podForKeywd Identifier
Bram Moolenaar8c1b8cb2022-06-14 17:41:28 +0100118hi def link podVerbatim PreProc
Bram Moolenaarf37506f2016-08-31 22:22:10 +0200119hi def link podFormat Identifier
Bram Moolenaar8c1b8cb2022-06-14 17:41:28 +0100120hi def link podFormatDelimiter podFormat
121hi def link podFormatError Error
Bram Moolenaarf37506f2016-08-31 22:22:10 +0200122hi def link podSpecial Identifier
Bram Moolenaar8c1b8cb2022-06-14 17:41:28 +0100123hi def link podEscape Constant
Bram Moolenaarf37506f2016-08-31 22:22:10 +0200124hi def link podEscape2 Number
Bram Moolenaar071d4272004-06-13 20:20:40 +0000125
Bram Moolenaar543b7ef2013-06-01 14:50:56 +0200126if exists("perl_pod_spellcheck_headings")
127 " Spell-check headings
128 syn clear podCmdText
Bram Moolenaar8c1b8cb2022-06-14 17:41:28 +0100129 syn region podCmdText start="\S.*$" end="^\s*$" end="^\ze=cut\>" contained contains=podFormat
Bram Moolenaar543b7ef2013-06-01 14:50:56 +0200130endif
131
132if exists("perl_pod_formatting")
133 " By default, escapes like C<> are not checked for spelling. Remove B<>
134 " and I<> from the list of escapes.
135 syn clear podFormat
Bram Moolenaar8c1b8cb2022-06-14 17:41:28 +0100136 syn region podFormat start="[CLF]<[^<]"me=e-1 end=">" contains=@podFormat,@NoSpell
137 syn region podFormat start="[CLF]<<\%(\s\+\|$\)" end="\%(\s\+\|^\)>>" contains=@podFormat,@NoSpell
Bram Moolenaar543b7ef2013-06-01 14:50:56 +0200138
139 " Don't spell-check inside E<>, but ensure that the E< itself isn't
140 " marked as a spelling mistake.
Bram Moolenaar8c1b8cb2022-06-14 17:41:28 +0100141 syn region podFormat start="E<" end=">" oneline contains=podEscape,podEscape2,@NoSpell
Bram Moolenaar543b7ef2013-06-01 14:50:56 +0200142
143 " Z<> is a mock formatting code. Ensure Z<> on its own isn't marked as a
144 " spelling mistake.
145 syn match podFormat "Z<>" contains=podEscape,podEscape2,@NoSpell
146
147 " These are required so that whatever is *within* B<...>, I<...>, etc. is
148 " spell-checked, but not the B, I, ... itself.
149 syn match podBoldOpen "B<" contains=@NoSpell
150 syn match podItalicOpen "I<" contains=@NoSpell
151 syn match podNoSpaceOpen "S<" contains=@NoSpell
152 syn match podIndexOpen "X<" contains=@NoSpell
153
154 " Same as above but for the << >> syntax.
Bram Moolenaar8c1b8cb2022-06-14 17:41:28 +0100155 syn match podBoldAlternativeDelimOpen "B<<\%(\s\+\|$\)" contains=@NoSpell
156 syn match podItalicAlternativeDelimOpen "I<<\%(\s\+\|$\)" contains=@NoSpell
157 syn match podNoSpaceAlternativeDelimOpen "S<<\%(\s\+\|$\)" contains=@NoSpell
158 syn match podIndexAlternativeDelimOpen "X<<\%(\s\+\|$\)" contains=@NoSpell
Bram Moolenaar543b7ef2013-06-01 14:50:56 +0200159
160 " Add support for spell checking text inside B<>, I<>, S<> and X<>.
Bram Moolenaar8c1b8cb2022-06-14 17:41:28 +0100161 syn region podBold start="B<[^<]"me=e end=">" contains=podBoldItalic,podBoldOpen
162 syn region podBoldAlternativeDelim start="B<<\%(\s\+\|$\)" end="\%(\s\+\|^\)>>" contains=podBoldAlternativeDelimOpen
Bram Moolenaar543b7ef2013-06-01 14:50:56 +0200163
Bram Moolenaar8c1b8cb2022-06-14 17:41:28 +0100164 syn region podItalic start="I<[^<]"me=e end=">" contains=podItalicBold,podItalicOpen
165 syn region podItalicAlternativeDelim start="I<<\%(\s\+\|$\)" end="\%(\s\+\|^\)>>" contains=podItalicAlternativeDelimOpen
Bram Moolenaar543b7ef2013-06-01 14:50:56 +0200166
167 " Nested bold/italic and vice-versa
Bram Moolenaar8c1b8cb2022-06-14 17:41:28 +0100168 syn region podBoldItalic contained start="I<[^<]"me=e end=">"
169 syn region podItalicBold contained start="B<[^<]"me=e end=">"
Bram Moolenaar543b7ef2013-06-01 14:50:56 +0200170
Bram Moolenaar8c1b8cb2022-06-14 17:41:28 +0100171 syn region podNoSpace start="S<[^<]"ms=s-2 end=">"me=e contains=podNoSpaceOpen
172 syn region podNoSpaceAlternativeDelim start="S<<\%(\s\+\|$\)"ms=s-2 end="\%(\s\+\|^\)>>"me=e contains=podNoSpaceAlternativeDelimOpen
Bram Moolenaar543b7ef2013-06-01 14:50:56 +0200173
Bram Moolenaar8c1b8cb2022-06-14 17:41:28 +0100174 syn region podIndex start="X<[^<]"ms=s-2 end=">"me=e contains=podIndexOpen
175 syn region podIndexAlternativeDelim start="X<<\%(\s\+\|$\)"ms=s-2 end="\%(\s\+\|^\)>>"me=e contains=podIndexAlternativeDelimOpen
Bram Moolenaar543b7ef2013-06-01 14:50:56 +0200176
177 " Restore this (otherwise B<> is shown as bold inside verbatim)
Bram Moolenaar8c1b8cb2022-06-14 17:41:28 +0100178 syn region podVerbatim start="^\s\+\S.*$" end="^\ze\s*$" end="^\ze=cut\>" contains=@NoSpell
Bram Moolenaar543b7ef2013-06-01 14:50:56 +0200179
180 " Ensure formatted text can be displayed in headings and items
181 syn clear podCmdText
182
183 if exists("perl_pod_spellcheck_headings")
Bram Moolenaar8c1b8cb2022-06-14 17:41:28 +0100184 syn match podCmdText ".*$" contained contains=@podFormat,podBold,
Bram Moolenaar543b7ef2013-06-01 14:50:56 +0200185 \podBoldAlternativeDelim,podItalic,podItalicAlternativeDelim,
186 \podBoldOpen,podItalicOpen,podBoldAlternativeDelimOpen,
187 \podItalicAlternativeDelimOpen,podNoSpaceOpen
188 else
Bram Moolenaar8c1b8cb2022-06-14 17:41:28 +0100189 syn match podCmdText ".*$" contained contains=@podFormat,podBold,
Bram Moolenaar543b7ef2013-06-01 14:50:56 +0200190 \podBoldAlternativeDelim,podItalic,podItalicAlternativeDelim,
191 \@NoSpell
192 endif
193
194 " Specify how to display these
195 hi def podBold term=bold cterm=bold gui=bold
196
197 hi link podBoldAlternativeDelim podBold
198 hi link podBoldAlternativeDelimOpen podBold
199 hi link podBoldOpen podBold
200
201 hi link podNoSpace Identifier
202 hi link podNoSpaceAlternativeDelim Identifier
203
204 hi link podIndex Identifier
205 hi link podIndexAlternativeDelim Identifier
206
207 hi def podItalic term=italic cterm=italic gui=italic
208
209 hi link podItalicAlternativeDelim podItalic
210 hi link podItalicAlternativeDelimOpen podItalic
211 hi link podItalicOpen podItalic
212
213 hi def podBoldItalic term=italic,bold cterm=italic,bold gui=italic,bold
214 hi def podItalicBold term=italic,bold cterm=italic,bold gui=italic,bold
215endif
216
Bram Moolenaar071d4272004-06-13 20:20:40 +0000217let b:current_syntax = "pod"
218
Bram Moolenaar543b7ef2013-06-01 14:50:56 +0200219let &cpo = s:cpo_save
220unlet s:cpo_save
221
Bram Moolenaar8c1b8cb2022-06-14 17:41:28 +0100222" vim: ts=8 fdm=marker: