Attempt "subtype" with auto ; placement
Shawn M Moore [Sat, 16 May 2009 09:23:17 +0000 (05:23 -0400)]
vim/moose_snippets.vim

index bfe9f90..16b7604 100644 (file)
@@ -14,6 +14,18 @@ function! RemoveUnchangedLine()
     endif
 endfun
 
+function! RemoveUnchangedLineSemicolon()
+    if match(getline('.'), "<{}>") >= 0
+        normal! ddkA;
+        normal! o
+        return ''
+    else
+        normal! A;
+        "normal! o " we can't actually change what line we're on :/
+        return @z
+    endif
+endfun
+
 function! Snippet(abbr, str)
     if type(a:str) == type([])
         return Snippet(a:abbr, join(a:str, "\n"))
@@ -107,6 +119,12 @@ call Snippet('after', [
             \    "my $self = shift;",
             \    "<{}>",
             \"};"])
+call Snippet('subtype', [
+            \"subtype '<{name}>'",
+            \    "=> as '<{supertype}>'",
+            \    "=> where { <{predicate:RemoveUnchangedLine()}> }",
+            \    "=> message { \"<{message:RemoveUnchangedLineSemicolon()}>\" }",
+            \""])
 
 " MooseX support
 call Snippet('prole', [