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" quit when a syntax file was already loaded 23if exists("b:current_syntax") 24 finish 25endif 26 27let s:cpo_save = &cpo 28set cpo&vim 29 30" POD commands 31syn match podCommand "^=encoding" nextgroup=podCmdText contains=@NoSpell 32syn 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 41 42" Text of a =head1, =head2 or =item command 43syn match podCmdText ".*$" contained contains=podFormat,@NoSpell 44 45" Indent amount of =over command 46syn match podOverIndent "\d\+" contained contains=@NoSpell 47 48" Formatter identifier keyword for =for, =begin and =end commands 49syn match podForKeywd "\S\+" contained contains=@NoSpell 50 51" An indented line, to be displayed verbatim 52syn match podVerbatimLine "^\s.*$" contains=@NoSpell 53 54" Inline textual items handled specially by POD 55syn match podSpecial "\(\<\|&\)\I\i*\(::\I\i*\)*([^)]*)" contains=@NoSpell 56syn match podSpecial "[$@%]\I\i*\(::\I\i*\)*\>" contains=@NoSpell 57 58" Special formatting sequences 59syn region podFormat start="[IBSCLFX]<[^<]"me=e-1 end=">" oneline contains=podFormat,@NoSpell 60syn region podFormat start="[IBSCLFX]<<\s" end="\s>>" oneline contains=podFormat,@NoSpell 61syn match podFormat "Z<>" 62syn 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 65 66" Define the default highlighting. 67" Only when an item doesn't have highlighting yet 68 69hi def link podCommand Statement 70hi def link podCmdText String 71hi def link podOverIndent Number 72hi 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 78 79 80if exists("perl_pod_spellcheck_headings") 81 " Spell-check headings 82 syn clear podCmdText 83 syn match podCmdText ".*$" contained contains=podFormat 84endif 85 86if exists("perl_pod_formatting") 87 " By default, escapes like C<> are not checked for spelling. Remove B<> 88 " and I<> from the list of escapes. 89 syn clear podFormat 90 syn region podFormat start="[CLF]<[^<]"me=e-1 end=">" oneline contains=podFormat,@NoSpell 91 syn region podFormat start="[CLF]<<\s" end="\s>>" oneline contains=podFormat,@NoSpell 92 93 " Don't spell-check inside E<>, but ensure that the E< itself isn't 94 " marked as a spelling mistake. 95 syn match podFormat "E<\(\d\+\|\I\i*\)>" contains=podEscape,podEscape2,@NoSpell 96 97 " Z<> is a mock formatting code. Ensure Z<> on its own isn't marked as a 98 " spelling mistake. 99 syn match podFormat "Z<>" contains=podEscape,podEscape2,@NoSpell 100 101 " These are required so that whatever is *within* B<...>, I<...>, etc. is 102 " spell-checked, but not the B, I, ... itself. 103 syn match podBoldOpen "B<" contains=@NoSpell 104 syn match podItalicOpen "I<" contains=@NoSpell 105 syn match podNoSpaceOpen "S<" contains=@NoSpell 106 syn match podIndexOpen "X<" contains=@NoSpell 107 108 " Same as above but for the << >> syntax. 109 syn match podBoldAlternativeDelimOpen "B<< " contains=@NoSpell 110 syn match podItalicAlternativeDelimOpen "I<< " contains=@NoSpell 111 syn match podNoSpaceAlternativeDelimOpen "S<< " contains=@NoSpell 112 syn match podIndexAlternativeDelimOpen "X<< " contains=@NoSpell 113 114 " Add support for spell checking text inside B<>, I<>, S<> and X<>. 115 syn region podBold start="B<[^<]"me=e end=">" oneline contains=podBoldItalic,podBoldOpen 116 syn region podBoldAlternativeDelim start="B<<\s" end="\s>>" oneline contains=podBoldAlternativeDelimOpen 117 118 syn region podItalic start="I<[^<]"me=e end=">" oneline contains=podItalicBold,podItalicOpen 119 syn region podItalicAlternativeDelim start="I<<\s" end="\s>>" oneline contains=podItalicAlternativeDelimOpen 120 121 " Nested bold/italic and vice-versa 122 syn region podBoldItalic contained start="I<[^<]"me=e end=">" oneline 123 syn region podItalicBold contained start="B<[^<]"me=e end=">" oneline 124 125 syn region podNoSpace start="S<[^<]"ms=s-2 end=">"me=e oneline contains=podNoSpaceOpen 126 syn region podNoSpaceAlternativeDelim start="S<<\s"ms=s-2 end="\s>>"me=e oneline contains=podNoSpaceAlternativeDelimOpen 127 128 syn region podIndex start="X<[^<]"ms=s-2 end=">"me=e oneline contains=podIndexOpen 129 syn region podIndexAlternativeDelim start="X<<\s"ms=s-2 end="\s>>"me=e oneline contains=podIndexAlternativeDelimOpen 130 131 " Restore this (otherwise B<> is shown as bold inside verbatim) 132 syn match podVerbatimLine "^\s.*$" contains=@NoSpell 133 134 " Ensure formatted text can be displayed in headings and items 135 syn clear podCmdText 136 137 if exists("perl_pod_spellcheck_headings") 138 syn match podCmdText ".*$" contained contains=podFormat,podBold, 139 \podBoldAlternativeDelim,podItalic,podItalicAlternativeDelim, 140 \podBoldOpen,podItalicOpen,podBoldAlternativeDelimOpen, 141 \podItalicAlternativeDelimOpen,podNoSpaceOpen 142 else 143 syn match podCmdText ".*$" contained contains=podFormat,podBold, 144 \podBoldAlternativeDelim,podItalic,podItalicAlternativeDelim, 145 \@NoSpell 146 endif 147 148 " Specify how to display these 149 hi def podBold term=bold cterm=bold gui=bold 150 151 hi link podBoldAlternativeDelim podBold 152 hi link podBoldAlternativeDelimOpen podBold 153 hi link podBoldOpen podBold 154 155 hi link podNoSpace Identifier 156 hi link podNoSpaceAlternativeDelim Identifier 157 158 hi link podIndex Identifier 159 hi link podIndexAlternativeDelim Identifier 160 161 hi def podItalic term=italic cterm=italic gui=italic 162 163 hi link podItalicAlternativeDelim podItalic 164 hi link podItalicAlternativeDelimOpen podItalic 165 hi link podItalicOpen podItalic 166 167 hi def podBoldItalic term=italic,bold cterm=italic,bold gui=italic,bold 168 hi def podItalicBold term=italic,bold cterm=italic,bold gui=italic,bold 169endif 170 171let b:current_syntax = "pod" 172 173let &cpo = s:cpo_save 174unlet s:cpo_save 175 176" vim: ts=8 177