summaryrefslogtreecommitdiffstats
path: root/vim/snippets
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2009-06-04 00:46:20 -0500
committerJesse Luehrs <doy@tozt.net>2009-06-04 00:46:20 -0500
commit8ac9438864d8556888e1619ca942e2ac1966272e (patch)
treea8ad3a4bad08153a629032237b9709d8372cc1a7 /vim/snippets
parentad7d28917ae6feff4b7b841e400b35c087b543e8 (diff)
downloadconf-8ac9438864d8556888e1619ca942e2ac1966272e.tar.gz
conf-8ac9438864d8556888e1619ca942e2ac1966272e.zip
add moose snippets
Diffstat (limited to 'vim/snippets')
-rw-r--r--vim/snippets/perl.snippets65
1 files changed, 65 insertions, 0 deletions
diff --git a/vim/snippets/perl.snippets b/vim/snippets/perl.snippets
index 0e7059c..320300b 100644
--- a/vim/snippets/perl.snippets
+++ b/vim/snippets/perl.snippets
@@ -49,3 +49,68 @@ snippet ccl
snippet linc
local $${1:a} = $$1 + ${2:1};
${3}
+#
+# Moose
+#
+snippet class
+ package ${1:`substitute(matchstr(expand("%"), '^lib/\zs.*\ze\.pm'), '/', '::', 'g')`};
+ use Moose;
+
+ ${2}
+
+ __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::.*')`}';
+
+ ${3}
+
+ __PACKAGE__->meta->make_immutable;
+ no Moose;
+
+ 1;
+snippet has
+ has ${1:attr} => (
+ is => '${2:ro}',
+ isa => '${3:Str}',${4}
+ );
+ ${5}
+snippet hasl
+ has ${1:attr} => (
+ is => '${2:ro}',
+ isa => '${3:Str}',
+ lazy_build => 1,${4}
+ );
+
+ sub _build_$1 {
+ my $self = shift;
+ $5
+ }
+snippet m
+ sub ${1:foo} {
+ my $self = shift;
+ ${2}
+ }
+snippet around
+ around ${1:foo} => sub {
+ my $orig = shift;
+ my $self = shift;
+ ${2}
+ };
+snippet after
+ after ${1:foo} => sub {
+ my $self = shift;
+ ${2}
+ };
+snippet before
+ before ${1:foo} => sub {
+ my $self = shift;
+ ${2}
+ };