blob: b9f2e0854f75be364224ab5fef8dbcad28ca2e10 [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>
5" Homepage: http://github.com/vim-perl/vim-perl
6" Bugs/requests: http://github.com/vim-perl/vim-perl/issues
Bram Moolenaar9d98fe92013-08-03 18:35:36 +02007" Last Change: 2013-07-21
Bram Moolenaar071d4272004-06-13 20:20:40 +00008
9" To add embedded POD documentation highlighting to your syntax file, add
10" the commands:
11"
12" syn include @Pod <sfile>:p:h/pod.vim
13" syn region myPOD start="^=pod" start="^=head" end="^=cut" keepend contained contains=@Pod
14"
15" and add myPod to the contains= list of some existing region, probably a
16" comment. The "keepend" flag is needed because "=cut" is matched as a
17" pattern in its own right.
18
19
20" Remove any old syntax stuff hanging around (this is suppressed
21" automatically by ":syn include" if necessary).
22" For version 5.x: Clear all syntax items
23" For version 6.x: Quit when a syntax file was already loaded
24if version < 600
25 syntax clear
26elseif exists("b:current_syntax")
27 finish
28endif
29
Bram Moolenaar543b7ef2013-06-01 14:50:56 +020030let s:cpo_save = &cpo
31set cpo&vim
32
Bram Moolenaar071d4272004-06-13 20:20:40 +000033" POD commands
Bram Moolenaar543b7ef2013-06-01 14:50:56 +020034syn match podCommand "^=encoding" nextgroup=podCmdText contains=@NoSpell
Bram Moolenaarede981a2010-08-11 23:37:32 +020035syn match podCommand "^=head[1234]" nextgroup=podCmdText contains=@NoSpell
36syn match podCommand "^=item" nextgroup=podCmdText contains=@NoSpell
37syn match podCommand "^=over" nextgroup=podOverIndent skipwhite contains=@NoSpell
38syn match podCommand "^=back" contains=@NoSpell
39syn match podCommand "^=cut" contains=@NoSpell
40syn match podCommand "^=pod" contains=@NoSpell
41syn match podCommand "^=for" nextgroup=podForKeywd skipwhite contains=@NoSpell
42syn match podCommand "^=begin" nextgroup=podForKeywd skipwhite contains=@NoSpell
43syn match podCommand "^=end" nextgroup=podForKeywd skipwhite contains=@NoSpell
Bram Moolenaar071d4272004-06-13 20:20:40 +000044
45" Text of a =head1, =head2 or =item command
Bram Moolenaar97409f12005-07-08 22:17:29 +000046syn match podCmdText ".*$" contained contains=podFormat,@NoSpell
Bram Moolenaar071d4272004-06-13 20:20:40 +000047
48" Indent amount of =over command
Bram Moolenaar97409f12005-07-08 22:17:29 +000049syn match podOverIndent "\d\+" contained contains=@NoSpell
Bram Moolenaar071d4272004-06-13 20:20:40 +000050
51" Formatter identifier keyword for =for, =begin and =end commands
Bram Moolenaar97409f12005-07-08 22:17:29 +000052syn match podForKeywd "\S\+" contained contains=@NoSpell
Bram Moolenaar071d4272004-06-13 20:20:40 +000053
54" An indented line, to be displayed verbatim
Bram Moolenaar97409f12005-07-08 22:17:29 +000055syn match podVerbatimLine "^\s.*$" contains=@NoSpell
Bram Moolenaar071d4272004-06-13 20:20:40 +000056
57" Inline textual items handled specially by POD
Bram Moolenaar97409f12005-07-08 22:17:29 +000058syn match podSpecial "\(\<\|&\)\I\i*\(::\I\i*\)*([^)]*)" contains=@NoSpell
59syn match podSpecial "[$@%]\I\i*\(::\I\i*\)*\>" contains=@NoSpell
Bram Moolenaar071d4272004-06-13 20:20:40 +000060
61" Special formatting sequences
Bram Moolenaar97409f12005-07-08 22:17:29 +000062syn region podFormat start="[IBSCLFX]<[^<]"me=e-1 end=">" oneline contains=podFormat,@NoSpell
Bram Moolenaarc81e5e72007-05-05 18:24:42 +000063syn region podFormat start="[IBSCLFX]<<\s" end="\s>>" oneline contains=podFormat,@NoSpell
Bram Moolenaar3fdfa4a2004-10-07 21:02:47 +000064syn match podFormat "Z<>"
Bram Moolenaar97409f12005-07-08 22:17:29 +000065syn match podFormat "E<\(\d\+\|\I\i*\)>" contains=podEscape,podEscape2,@NoSpell
66syn match podEscape "\I\i*>"me=e-1 contained contains=@NoSpell
67syn match podEscape2 "\d\+>"me=e-1 contained contains=@NoSpell
Bram Moolenaar071d4272004-06-13 20:20:40 +000068
69" Define the default highlighting.
70" For version 5.7 and earlier: only when not done already
71" For version 5.8 and later: only when an item doesn't have highlighting yet
72if version >= 508 || !exists("did_pod_syntax_inits")
73 if version < 508
74 let did_pod_syntax_inits = 1
75 command -nargs=+ HiLink hi link <args>
76 else
77 command -nargs=+ HiLink hi def link <args>
78 endif
79
80 HiLink podCommand Statement
81 HiLink podCmdText String
82 HiLink podOverIndent Number
83 HiLink podForKeywd Identifier
84 HiLink podFormat Identifier
85 HiLink podVerbatimLine PreProc
86 HiLink podSpecial Identifier
Bram Moolenaar3fdfa4a2004-10-07 21:02:47 +000087 HiLink podEscape String
88 HiLink podEscape2 Number
Bram Moolenaar071d4272004-06-13 20:20:40 +000089
90 delcommand HiLink
91endif
92
Bram Moolenaar543b7ef2013-06-01 14:50:56 +020093if exists("perl_pod_spellcheck_headings")
94 " Spell-check headings
95 syn clear podCmdText
96 syn match podCmdText ".*$" contained contains=podFormat
97endif
98
99if exists("perl_pod_formatting")
100 " By default, escapes like C<> are not checked for spelling. Remove B<>
101 " and I<> from the list of escapes.
102 syn clear podFormat
103 syn region podFormat start="[CLF]<[^<]"me=e-1 end=">" oneline contains=podFormat,@NoSpell
104 syn region podFormat start="[CLF]<<\s" end="\s>>" oneline contains=podFormat,@NoSpell
105
106 " Don't spell-check inside E<>, but ensure that the E< itself isn't
107 " marked as a spelling mistake.
108 syn match podFormat "E<\(\d\+\|\I\i*\)>" contains=podEscape,podEscape2,@NoSpell
109
110 " Z<> is a mock formatting code. Ensure Z<> on its own isn't marked as a
111 " spelling mistake.
112 syn match podFormat "Z<>" contains=podEscape,podEscape2,@NoSpell
113
114 " These are required so that whatever is *within* B<...>, I<...>, etc. is
115 " spell-checked, but not the B, I, ... itself.
116 syn match podBoldOpen "B<" contains=@NoSpell
117 syn match podItalicOpen "I<" contains=@NoSpell
118 syn match podNoSpaceOpen "S<" contains=@NoSpell
119 syn match podIndexOpen "X<" contains=@NoSpell
120
121 " Same as above but for the << >> syntax.
122 syn match podBoldAlternativeDelimOpen "B<< " contains=@NoSpell
123 syn match podItalicAlternativeDelimOpen "I<< " contains=@NoSpell
124 syn match podNoSpaceAlternativeDelimOpen "S<< " contains=@NoSpell
125 syn match podIndexAlternativeDelimOpen "X<< " contains=@NoSpell
126
127 " Add support for spell checking text inside B<>, I<>, S<> and X<>.
128 syn region podBold start="B<[^<]"me=e end=">" oneline contains=podBoldItalic,podBoldOpen
129 syn region podBoldAlternativeDelim start="B<<\s" end="\s>>" oneline contains=podBoldAlternativeDelimOpen
130
131 syn region podItalic start="I<[^<]"me=e end=">" oneline contains=podItalicBold,podItalicOpen
132 syn region podItalicAlternativeDelim start="I<<\s" end="\s>>" oneline contains=podItalicAlternativeDelimOpen
133
134 " Nested bold/italic and vice-versa
135 syn region podBoldItalic contained start="I<[^<]"me=e end=">" oneline
136 syn region podItalicBold contained start="B<[^<]"me=e end=">" oneline
137
138 syn region podNoSpace start="S<[^<]"ms=s-2 end=">"me=e oneline contains=podNoSpaceOpen
139 syn region podNoSpaceAlternativeDelim start="S<<\s"ms=s-2 end="\s>>"me=e oneline contains=podNoSpaceAlternativeDelimOpen
140
141 syn region podIndex start="X<[^<]"ms=s-2 end=">"me=e oneline contains=podIndexOpen
142 syn region podIndexAlternativeDelim start="X<<\s"ms=s-2 end="\s>>"me=e oneline contains=podIndexAlternativeDelimOpen
143
144 " Restore this (otherwise B<> is shown as bold inside verbatim)
145 syn match podVerbatimLine "^\s.*$" contains=@NoSpell
146
147 " Ensure formatted text can be displayed in headings and items
148 syn clear podCmdText
149
150 if exists("perl_pod_spellcheck_headings")
151 syn match podCmdText ".*$" contained contains=podFormat,podBold,
152 \podBoldAlternativeDelim,podItalic,podItalicAlternativeDelim,
153 \podBoldOpen,podItalicOpen,podBoldAlternativeDelimOpen,
154 \podItalicAlternativeDelimOpen,podNoSpaceOpen
155 else
156 syn match podCmdText ".*$" contained contains=podFormat,podBold,
157 \podBoldAlternativeDelim,podItalic,podItalicAlternativeDelim,
158 \@NoSpell
159 endif
160
161 " Specify how to display these
162 hi def podBold term=bold cterm=bold gui=bold
163
164 hi link podBoldAlternativeDelim podBold
165 hi link podBoldAlternativeDelimOpen podBold
166 hi link podBoldOpen podBold
167
168 hi link podNoSpace Identifier
169 hi link podNoSpaceAlternativeDelim Identifier
170
171 hi link podIndex Identifier
172 hi link podIndexAlternativeDelim Identifier
173
174 hi def podItalic term=italic cterm=italic gui=italic
175
176 hi link podItalicAlternativeDelim podItalic
177 hi link podItalicAlternativeDelimOpen podItalic
178 hi link podItalicOpen podItalic
179
180 hi def podBoldItalic term=italic,bold cterm=italic,bold gui=italic,bold
181 hi def podItalicBold term=italic,bold cterm=italic,bold gui=italic,bold
182endif
183
Bram Moolenaar071d4272004-06-13 20:20:40 +0000184let b:current_syntax = "pod"
185
Bram Moolenaar543b7ef2013-06-01 14:50:56 +0200186let &cpo = s:cpo_save
187unlet s:cpo_save
188
Bram Moolenaar071d4272004-06-13 20:20:40 +0000189" vim: ts=8