neovim

Neovim text editor
git clone https://git.dasho.dev/neovim.git
Log | Files | Refs | README

pod.vim (10887B)


      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
     24 if exists("b:current_syntax")
     25  finish
     26 endif
     27 
     28 let s:cpo_save = &cpo
     29 set cpo&vim
     30 
     31 " TODO: add supported encodings when we can utilize better performing Vim 8 features
     32 syn match podEncoding	"[0-9A-Za-z_-]\+" contained contains=@NoSpell
     33 
     34 " Text of a =head1, =head2 or =item command
     35 syn region podCmdText	start="\S.*$" end="^\ze\s*$" end="^\ze=cut\>" contained contains=podFormat,@NoSpell
     36 
     37 " Indent amount of =over command
     38 syn match podOverIndent	"\d*\.\=\d\+\>" contained contains=@NoSpell
     39 
     40 " Formatter identifier keyword for =for, =begin and =end commands
     41 syn match podForKeywd	"\S\+" contained contains=@NoSpell
     42 
     43 " An indented line, to be displayed verbatim
     44 syn region podVerbatim	start="^\s\+\S.*$" end="^\ze\s*$" end="^\ze=cut\>" contains=@NoSpell
     45 
     46 syn region podOrdinary	start="^\S.*$" end="^\ze\s*$" end="^\ze=cut\>" contains=podFormat,podSpecial,@Spell
     47 
     48 " Inline textual items handled specially by POD
     49 syn match podSpecial	"\(\<\|&\)\I\i*\(::\I\i*\)*([^)]*)" contains=@NoSpell
     50 syn match podSpecial	"[$@%]\I\i*\(::\I\i*\)*\>" contains=@NoSpell
     51 
     52 " Special formatting sequences
     53 
     54 syn cluster podFormat contains=podFormat,podFormatError
     55 
     56 syn match  podFormatError "[ADGHJKM-RT-WY]<"
     57 
     58 syn region podFormat	matchgroup=podFormatDelimiter start="[IBSCLFX]<"              end=">"              contains=@podFormat,@NoSpell
     59 syn region podFormat	matchgroup=podFormatDelimiter start="[IBSCLFX]<<\%(\s\+\|$\)" end="\%(\s\+\|^\)>>" contains=@podFormat,@NoSpell
     60 
     61 syn match  podFormat	"Z<>"
     62 
     63 syn region podFormat	matchgroup=podFormatDelimiter start="E<" end=">" oneline contains=podEscape,podEscape2,@NoSpell
     64 
     65 " HTML entities {{{1
     66 " Source: Pod/Escapes.pm
     67 syn 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 
     70 syn match  podEscape2	"\d\+"     contained contains=@NoSpell
     71 syn match  podEscape2	"0\=x\x\+" contained contains=@NoSpell
     72 syn match  podEscape2	"0\o\+"    contained contains=@NoSpell
     73 
     74 
     75 " POD commands
     76 syn match podCommand    "^=encoding\>"   nextgroup=podEncoding skipwhite contains=@NoSpell
     77 syn match podCommand    "^=head[1234]\>" nextgroup=podCmdText skipwhite skipnl contains=@NoSpell
     78 syn match podCommand    "^=item\>"       nextgroup=podCmdText skipwhite skipnl contains=@NoSpell
     79 syn match podCommand    "^=over\>"       nextgroup=podOverIndent skipwhite contains=@NoSpell
     80 syn match podCommand    "^=back"         contains=@NoSpell
     81 syn match podCommand    "^=cut"          contains=@NoSpell
     82 syn match podCommand    "^=pod"          contains=@NoSpell
     83 syn match podCommand    "^=for"          nextgroup=podForKeywd skipwhite contains=@NoSpell
     84 syn match podCommand    "^=begin"        nextgroup=podForKeywd skipwhite contains=@NoSpell
     85 syn match podCommand    "^=end"          nextgroup=podForKeywd skipwhite contains=@NoSpell
     86 
     87 " Comments
     88 
     89 syn keyword podForKeywd comment contained nextgroup=podForComment skipwhite skipnl
     90 
     91 if exists("perl_pod_no_comment_fold")
     92  syn region podBeginComment start="^=begin\s\+comment\s*$" end="^=end\s\+comment\ze\s*$" keepend extend contains=podCommand
     93  syn region podForComment start="\S.*$" end="^\ze\s*$" end="^\ze=cut\>" contained contains=@Spell,podTodo
     94 else
     95  syn region podBeginComment start="^=begin\s\+comment\s*$" end="^=end\s\+comment\ze\s*$" keepend extend contains=podCommand,podTodo fold
     96  syn region podForComment start="\S.*$" end="^\ze\s*$" end="^\ze=cut\>" contained contains=@Spell,podTodo fold
     97 endif
     98 
     99 syn keyword podTodo contained TODO FIXME XXX
    100 
    101 " Plain Pod files
    102 syn region podNonPod			   start="\%^\%(=\w\+\>\)\@!" end="^\ze=\a\w*\>"
    103 syn region podNonPod matchgroup=podCommand start="^=cut\>"	      end="\%$"
    104 syn 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 
    109 hi def link podCommand		Statement
    110 hi def link podBeginComment	Comment
    111 hi def link podForComment	Comment
    112 hi def link podNonPod		Comment
    113 hi def link podTodo		Todo
    114 hi def link podCmdText		String
    115 hi def link podEncoding		Constant
    116 hi def link podOverIndent	Number
    117 hi def link podForKeywd		Identifier
    118 hi def link podVerbatim		PreProc
    119 hi def link podFormat		Identifier
    120 hi def link podFormatDelimiter	podFormat
    121 hi def link podFormatError	Error
    122 hi def link podSpecial		Identifier
    123 hi def link podEscape		Constant
    124 hi def link podEscape2		Number
    125 
    126 if exists("perl_pod_spellcheck_headings")
    127  " Spell-check headings
    128  syn clear podCmdText
    129  syn region podCmdText start="\S.*$" end="^\s*$" end="^\ze=cut\>" contained contains=podFormat
    130 endif
    131 
    132 if 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.
    135  syn clear podFormat
    136  syn region podFormat start="[CLF]<[^<]"me=e-1 end=">" contains=@podFormat,@NoSpell
    137  syn 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.
    141  syn 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.
    145  syn 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.
    149  syn match podBoldOpen    "B<" contains=@NoSpell
    150  syn match podItalicOpen  "I<" contains=@NoSpell
    151  syn match podNoSpaceOpen "S<" contains=@NoSpell
    152  syn match podIndexOpen   "X<" contains=@NoSpell
    153 
    154  " Same as above but for the << >> syntax.
    155  syn match podBoldAlternativeDelimOpen    "B<<\%(\s\+\|$\)" contains=@NoSpell
    156  syn match podItalicAlternativeDelimOpen  "I<<\%(\s\+\|$\)" contains=@NoSpell
    157  syn match podNoSpaceAlternativeDelimOpen "S<<\%(\s\+\|$\)" contains=@NoSpell
    158  syn match podIndexAlternativeDelimOpen   "X<<\%(\s\+\|$\)" contains=@NoSpell
    159 
    160  " Add support for spell checking text inside B<>, I<>, S<> and X<>.
    161  syn region podBold start="B<[^<]"me=e end=">" contains=podBoldItalic,podBoldOpen
    162  syn region podBoldAlternativeDelim start="B<<\%(\s\+\|$\)" end="\%(\s\+\|^\)>>" contains=podBoldAlternativeDelimOpen
    163 
    164  syn region podItalic start="I<[^<]"me=e end=">" contains=podItalicBold,podItalicOpen
    165  syn region podItalicAlternativeDelim start="I<<\%(\s\+\|$\)" end="\%(\s\+\|^\)>>" contains=podItalicAlternativeDelimOpen
    166 
    167  " Nested bold/italic and vice-versa
    168  syn region podBoldItalic contained start="I<[^<]"me=e end=">"
    169  syn region podItalicBold contained start="B<[^<]"me=e end=">"
    170 
    171  syn region podNoSpace start="S<[^<]"ms=s-2 end=">"me=e contains=podNoSpaceOpen
    172  syn region podNoSpaceAlternativeDelim start="S<<\%(\s\+\|$\)"ms=s-2 end="\%(\s\+\|^\)>>"me=e contains=podNoSpaceAlternativeDelimOpen
    173 
    174  syn region podIndex start="X<[^<]"ms=s-2 end=">"me=e contains=podIndexOpen
    175  syn region podIndexAlternativeDelim start="X<<\%(\s\+\|$\)"ms=s-2 end="\%(\s\+\|^\)>>"me=e contains=podIndexAlternativeDelimOpen
    176 
    177  " Restore this (otherwise B<> is shown as bold inside verbatim)
    178  syn 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
    181  syn clear podCmdText
    182 
    183  if exists("perl_pod_spellcheck_headings")
    184    syn match podCmdText ".*$" contained contains=@podFormat,podBold,
    185          \podBoldAlternativeDelim,podItalic,podItalicAlternativeDelim,
    186          \podBoldOpen,podItalicOpen,podBoldAlternativeDelimOpen,
    187          \podItalicAlternativeDelimOpen,podNoSpaceOpen
    188  else
    189    syn match podCmdText ".*$" contained contains=@podFormat,podBold,
    190          \podBoldAlternativeDelim,podItalic,podItalicAlternativeDelim,
    191          \@NoSpell
    192  endif
    193 
    194  " Specify how to display these
    195  hi def podBold term=bold cterm=bold gui=bold
    196 
    197  hi link podBoldAlternativeDelim podBold
    198  hi link podBoldAlternativeDelimOpen podBold
    199  hi link podBoldOpen podBold
    200 
    201  hi link podNoSpace                 Identifier
    202  hi link podNoSpaceAlternativeDelim Identifier
    203 
    204  hi link podIndex                   Identifier
    205  hi link podIndexAlternativeDelim   Identifier
    206 
    207  hi def podItalic term=italic cterm=italic gui=italic
    208 
    209  hi link podItalicAlternativeDelim podItalic
    210  hi link podItalicAlternativeDelimOpen podItalic
    211  hi link podItalicOpen podItalic
    212 
    213  hi def podBoldItalic term=italic,bold cterm=italic,bold gui=italic,bold
    214  hi def podItalicBold term=italic,bold cterm=italic,bold gui=italic,bold
    215 endif
    216 
    217 let b:current_syntax = "pod"
    218 
    219 let &cpo = s:cpo_save
    220 unlet s:cpo_save
    221 
    222 " vim: ts=8 fdm=marker: