summaryrefslogtreecommitdiff
path: root/runtime/syntax/pod.vim
blob: 9809d00b5aa62c975acc27f5a3698a5804ecbae1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
" Vim syntax file
" Language:	Perl POD format
" Maintainer:	Scott Bigham <dsb@killerbunnies.org>
" Last Change:	2007 Jan 21

" To add embedded POD documentation highlighting to your syntax file, add
" the commands:
"
"   syn include @Pod <sfile>:p:h/pod.vim
"   syn region myPOD start="^=pod" start="^=head" end="^=cut" keepend contained contains=@Pod
"
" and add myPod to the contains= list of some existing region, probably a
" comment.  The "keepend" flag is needed because "=cut" is matched as a
" pattern in its own right.


" Remove any old syntax stuff hanging around (this is suppressed
" automatically by ":syn include" if necessary).
" For version 5.x: Clear all syntax items
" For version 6.x: Quit when a syntax file was already loaded
if version < 600
  syntax clear
elseif exists("b:current_syntax")
  finish
endif

" POD commands
syn match podCommand	"^=head[1234]"	nextgroup=podCmdText contains=@NoSpell
syn match podCommand	"^=item"	nextgroup=podCmdText contains=@NoSpell
syn match podCommand	"^=over"	nextgroup=podOverIndent skipwhite contains=@NoSpell
syn match podCommand	"^=back" contains=@NoSpell
syn match podCommand	"^=cut" contains=@NoSpell
syn match podCommand	"^=pod" contains=@NoSpell
syn match podCommand	"^=for"		nextgroup=podForKeywd skipwhite contains=@NoSpell
syn match podCommand	"^=begin"	nextgroup=podForKeywd skipwhite contains=@NoSpell
syn match podCommand	"^=end"		nextgroup=podForKeywd skipwhite contains=@NoSpell

" Text of a =head1, =head2 or =item command
syn match podCmdText	".*$" contained contains=podFormat,@NoSpell

" Indent amount of =over command
syn match podOverIndent	"\d\+" contained contains=@NoSpell

" Formatter identifier keyword for =for, =begin and =end commands
syn match podForKeywd	"\S\+" contained contains=@NoSpell

" An indented line, to be displayed verbatim
syn match podVerbatimLine	"^\s.*$" contains=@NoSpell

" Inline textual items handled specially by POD
syn match podSpecial	"\(\<\|&\)\I\i*\(::\I\i*\)*([^)]*)" contains=@NoSpell
syn match podSpecial	"[$@%]\I\i*\(::\I\i*\)*\>" contains=@NoSpell

" Special formatting sequences
syn region podFormat	start="[IBSCLFX]<[^<]"me=e-1 end=">" oneline contains=podFormat,@NoSpell
syn region podFormat	start="[IBSCLFX]<<\s" end="\s>>" oneline contains=podFormat,@NoSpell
syn match  podFormat	"Z<>"
syn match  podFormat	"E<\(\d\+\|\I\i*\)>" contains=podEscape,podEscape2,@NoSpell
syn match  podEscape	"\I\i*>"me=e-1 contained contains=@NoSpell
syn match  podEscape2	"\d\+>"me=e-1 contained contains=@NoSpell

" Define the default highlighting.
" For version 5.7 and earlier: only when not done already
" For version 5.8 and later: only when an item doesn't have highlighting yet
if version >= 508 || !exists("did_pod_syntax_inits")
  if version < 508
    let did_pod_syntax_inits = 1
    command -nargs=+ HiLink hi link <args>
  else
    command -nargs=+ HiLink hi def link <args>
  endif

  HiLink podCommand		Statement
  HiLink podCmdText		String
  HiLink podOverIndent		Number
  HiLink podForKeywd		Identifier
  HiLink podFormat		Identifier
  HiLink podVerbatimLine	PreProc
  HiLink podSpecial		Identifier
  HiLink podEscape		String
  HiLink podEscape2		Number

  delcommand HiLink
endif

let b:current_syntax = "pod"

" vim: ts=8