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