1" Vim syntax file 2" Language: Perl POD format 3" Maintainer: vim-perl <[email protected]> 4" Previously: Scott Bigham <[email protected]> 5" Homepage: http://github.com/vim-perl/vim-perl 6" Bugs/requests: http://github.com/vim-perl/vim-perl/issues 7" Last Change: 2013-07-21 8 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 30let s:cpo_save = &cpo 31set cpo&vim 32 33" POD commands 34syn match podCommand "^=encoding" nextgroup=podCmdText contains=@NoSpell 35syn 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 44 45" Text of a =head1, =head2 or =item command 46syn match podCmdText ".*$" contained contains=podFormat,@NoSpell 47 48" Indent amount of =over command 49syn match podOverIndent "\d\+" contained contains=@NoSpell 50 51" Formatter identifier keyword for =for, =begin and =end commands 52syn match podForKeywd "\S\+" contained contains=@NoSpell 53 54" An indented line, to be displayed verbatim 55syn match podVerbatimLine "^\s.*$" contains=@NoSpell 56 57" Inline textual items handled specially by POD 58syn match podSpecial "\(\<\|&\)\I\i*\(::\I\i*\)*([^)]*)" contains=@NoSpell 59syn match podSpecial "[$@%]\I\i*\(::\I\i*\)*\>" contains=@NoSpell 60 61" Special formatting sequences 62syn region podFormat start="[IBSCLFX]<[^<]"me=e-1 end=">" oneline contains=podFormat,@NoSpell 63syn region podFormat start="[IBSCLFX]<<\s" end="\s>>" oneline contains=podFormat,@NoSpell 64syn match podFormat "Z<>" 65syn 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 68 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 87 HiLink podEscape String 88 HiLink podEscape2 Number 89 90 delcommand HiLink 91endif 92 93if 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 184let b:current_syntax = "pod" 185 186let &cpo = s:cpo_save 187unlet s:cpo_save 188 189" vim: ts=8 190