From 786f9a66fa7d1361bfd78486392ff54d57fc5a0d Mon Sep 17 00:00:00 2001 From: yuhuanbo Date: Mon, 19 Aug 2013 11:58:09 +0800 Subject: [PATCH] snip `nc` auto detect `Abstract` and `Interface` --- UltiSnips/php.snippets | 20 ++++++++++++++++++-- UltiSnips/php/symfony2.snippets | 17 ++++++++++++++++- 2 files changed, 34 insertions(+), 3 deletions(-) diff --git a/UltiSnips/php.snippets b/UltiSnips/php.snippets index 0e866d9..8b6a8ae 100644 --- a/UltiSnips/php.snippets +++ b/UltiSnips/php.snippets @@ -18,7 +18,7 @@ if m: endsnippet -snippet nc "php namespace and class" b +snippet nc "php namespace and class or interface" b namespace ${1:`!p abspath = os.path.abspath(path) m = re.search(r'[A-Z].+(?=/)', abspath) @@ -29,7 +29,17 @@ if m: /** * ${3:@author `whoami`}${4} */ -class ${2:`!p +`!p +m = re.search(r'Abstract', path) +if m: + snip.rv = 'abstract ' +``!p +m = re.search(r'Interface', path) +if m: + snip.rv = 'interface' +else: + snip.rv = 'class' +` ${2:`!p snip.rv = re.match(r'.*(?=\.)', fn).group() `} { @@ -80,3 +90,9 @@ if (${1}) { ${2} } endsnippet + +snippet /** "php comment block" b +/** + * @${1} + */ +endsnippet diff --git a/UltiSnips/php/symfony2.snippets b/UltiSnips/php/symfony2.snippets index 53df3d3..df928bf 100644 --- a/UltiSnips/php/symfony2.snippets +++ b/UltiSnips/php/symfony2.snippets @@ -1,3 +1,5 @@ +# sugguestion? report bugs? +# go to https://github.com/chrisyue/vim-snippets/issues snippet contr "symfony2 controller" b namespace `!p abspath = os.path.abspath(path) @@ -23,6 +25,18 @@ snip.rv = re.match(r'.*(?=\.)', fn).group() endsnippet snippet act "symfony2 action" b +/** + * @Route("${3}", name="${4}") + * @Method({${5:"POST"}}) + */ +public function ${1}Action(${2}) +{ + ${6} + return $this->redirect($this->generate('home', [], false)); +} +endsnippet + +snippet actt "symfony2 action and template" b /** * @Route("${3}", name="${4}") * @Method({${5:"GET"}}) @@ -32,7 +46,8 @@ public function ${1}Action(${2}) { ${6} return []; -} +}`!p +abspath = os.path.abspath(path)` endsnippet snippet comm "symfony2 command" b