Merge pull request #264 from chrisyue/master

snip `nc` auto detect `Abstract` and `Interface`
This commit is contained in:
Honza Pokorny 2013-08-19 05:13:30 -07:00
commit 4a495f7b3e
2 changed files with 34 additions and 3 deletions

View File

@ -18,7 +18,7 @@ if m:
endsnippet endsnippet
snippet nc "php namespace and class" b snippet nc "php namespace and class or interface" b
namespace ${1:`!p namespace ${1:`!p
abspath = os.path.abspath(path) abspath = os.path.abspath(path)
m = re.search(r'[A-Z].+(?=/)', abspath) m = re.search(r'[A-Z].+(?=/)', abspath)
@ -29,7 +29,17 @@ if m:
/** /**
* ${3:@author `whoami`}${4} * ${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() snip.rv = re.match(r'.*(?=\.)', fn).group()
`} `}
{ {
@ -80,3 +90,9 @@ if (${1}) {
${2} ${2}
} }
endsnippet endsnippet
snippet /** "php comment block" b
/**
* @${1}
*/
endsnippet

View File

@ -1,3 +1,5 @@
# sugguestion? report bugs?
# go to https://github.com/chrisyue/vim-snippets/issues
snippet contr "symfony2 controller" b snippet contr "symfony2 controller" b
namespace `!p namespace `!p
abspath = os.path.abspath(path) abspath = os.path.abspath(path)
@ -23,6 +25,18 @@ snip.rv = re.match(r'.*(?=\.)', fn).group()
endsnippet endsnippet
snippet act "symfony2 action" b 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}") * @Route("${3}", name="${4}")
* @Method({${5:"GET"}}) * @Method({${5:"GET"}})
@ -32,7 +46,8 @@ public function ${1}Action(${2})
{ {
${6} ${6}
return []; return [];
} }`!p
abspath = os.path.abspath(path)`
endsnippet endsnippet
snippet comm "symfony2 command" b snippet comm "symfony2 command" b