robin/laufey
git clone https://git.robinwobin.dev/robin/laufey
db210dd2a4
master
1" Vim syntax file 2" Language: Perl POD format 3" Maintainer: vim-perl <vim-perl@googlegroups.com> (need to be subscribed to post) 4" Previously: Scott Bigham <dsb@killerbunnies.org> 5" Homepage: https://github.com/vim-perl/vim-perl 6" Bugs/requests: https://github.com/vim-perl/vim-perl/issues 7" License: Vim License (see :help license) 8" Last Change: 2022 Jun 13 9 10" To add embedded POD documentation highlighting to your syntax file, add 11" the commands: 12" 13" syn include @Pod <sfile>:p:h/pod.vim 14" syn region myPOD start="^=pod" start="^=head" end="^=cut" keepend contained contains=@Pod 15" 16" and add myPod to the contains= list of some existing region, probably a 17" comment. The "keepend" flag is needed because "=cut" is matched as a 18" pattern in its own right. 19 20 21" Remove any old syntax stuff hanging around (this is suppressed 22" automatically by ":syn include" if necessary). 23" quit when a syntax file was already loaded 24if exists ( "b:current_syntax" ) 25finish 26endif 27 28let s: cpo_save = & cpo 29set cpo & vim 30 31" TODO: add supported encodings when we can utilize better performing Vim 8 features 32syn match podEncoding "[ 0-9A-Za-z_- ] \+ "contained contains = @NoSpell 33 34" Text of a =head1, =head2 or =item command 35syn region podCmdText start = "\S. * $ "end = "^\ze\s * $ "end = "^\ze=cut\> "contained contains = podFormat , @NoSpell 36 37" Indent amount of =over command 38syn match podOverIndent "\d * \.\=\d\+\> "contained contains = @NoSpell 39 40" Formatter identifier keyword for =for, =begin and =end commands 41syn match podForKeywd "\S\+ "contained contains = @NoSpell 42 43" An indented line, to be displayed verbatim 44syn region podVerbatim start = "^\s\+\S. * $ "end = "^\ze\s * $ "end = "^\ze=cut\> "contains = @NoSpell 45 46syn region podOrdinary start = "^\S. * $ "end = "^\ze\s * $ "end = "^\ze=cut\> "contains = podFormat , podSpecial , @Spell 47 48" Inline textual items handled specially by POD 49syn match podSpecial "\(\<\|&\)\I\i * \(::\I\i * \) * ( [ ^) ] * ) "contains = @NoSpell 50syn match podSpecial "[ $@% ] \I\i * \(::\I\i * \) * \> "contains = @NoSpell 51 52" Special formatting sequences 53 54syn cluster podFormat contains = podFormat , podFormatError 55 56syn match podFormatError "[ ADGHJKM-RT-WY ] < " 57 58syn region podFormat matchgroup = podFormatDelimiter start = "[ IBSCLFX ] < "end = "> "contains = @podFormat , @NoSpell 59syn region podFormat matchgroup = podFormatDelimiter start = "[ IBSCLFX ] <<\%(\s\+\|$\) "end = "\%(\s\+\|^\)>> "contains = @podFormat , @NoSpell 60 61syn match podFormat "Z<> " 62 63syn region podFormat matchgroup = podFormatDelimiter start = "E< "end = "> "oneline contains = podEscape , podEscape2 , @NoSpell 64 65" HTML entities {{{1 66" Source: Pod/Escapes.pm 67syn keyword podEscape contained lt gt quot amp apos sol verbar lchevron rchevron nbsp iexcl cent pound curren yen brvbar sect uml copy ordf laquo not shy reg macr deg plusmn sup2 sup3 acute micro para middot cedil sup1 ordm raquo frac14 frac12 frac34 iquest Agrave Aacute Acirc Atilde Auml Aring AElig Ccedil Egrave Eacute Ecirc Euml Igrave Iacute Icirc Iuml ETH Ntilde Ograve Oacute Ocirc Otilde Ouml times Oslash Ugrave Uacute Ucirc Uuml Yacute THORN szlig agrave aacute acirc atilde auml aring aelig ccedil egrave eacute ecirc euml igrave iacute icirc iuml eth ntilde ograve oacute ocirc otilde ouml divide oslash ugrave uacute ucirc uuml yacute thorn yuml fnof Alpha Beta Gamma Delta Epsilon Zeta Eta Theta Iota Kappa Lambda Mu Nu Xi Omicron Pi Rho Sigma Tau Upsilon Phi Chi Psi Omega alpha beta gamma delta epsilon zeta eta theta iota kappa lambda mu nu xi omicron pi rho sigmaf sigma tau upsilon phi chi psi omega thetasym upsih piv bull hellip prime Prime oline frasl weierp image real trade alefsym larr uarr rarr darr harr crarr lArr uArr rArr dArr hArr forall part exist empty nabla isin notin ni prod sum minus lowast radic prop infin ang and or cap cup int there4 sim cong asymp ne equiv le ge sub sup nsub sube supe oplus otimes perp sdot lceil rceil lfloor rfloor lang rang loz spades clubs hearts diams OElig oelig Scaron scaron Yuml circ tilde ensp emsp thinsp zwnj zwj lrm rlm ndash mdash lsquo rsquo sbquo ldquo rdquo bdquo dagger Dagger permil lsaquo rsaquo 68" }}} 69 70syn match podEscape2 "\d\+ "contained contains = @NoSpell 71syn match podEscape2 "0\=x\x\+ "contained contains = @NoSpell 72syn match podEscape2 "0\o\+ "contained contains = @NoSpell 73 74 75" POD commands 76syn match podCommand "^=encoding\> "nextgroup = podEncoding skipwhite contains = @NoSpell 77syn match podCommand "^=head [ 1234 ] \> "nextgroup = podCmdText skipwhite skipnl contains = @NoSpell 78syn match podCommand "^=item\> "nextgroup = podCmdText skipwhite skipnl contains = @NoSpell 79syn match podCommand "^=over\> "nextgroup = podOverIndent skipwhite contains = @NoSpell 80syn match podCommand "^=back "contains = @NoSpell 81syn match podCommand "^=cut "contains = @NoSpell 82syn match podCommand "^=pod "contains = @NoSpell 83syn match podCommand "^=for "nextgroup = podForKeywd skipwhite contains = @NoSpell 84syn match podCommand "^=begin "nextgroup = podForKeywd skipwhite contains = @NoSpell 85syn match podCommand "^=end "nextgroup = podForKeywd skipwhite contains = @NoSpell 86 87" Comments 88 89syn keyword podForKeywd comment contained nextgroup = podForComment skipwhite skipnl 90 91if exists ( "perl_pod_no_comment_fold" ) 92syn region podBeginComment start = "^=begin\s\+comment\s * $ "end = "^=end\s\+comment\ze\s * $ "keepend extend contains = podCommand 93syn region podForComment start = "\S. * $ "end = "^\ze\s * $ "end = "^\ze=cut\> "contained contains = @Spell , podTodo 94else 95syn region podBeginComment start = "^=begin\s\+comment\s * $ "end = "^=end\s\+comment\ze\s * $ "keepend extend contains = podCommand , podTodo fold 96syn region podForComment start = "\S. * $ "end = "^\ze\s * $ "end = "^\ze=cut\> "contained contains = @Spell , podTodo fold 97endif 98 99syn keyword podTodo contained TODO FIXME XXX 100 101" Plain Pod files 102syn region podNonPod start = "\%^\%(=\w\+\>\)\@! "end = "^\ze=\a\w * \> " 103syn region podNonPod matchgroup = podCommand start = "^=cut\> "end = "\%$ " 104syn region podNonPod matchgroup = podCommand start = "^=cut\> "end = "^\ze=\a\w * \> " 105 106" Define the default highlighting. 107" Only when an item doesn't have highlighting yet 108 109hi def link podCommand Statement 110hi def link podBeginComment Comment 111hi def link podForComment Comment 112hi def link podNonPod Comment 113hi def link podTodo Todo 114hi def link podCmdText String 115hi def link podEncoding Constant 116hi def link podOverIndent Number 117hi def link podForKeywd Identifier 118hi def link podVerbatim PreProc 119hi def link podFormat Identifier 120hi def link podFormatDelimiter podFormat 121hi def link podFormatError Error 122hi def link podSpecial Identifier 123hi def link podEscape Constant 124hi def link podEscape2 Number 125 126if exists ( "perl_pod_spellcheck_headings" ) 127" Spell-check headings 128syn clear podCmdText 129syn region podCmdText start = "\S. * $ "end = "^\s * $ "end = "^\ze=cut\> "contained contains = podFormat 130endif 131 132if exists ( "perl_pod_formatting" ) 133" By default, escapes like C<> are not checked for spelling. Remove B<> 134" and I<> from the list of escapes. 135syn clear podFormat 136syn region podFormat start = "[ CLF ] < [ ^< ] "me= e-1end = "> "contains = @podFormat , @NoSpell 137syn region podFormat start = "[ CLF ] <<\%(\s\+\|$\) "end = "\%(\s\+\|^\)>> "contains = @podFormat , @NoSpell 138 139" Don't spell-check inside E<>, but ensure that the E< itself isn't 140" marked as a spelling mistake. 141syn region podFormat start = "E< "end = "> "oneline contains = podEscape , podEscape2 , @NoSpell 142 143" Z<> is a mock formatting code. Ensure Z<> on its own isn't marked as a 144" spelling mistake. 145syn match podFormat "Z<> "contains = podEscape , podEscape2 , @NoSpell 146 147" These are required so that whatever is *within* B<...>, I<...>, etc. is 148" spell-checked, but not the B, I, ... itself. 149syn match podBoldOpen "B< "contains = @NoSpell 150syn match podItalicOpen "I< "contains = @NoSpell 151syn match podNoSpaceOpen "S< "contains = @NoSpell 152syn match podIndexOpen "X< "contains = @NoSpell 153 154" Same as above but for the << >> syntax. 155syn match podBoldAlternativeDelimOpen "B<<\%(\s\+\|$\) "contains = @NoSpell 156syn match podItalicAlternativeDelimOpen "I<<\%(\s\+\|$\) "contains = @NoSpell 157syn match podNoSpaceAlternativeDelimOpen "S<<\%(\s\+\|$\) "contains = @NoSpell 158syn match podIndexAlternativeDelimOpen "X<<\%(\s\+\|$\) "contains = @NoSpell 159 160" Add support for spell checking text inside B<>, I<>, S<> and X<>. 161syn region podBold start = "B< [ ^< ] "me= eend = "> "contains = podBoldItalic , podBoldOpen 162syn region podBoldAlternativeDelim start = "B<<\%(\s\+\|$\) "end = "\%(\s\+\|^\)>> "contains = podBoldAlternativeDelimOpen 163 164syn region podItalic start = "I< [ ^< ] "me= eend = "> "contains = podItalicBold , podItalicOpen 165syn region podItalicAlternativeDelim start = "I<<\%(\s\+\|$\) "end = "\%(\s\+\|^\)>> "contains = podItalicAlternativeDelimOpen 166 167" Nested bold/italic and vice-versa 168syn region podBoldItalic contained start = "I< [ ^< ] "me= eend = "> " 169syn region podItalicBold contained start = "B< [ ^< ] "me= eend = "> " 170 171syn region podNoSpace start = "S< [ ^< ] "ms= s-2end = "> "me= econtains = podNoSpaceOpen 172syn region podNoSpaceAlternativeDelim start = "S<<\%(\s\+\|$\) "ms= s-2end = "\%(\s\+\|^\)>> "me= econtains = podNoSpaceAlternativeDelimOpen 173 174syn region podIndex start = "X< [ ^< ] "ms= s-2end = "> "me= econtains = podIndexOpen 175syn region podIndexAlternativeDelim start = "X<<\%(\s\+\|$\) "ms= s-2end = "\%(\s\+\|^\)>> "me= econtains = podIndexAlternativeDelimOpen 176 177" Restore this (otherwise B<> is shown as bold inside verbatim) 178syn region podVerbatim start = "^\s\+\S. * $ "end = "^\ze\s * $ "end = "^\ze=cut\> "contains = @NoSpell 179 180" Ensure formatted text can be displayed in headings and items 181syn clear podCmdText 182 183if exists ( "perl_pod_spellcheck_headings" ) 184syn match podCmdText ". * $ "contained contains = @podFormat , podBold , 185 \podBoldAlternativeDelim , podItalic , podItalicAlternativeDelim , 186 \podBoldOpen , podItalicOpen , podBoldAlternativeDelimOpen , 187 \podItalicAlternativeDelimOpen , podNoSpaceOpen 188else 189syn match podCmdText ". * $ "contained contains = @podFormat , podBold , 190 \podBoldAlternativeDelim , podItalic , podItalicAlternativeDelim , 191 \@NoSpell 192endif 193 194" Specify how to display these 195hi def podBold term = bold cterm = bold gui = bold 196 197hi link podBoldAlternativeDelim podBold 198hi link podBoldAlternativeDelimOpen podBold 199hi link podBoldOpen podBold 200 201hi link podNoSpace Identifier 202hi link podNoSpaceAlternativeDelim Identifier 203 204hi link podIndex Identifier 205hi link podIndexAlternativeDelim Identifier 206 207hi def podItalic term = italic cterm = italic gui = italic 208 209hi link podItalicAlternativeDelim podItalic 210hi link podItalicAlternativeDelimOpen podItalic 211hi link podItalicOpen podItalic 212 213hi def podBoldItalic term = italic , boldcterm = italic , boldgui = italic , bold 214hi def podItalicBold term = italic , boldcterm = italic , boldgui = italic , bold 215endif 216 217let b: current_syntax = "pod" 218 219let & cpo = s: cpo_save 220unlet s: cpo_save 221 222" vim: ts=8 fdm=marker: