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