Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 1 | " Vim syntax file |
| 2 | " Language: Perl POD format |
Bram Moolenaar | 3fdfa4a | 2004-10-07 21:02:47 +0000 | [diff] [blame] | 3 | " Maintainer: Scott Bigham <dsb@killerbunnies.org> |
Bram Moolenaar | 97409f1 | 2005-07-08 22:17:29 +0000 | [diff] [blame] | 4 | " Last Change: 2005 Jul 05 |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 5 | |
| 6 | " To add embedded POD documentation highlighting to your syntax file, add |
| 7 | " the commands: |
| 8 | " |
| 9 | " syn include @Pod <sfile>:p:h/pod.vim |
| 10 | " syn region myPOD start="^=pod" start="^=head" end="^=cut" keepend contained contains=@Pod |
| 11 | " |
| 12 | " and add myPod to the contains= list of some existing region, probably a |
| 13 | " comment. The "keepend" flag is needed because "=cut" is matched as a |
| 14 | " pattern in its own right. |
| 15 | |
| 16 | |
| 17 | " Remove any old syntax stuff hanging around (this is suppressed |
| 18 | " automatically by ":syn include" if necessary). |
| 19 | " For version 5.x: Clear all syntax items |
| 20 | " For version 6.x: Quit when a syntax file was already loaded |
| 21 | if version < 600 |
| 22 | syntax clear |
| 23 | elseif exists("b:current_syntax") |
| 24 | finish |
| 25 | endif |
| 26 | |
| 27 | " POD commands |
Bram Moolenaar | 97409f1 | 2005-07-08 22:17:29 +0000 | [diff] [blame] | 28 | syn match podCommand "^=head[1234]" nextgroup=podCmdText contains=@NoSpell |
| 29 | syn match podCommand "^=item" nextgroup=podCmdText contains=@NoSpell |
| 30 | syn match podCommand "^=over" nextgroup=podOverIndent skipwhite contains=@NoSpell |
| 31 | syn match podCommand "^=back" contains=@NoSpell |
| 32 | syn match podCommand "^=cut" contains=@NoSpell |
| 33 | syn match podCommand "^=pod" contains=@NoSpell |
| 34 | syn match podCommand "^=for" nextgroup=podForKeywd skipwhite contains=@NoSpell |
| 35 | syn match podCommand "^=begin" nextgroup=podForKeywd skipwhite contains=@NoSpell |
| 36 | syn match podCommand "^=end" nextgroup=podForKeywd skipwhite contains=@NoSpell |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 37 | |
| 38 | " Text of a =head1, =head2 or =item command |
Bram Moolenaar | 97409f1 | 2005-07-08 22:17:29 +0000 | [diff] [blame] | 39 | syn match podCmdText ".*$" contained contains=podFormat,@NoSpell |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 40 | |
| 41 | " Indent amount of =over command |
Bram Moolenaar | 97409f1 | 2005-07-08 22:17:29 +0000 | [diff] [blame] | 42 | syn match podOverIndent "\d\+" contained contains=@NoSpell |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 43 | |
| 44 | " Formatter identifier keyword for =for, =begin and =end commands |
Bram Moolenaar | 97409f1 | 2005-07-08 22:17:29 +0000 | [diff] [blame] | 45 | syn match podForKeywd "\S\+" contained contains=@NoSpell |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 46 | |
| 47 | " An indented line, to be displayed verbatim |
Bram Moolenaar | 97409f1 | 2005-07-08 22:17:29 +0000 | [diff] [blame] | 48 | syn match podVerbatimLine "^\s.*$" contains=@NoSpell |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 49 | |
| 50 | " Inline textual items handled specially by POD |
Bram Moolenaar | 97409f1 | 2005-07-08 22:17:29 +0000 | [diff] [blame] | 51 | syn match podSpecial "\(\<\|&\)\I\i*\(::\I\i*\)*([^)]*)" contains=@NoSpell |
| 52 | syn match podSpecial "[$@%]\I\i*\(::\I\i*\)*\>" contains=@NoSpell |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 53 | |
| 54 | " Special formatting sequences |
Bram Moolenaar | 97409f1 | 2005-07-08 22:17:29 +0000 | [diff] [blame] | 55 | syn region podFormat start="[IBSCLFX]<[^<]"me=e-1 end=">" oneline contains=podFormat,@NoSpell |
Bram Moolenaar | 3fdfa4a | 2004-10-07 21:02:47 +0000 | [diff] [blame] | 56 | syn match podFormat "Z<>" |
Bram Moolenaar | 97409f1 | 2005-07-08 22:17:29 +0000 | [diff] [blame] | 57 | syn match podFormat "E<\(\d\+\|\I\i*\)>" contains=podEscape,podEscape2,@NoSpell |
| 58 | syn match podEscape "\I\i*>"me=e-1 contained contains=@NoSpell |
| 59 | syn match podEscape2 "\d\+>"me=e-1 contained contains=@NoSpell |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 60 | |
| 61 | " Define the default highlighting. |
| 62 | " For version 5.7 and earlier: only when not done already |
| 63 | " For version 5.8 and later: only when an item doesn't have highlighting yet |
| 64 | if version >= 508 || !exists("did_pod_syntax_inits") |
| 65 | if version < 508 |
| 66 | let did_pod_syntax_inits = 1 |
| 67 | command -nargs=+ HiLink hi link <args> |
| 68 | else |
| 69 | command -nargs=+ HiLink hi def link <args> |
| 70 | endif |
| 71 | |
| 72 | HiLink podCommand Statement |
| 73 | HiLink podCmdText String |
| 74 | HiLink podOverIndent Number |
| 75 | HiLink podForKeywd Identifier |
| 76 | HiLink podFormat Identifier |
| 77 | HiLink podVerbatimLine PreProc |
| 78 | HiLink podSpecial Identifier |
Bram Moolenaar | 3fdfa4a | 2004-10-07 21:02:47 +0000 | [diff] [blame] | 79 | HiLink podEscape String |
| 80 | HiLink podEscape2 Number |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 81 | |
| 82 | delcommand HiLink |
| 83 | endif |
| 84 | |
| 85 | let b:current_syntax = "pod" |
| 86 | |
| 87 | " vim: ts=8 |