blob: 604713260be4c2363a8c8de69a08f621ad27e69c [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 Moolenaar37c64c72017-09-19 22:06:03 +02007" Last Change: 2017-09-12
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).
Bram Moolenaar89bcfda2016-08-30 23:26:57 +020022" quit when a syntax file was already loaded
23if exists("b:current_syntax")
Bram Moolenaar071d4272004-06-13 20:20:40 +000024 finish
25endif
26
Bram Moolenaar543b7ef2013-06-01 14:50:56 +020027let s:cpo_save = &cpo
28set cpo&vim
29
Bram Moolenaar071d4272004-06-13 20:20:40 +000030" POD commands
Bram Moolenaar543b7ef2013-06-01 14:50:56 +020031syn match podCommand "^=encoding" nextgroup=podCmdText contains=@NoSpell
Bram Moolenaarede981a2010-08-11 23:37:32 +020032syn match podCommand "^=head[1234]" nextgroup=podCmdText contains=@NoSpell
33syn match podCommand "^=item" nextgroup=podCmdText contains=@NoSpell
34syn match podCommand "^=over" nextgroup=podOverIndent skipwhite contains=@NoSpell
35syn match podCommand "^=back" contains=@NoSpell
36syn match podCommand "^=cut" contains=@NoSpell
37syn match podCommand "^=pod" contains=@NoSpell
38syn match podCommand "^=for" nextgroup=podForKeywd skipwhite contains=@NoSpell
39syn match podCommand "^=begin" nextgroup=podForKeywd skipwhite contains=@NoSpell
40syn match podCommand "^=end" nextgroup=podForKeywd skipwhite contains=@NoSpell
Bram Moolenaar071d4272004-06-13 20:20:40 +000041
42" Text of a =head1, =head2 or =item command
Bram Moolenaar97409f12005-07-08 22:17:29 +000043syn match podCmdText ".*$" contained contains=podFormat,@NoSpell
Bram Moolenaar071d4272004-06-13 20:20:40 +000044
45" Indent amount of =over command
Bram Moolenaar97409f12005-07-08 22:17:29 +000046syn match podOverIndent "\d\+" contained contains=@NoSpell
Bram Moolenaar071d4272004-06-13 20:20:40 +000047
48" Formatter identifier keyword for =for, =begin and =end commands
Bram Moolenaar97409f12005-07-08 22:17:29 +000049syn match podForKeywd "\S\+" contained contains=@NoSpell
Bram Moolenaar071d4272004-06-13 20:20:40 +000050
51" An indented line, to be displayed verbatim
Bram Moolenaar97409f12005-07-08 22:17:29 +000052syn match podVerbatimLine "^\s.*$" contains=@NoSpell
Bram Moolenaar071d4272004-06-13 20:20:40 +000053
54" Inline textual items handled specially by POD
Bram Moolenaar97409f12005-07-08 22:17:29 +000055syn match podSpecial "\(\<\|&\)\I\i*\(::\I\i*\)*([^)]*)" contains=@NoSpell
56syn match podSpecial "[$@%]\I\i*\(::\I\i*\)*\>" contains=@NoSpell
Bram Moolenaar071d4272004-06-13 20:20:40 +000057
58" Special formatting sequences
Bram Moolenaar97409f12005-07-08 22:17:29 +000059syn region podFormat start="[IBSCLFX]<[^<]"me=e-1 end=">" oneline contains=podFormat,@NoSpell
Bram Moolenaarc81e5e72007-05-05 18:24:42 +000060syn region podFormat start="[IBSCLFX]<<\s" end="\s>>" oneline contains=podFormat,@NoSpell
Bram Moolenaar3fdfa4a2004-10-07 21:02:47 +000061syn match podFormat "Z<>"
Bram Moolenaar97409f12005-07-08 22:17:29 +000062syn match podFormat "E<\(\d\+\|\I\i*\)>" contains=podEscape,podEscape2,@NoSpell
63syn match podEscape "\I\i*>"me=e-1 contained contains=@NoSpell
64syn match podEscape2 "\d\+>"me=e-1 contained contains=@NoSpell
Bram Moolenaar071d4272004-06-13 20:20:40 +000065
66" Define the default highlighting.
Bram Moolenaar89bcfda2016-08-30 23:26:57 +020067" Only when an item doesn't have highlighting yet
Bram Moolenaar071d4272004-06-13 20:20:40 +000068
Bram Moolenaarf37506f2016-08-31 22:22:10 +020069hi def link podCommand Statement
70hi def link podCmdText String
Bram Moolenaar37c64c72017-09-19 22:06:03 +020071hi def link podOverIndent Number
Bram Moolenaarf37506f2016-08-31 22:22:10 +020072hi def link podForKeywd Identifier
73hi def link podFormat Identifier
74hi def link podVerbatimLine PreProc
75hi def link podSpecial Identifier
76hi def link podEscape String
77hi def link podEscape2 Number
Bram Moolenaar071d4272004-06-13 20:20:40 +000078
Bram Moolenaar543b7ef2013-06-01 14:50:56 +020079if exists("perl_pod_spellcheck_headings")
80 " Spell-check headings
81 syn clear podCmdText
82 syn match podCmdText ".*$" contained contains=podFormat
83endif
84
85if exists("perl_pod_formatting")
86 " By default, escapes like C<> are not checked for spelling. Remove B<>
87 " and I<> from the list of escapes.
88 syn clear podFormat
89 syn region podFormat start="[CLF]<[^<]"me=e-1 end=">" oneline contains=podFormat,@NoSpell
90 syn region podFormat start="[CLF]<<\s" end="\s>>" oneline contains=podFormat,@NoSpell
91
92 " Don't spell-check inside E<>, but ensure that the E< itself isn't
93 " marked as a spelling mistake.
94 syn match podFormat "E<\(\d\+\|\I\i*\)>" contains=podEscape,podEscape2,@NoSpell
95
96 " Z<> is a mock formatting code. Ensure Z<> on its own isn't marked as a
97 " spelling mistake.
98 syn match podFormat "Z<>" contains=podEscape,podEscape2,@NoSpell
99
100 " These are required so that whatever is *within* B<...>, I<...>, etc. is
101 " spell-checked, but not the B, I, ... itself.
102 syn match podBoldOpen "B<" contains=@NoSpell
103 syn match podItalicOpen "I<" contains=@NoSpell
104 syn match podNoSpaceOpen "S<" contains=@NoSpell
105 syn match podIndexOpen "X<" contains=@NoSpell
106
107 " Same as above but for the << >> syntax.
108 syn match podBoldAlternativeDelimOpen "B<< " contains=@NoSpell
109 syn match podItalicAlternativeDelimOpen "I<< " contains=@NoSpell
110 syn match podNoSpaceAlternativeDelimOpen "S<< " contains=@NoSpell
111 syn match podIndexAlternativeDelimOpen "X<< " contains=@NoSpell
112
113 " Add support for spell checking text inside B<>, I<>, S<> and X<>.
114 syn region podBold start="B<[^<]"me=e end=">" oneline contains=podBoldItalic,podBoldOpen
115 syn region podBoldAlternativeDelim start="B<<\s" end="\s>>" oneline contains=podBoldAlternativeDelimOpen
116
117 syn region podItalic start="I<[^<]"me=e end=">" oneline contains=podItalicBold,podItalicOpen
118 syn region podItalicAlternativeDelim start="I<<\s" end="\s>>" oneline contains=podItalicAlternativeDelimOpen
119
120 " Nested bold/italic and vice-versa
121 syn region podBoldItalic contained start="I<[^<]"me=e end=">" oneline
122 syn region podItalicBold contained start="B<[^<]"me=e end=">" oneline
123
124 syn region podNoSpace start="S<[^<]"ms=s-2 end=">"me=e oneline contains=podNoSpaceOpen
125 syn region podNoSpaceAlternativeDelim start="S<<\s"ms=s-2 end="\s>>"me=e oneline contains=podNoSpaceAlternativeDelimOpen
126
127 syn region podIndex start="X<[^<]"ms=s-2 end=">"me=e oneline contains=podIndexOpen
128 syn region podIndexAlternativeDelim start="X<<\s"ms=s-2 end="\s>>"me=e oneline contains=podIndexAlternativeDelimOpen
129
130 " Restore this (otherwise B<> is shown as bold inside verbatim)
131 syn match podVerbatimLine "^\s.*$" contains=@NoSpell
132
133 " Ensure formatted text can be displayed in headings and items
134 syn clear podCmdText
135
136 if exists("perl_pod_spellcheck_headings")
137 syn match podCmdText ".*$" contained contains=podFormat,podBold,
138 \podBoldAlternativeDelim,podItalic,podItalicAlternativeDelim,
139 \podBoldOpen,podItalicOpen,podBoldAlternativeDelimOpen,
140 \podItalicAlternativeDelimOpen,podNoSpaceOpen
141 else
142 syn match podCmdText ".*$" contained contains=podFormat,podBold,
143 \podBoldAlternativeDelim,podItalic,podItalicAlternativeDelim,
144 \@NoSpell
145 endif
146
147 " Specify how to display these
148 hi def podBold term=bold cterm=bold gui=bold
149
150 hi link podBoldAlternativeDelim podBold
151 hi link podBoldAlternativeDelimOpen podBold
152 hi link podBoldOpen podBold
153
154 hi link podNoSpace Identifier
155 hi link podNoSpaceAlternativeDelim Identifier
156
157 hi link podIndex Identifier
158 hi link podIndexAlternativeDelim Identifier
159
160 hi def podItalic term=italic cterm=italic gui=italic
161
162 hi link podItalicAlternativeDelim podItalic
163 hi link podItalicAlternativeDelimOpen podItalic
164 hi link podItalicOpen podItalic
165
166 hi def podBoldItalic term=italic,bold cterm=italic,bold gui=italic,bold
167 hi def podItalicBold term=italic,bold cterm=italic,bold gui=italic,bold
168endif
169
Bram Moolenaar071d4272004-06-13 20:20:40 +0000170let b:current_syntax = "pod"
171
Bram Moolenaar543b7ef2013-06-01 14:50:56 +0200172let &cpo = s:cpo_save
173unlet s:cpo_save
174
Bram Moolenaar071d4272004-06-13 20:20:40 +0000175" vim: ts=8