1 " See http://www.vim.org/scripts/script.php?script_id=1318
2 " Written by Sartak, feel free to add your own!
4 if !exists('loaded_snippet') || &cp
8 function RemoveEmptySuperClass()
9 s/^extends '<{}>';\n//e
13 function Snippet(abbr, str)
14 if type(a:str) == type([])
15 return Snippet(a:abbr, join(a:str, "\n"))
17 let st = g:snip_start_tag
18 let et = g:snip_end_tag
19 let cd = g:snip_elem_delim
20 let str = substitute(a:str, '<{.\{-}\zs:\ze.\{-}}>', cd, "")
21 let str = substitute(str, '<{', st, "")
22 let str = substitute(str, '}>', et, "")
23 exec 'Snippet '.a:abbr.' '.str
26 function SnippetFile(filename)
27 let abbr = fnamemodify(a:filename, ':t:r')
28 let str = readfile(a:filename)
29 return Snippet(abbr, str)
32 call Snippet('class', [
33 \"package <{ClassName}>;",
36 \"extends '<{SuperClass:RemoveEmptySuperClass()}>;",
40 \"__PACKAGE__->meta->make_immutable;",
47 \ "isa => '<{Str}>',",
50 call Snippet('hasl', [
53 \ "isa => '<{Str}>',",
58 \"sub _build_<{attr}> {",
59 \ "my $self = shift;",
64 \ "my $self = shift;",
67 call Snippet('around', [
68 \"around <{name}> => sub {",
69 \ "my $orig = shift;",
70 \ "my $self = shift;",
73 call Snippet('before', [
74 \"before <{name}> => sub {",
75 \ "my $self = shift;",
78 call Snippet('after', [
79 \"after <{name}> => sub {",
80 \ "my $self = shift;",
84 "for file in globpath(&rtp, 'snippets/*')
85 "call SnippetFile(file)