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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
|
snippet tbl
local $Test::Builder::Level = $Test::Builder::Level + 1;
snippet ccl
local $Carp::CarpLevel = $Carp::CarpLevel + 1;
snippet linc
local $${1:a} = $$1 + ${2:1};
${0}
snippet script
#!/usr/bin/env perl
use strict;
use warnings;
${0}
snippet test
#!/usr/bin/env perl
use strict;
use warnings;
use Test::More;
${0}
done_testing;
snippet sub
sub ${1:foo} {
${0}
}
snippet wd
use Data::Dump; ddx(${1});
${0}
snippet wdd
use Data::Dump; push @Data::Dump::FILTERS, sub { return {dump => "$_[1]"} if $_[0]->depth > ${1:1} }; ddx(${2});
${0}
snippet package
package ${1:`substitute(matchstr(expand("%"), '^lib/\zs.*\ze\.pm'), '/', '::', 'g')`};
use strict;
use warnings;
${0}
1;
snippet test_psgi
test_psgi
app => ${1:MyApp}->new->to_app,
client => sub {
my $cb = shift;
{
${0}
}
};
#
# Moose
#
snippet class
package ${1:`substitute(matchstr(expand("%"), '^lib/\zs.*\ze\.pm'), '/', '::', 'g')`};
use Moose;
${0}
__PACKAGE__->meta->make_immutable;
no Moose;
1;
# XXX: ideally, this would be merged with the one above, but we need posthooks
# for that to happen. also, some way to get the extends line to update with
# the package line would be nice, maybe?
snippet subclass
package ${1:`substitute(matchstr(expand("%"), '^lib/\zs.*\ze\.pm'), '/', '::', 'g')`};
use Moose;
extends '${2:`matchstr(substitute(matchstr(expand("%"), '^lib/\zs.*\ze\.pm'), '/', '::', 'g'), '.*\ze::.*')`}';
${0}
__PACKAGE__->meta->make_immutable;
no Moose;
1;
snippet role
package ${1:`substitute(matchstr(expand("%"), '^lib/\zs.*\ze\.pm'), '/', '::', 'g')`};
use Moose::Role;
${0}
no Moose::Role;
1;
snippet has
has ${1:attr} => (
is => '${2:ro}',
isa => '${3:Str}',${0}
);
snippet hasl
has ${1:attr} => (
is => '${2:ro}',
isa => '${3:Str}',
lazy_build => 1,${4}
);
sub _build_$1 {
my $self = shift;
${0}
}
snippet m
sub ${1:foo} {
my $self = shift;
${0}
}
snippet around
around ${1:foo} => sub {
my $orig = shift;
my $self = shift;
${0}
};
snippet after
after ${1:foo} => sub {
my $self = shift;
${0}
};
snippet before
before ${1:foo} => sub {
my $self = shift;
${0}
};
|