1
0
mirror of https://github.com/amix/vimrc synced 2025-07-04 15:04:59 +08:00

merge to origin

This commit is contained in:
Tiande
2016-06-27 02:30:37 +08:00
parent 5ba4c775d9
commit 881ead4c17
113 changed files with 11333 additions and 3543 deletions

View File

@ -186,7 +186,7 @@ snippet iblock "" bi
{% block ${1:blockname} %}${VISUAL}{% endblock $1 %}
endsnippet
snippet csfr "" bi
snippet csrf "" bi
{% csrf_token %}
endsnippet

View File

@ -21,7 +21,7 @@ def nl(snip):
snip.rv += " "
def getArgs(group):
import re
word = re.compile('[a-zA-Z><.]+ \w+')
word = re.compile('[a-zA-Z0-9><.]+ \w+')
return [i.split(" ") for i in word.findall(group) ]
def camel(word):
@ -109,7 +109,7 @@ for i in args:
snip.rv += "\n\tprivate " + i[0] + " " + i[1]+ ";"
if len(args) > 0:
snip.rv += "\n"`
public `!p snip.rv = snip.basename or "unknown"`($1) { `!p
public `!p snip.rv = snip.basename or "unknown"`($1) {`!p
args = getArgs(t[1])
for i in args:
snip.rv += "\n\t\tthis." + i[1] + " = " + i[1] + ";"
@ -123,8 +123,8 @@ for i in args:
snip.rv += "\n\tpublic void set" + camel(i[1]) + "(" + i[0] + " " + i[1] + ") {\n" + "\
\tthis." + i[1] + " = " + i[1] + ";\n\t}\n"
snip.rv += "\n\tpublic " + i[0] + " get" + camel(i[1]) + "() {\
\n\t\treturn " + i[1] + ";\n\t}\n"
snip.rv += "\n\tpublic " + i[0] + " get" + camel(i[1]) + "() {\n\
\treturn " + i[1] + ";\n\t}\n"
`
}
endsnippet
@ -138,7 +138,7 @@ for i in args:
snip.rv += "\n\tprivate " + i[0] + " " + i[1]+ ";"
if len(args) > 0:
snip.rv += "\n"`
public `!p snip.rv = snip.basename or "unknown"`($1) { `!p
public `!p snip.rv = snip.basename or "unknown"`($1) {`!p
args = getArgs(t[1])
for i in args:
snip.rv += "\n\t\tthis.%s = %s;" % (i[1], i[1])
@ -266,7 +266,7 @@ for i in args:
snip.rv += "\n\tprivate " + i[0] + " " + i[1]+ ";"
if len(args) > 0:
snip.rv += "\n"`
public `!p snip.rv = snip.basename or "unknown"`($1) { `!p
public `!p snip.rv = snip.basename or "unknown"`($1) {`!p
args = getArgs(t[1])
for i in args:
snip.rv += "\n\t\tthis.%s = %s;" % (i[1], i[1])
@ -326,11 +326,11 @@ snippet md "Method With javadoc" b
* ${7:Short Description}`!p
for i in getArgs(t[4]):
snip.rv += "\n\t * @param " + i[1] + " usage..."`
* `!p
*`!p
if "throws" in t[5]:
snip.rv = "\n\t * @throws " + t[6]
else:
snip.rv = ""` `!p
snip.rv = ""``!p
if not "void" in t[2]:
snip.rv = "\n\t * @return object"
else:
@ -356,8 +356,7 @@ endsnippet
snippet /se?tge?t|ge?tse?t|gs/ "setter and getter" br
public void set${1:Name}(${2:String} `!p snip.rv = mixedCase(t[1])`) {
this.`!p snip.rv = mixedCase(t[1])` = `!p snip.rv = mixedCase(t[1])`;
}
}`!p snip.rv += "\n"`
public $2 get$1() {
return `!p snip.rv = mixedCase(t[1])`;
}

View File

@ -4,7 +4,7 @@ snippet s "String" b
"${1:key}": "${0:value}",
endsnippet
snippet n "number" b
snippet n "Number" b
"${1:key}": ${0:value},
endsnippet
@ -13,8 +13,39 @@ snippet a "Array" b
${VISUAL}$0
],
endsnippet
snippet na "Named array" b
"${1:key}": [
${VISUAL}$0
],
endsnippet
snippet o "Object" b
{
${VISUAL}$0
},
endsnippet
snippet no "Named object" b
"${1:key}": {
${VISUAL}$0
},
endsnippet
snippet null "Null" b
"${0:key}": null,
endsnippet
global !p
def compB(t, opts):
if t:
opts = [m[len(t):] for m in opts if m.startswith(t)]
if len(opts) == 1:
return opts[0]
return "(" + '|'.join(opts) + ')'
endglobal
snippet b "Bool" b
"${1:key}": $2`!p snip.rv=compB(t[2], ['true', 'false'])`,
endsnippet

View File

@ -1,8 +1,9 @@
# Snippets for phpspec
# Snippets for phpspec, to use add the following to your .vimrc
# `autocmd BufRead,BufNewFile,BufEnter *Spec.php UltiSnipsAddFiletypes php-phpspec`
priority -50
snippet spec "phpspec class" b
snippet spec "class XYZSpec extends ObjectBehaviour"
<?php
namespace `!p
@ -22,17 +23,200 @@ class `!p
snip.rv = re.match(r'.*(?=\.)', fn).group()
` extends ObjectBehavior
{
public function it${1:_does_something}()
function it_${1}()
{
$0
}
}
endsnippet
snippet it "phpspec function it..." b
public function it${1:_does_something}()
snippet it "function it_does_something() { ... }"
function it_${1}()
{
$0
${0:${VISUAL}}
}
endsnippet
snippet let "function let() { ... }"
function let()
{
${0:${VISUAL}}
}
endsnippet
snippet letgo "function letgo() { ... }"
function letgo()
{
${0:${VISUAL}}
}
endsnippet
# Object construction
snippet cw "$this->beConstructedWith($arg)"
$this->beConstructedWith(${1});
endsnippet
snippet ct "$this->beConstructedThrough($methodName, [$arg])"
$this->beConstructedThrough(${1:'methodName'}, [${2:'$arg'}]);
endsnippet
# Identity and comparison matchers
snippet sreturn "$this->XYZ()->shouldReturn('value')"
$this->${1:method}()->shouldReturn(${2:'value'});
endsnippet
snippet snreturn "$this->XYZ()->shouldNotReturn('value')"
$this->${1:method}()->shouldNotReturn(${2:'value'});
endsnippet
snippet sbe "$this->XYZ()->shouldBe('value')"
$this->${1:method}()->shouldBe(${2:'value'});
endsnippet
snippet snbe "$this->XYZ()->shouldNotBe('value')"
$this->${1:method}()->shouldNotBe(${2:'value'});
endsnippet
snippet sequal "$this->XYZ()->shouldEqual('value')"
$this->${1:method}()->shouldEqual(${2:'value'});
endsnippet
snippet snequal "$this->XYZ()->shouldNotEqual('value')"
$this->${1:method}()->shouldNotEqual(${2:'value'});
endsnippet
snippet sbequalto "$this->XYZ()->shouldBeEqualTo('value')"
$this->${1:method}()->shouldBeEqualTo(${2:'value'});
endsnippet
snippet snbequalto "$this->XYZ()->shouldNotBeEqualTo('value')"
$this->${1:method}()->shouldNotBeEqualTo(${2:'value'});
endsnippet
snippet sblike "$this->XYZ()->shouldBeLike('value')"
$this->${1:method}()->shouldBeLike(${2:'value'});
endsnippet
snippet snblike "$this->XYZ()->shouldNotBeLike('value')"
$this->${1:method}()->shouldNotBeLike(${2:'value'});
endsnippet
# Throw matcher
snippet sthrowm "$this->shouldThrow('\Exception')->duringXYZ($arg)"
$this->shouldThrow(${1:'\Exception'})->during${2:Method}(${3:'$arg'});
endsnippet
snippet sthrowi "$this->shouldThrow('\Exception')->duringInstantiation()"
$this->shouldThrow(${1:'\Exception'})->duringInstantiation();
endsnippet
# Type matchers
snippet stype "$this->shouldHaveType('Type')"
$this->shouldHaveType(${1});
endsnippet
snippet sntype "$this->shouldNotHaveType('Type')"
$this->shouldNotHaveType(${1});
endsnippet
snippet srinstance "$this->shouldReturnAnInstanceOf('Type')"
$this->shouldReturnAnInstanceOf(${1});
endsnippet
snippet snrinstance "$this->shouldNotReturnAnInstanceOf('Type')"
$this->shouldNotReturnAnInstanceOf(${1});
endsnippet
snippet sbinstance "$this->shouldBeAnInstanceOf('Type')"
$this->shouldBeAnInstanceOf(${1});
endsnippet
snippet snbinstance "$this->shouldNotBeAnInstanceOf('Type')"
$this->shouldNotBeAnInstanceOf(${1});
endsnippet
snippet simplement "$this->shouldImplement('Type')"
$this->shouldImplement(${1});
endsnippet
snippet snimplement "$this->shouldNotImplement('Type')"
$this->shouldNotImplement(${1});
endsnippet
# Object state matchers
snippet sbstate "$this->shouldBeXYZ()"
$this->shouldBe${1}();
endsnippet
snippet snbstate "$this->shouldNotBeXYZ()"
$this->shouldNotBe${1}();
endsnippet
# Count matchers
snippet scount "$this->XYZ()->shouldHaveCount(7)"
$this->${1:method}()->shouldHaveCount(${2:7});
endsnippet
snippet sncount "$this->XYZ()->shouldNotHaveCount(7)"
$this->${1:method}()->shouldNotHaveCount(${2:7});
endsnippet
# Scalar type matchers
snippet sbscalar "$this->XYZ()->shouldBeString|Array|Bool()"
$this->${1:method}()->shouldBe${2:String|Array|Bool}();
endsnippet
snippet snbscalar "$this->XYZ()->shouldNotBeString|Array|Bool()"
$this->${1:method}()->shouldNotBe${2:String|Array|Bool}();
endsnippet
# Contain matcher
snippet scontain "$this->XYZ()->shouldContain('value')"
$this->${1:method}()->shouldContain(${2:'value'});
endsnippet
snippet sncontain "$this->XYZ()->shouldNotContain('value')"
$this->${1:method}()->shouldNotContain(${2:'value'});
endsnippet
# Array matchers
snippet skey "$this->XYZ()->shouldHaveKey('key')"
$this->${1:method}()->shouldHaveKey(${2:'key'});
endsnippet
snippet snkey "$this->XYZ()->shouldNotHaveKey('key')"
$this->${1:method}()->shouldNotHaveKey(${2:'key'});
endsnippet
snippet skeyvalue "$this->XYZ()->shouldHaveKeyWithValue('key', 'value')"
$this->${1:method}()->shouldHaveKeyWithValue(${2:'key'}, ${3:'value'});
endsnippet
snippet snkeyvalue "$this->XYZ()->shouldNotHaveKeyWithValue('key', 'value')"
$this->${1:method}()->shouldNotHaveKeyWithValue(${2:'key'}, ${3:'value'});
endsnippet
# String matchers
snippet sstart "$this->XYZ()->shouldStartWith('string')"
$this->${1:method}()->shouldStartWith(${2:'string'});
endsnippet
snippet snstart "$this->XYZ()->shouldNotStartWith('string')"
$this->${1:method}()->shouldNotStartWith(${2:'string'});
endsnippet
snippet send "$this->XYZ()->shouldEndWith('string')"
$this->${1:method}()->shouldEndWith(${2:'string'});
endsnippet
snippet snend "$this->XYZ()->shouldNotEndWith('string')"
$this->${1:method}()->shouldNotEndWith(${2:'string'});
endsnippet
snippet smatch "$this->XYZ()->shouldMatch('/wizard/i')"
$this->${1:method}()->shouldMatch(${2:'/wizard/i'});
endsnippet
snippet snmatch "$this->XYZ()->shouldNotMatch('/wizard/i')"
$this->${1:method}()->shouldNotMatch(${2:'/wizard/i'});
endsnippet

View File

@ -1,40 +0,0 @@
# suggestion? report bugs?
# please go to https://github.com/chrisyue/vim-snippets/issues
priority -50
snippet test "phpunit test class" b
<?php
namespace `!p
relpath = os.path.relpath(path)
m = re.search(r'[A-Z].+(?=/)', relpath)
if m:
snip.rv = m.group().replace('/', '\\')
`;
/**
* @author `!v g:snips_author`
*/
class `!p
snip.rv = re.match(r'.*(?=\.)', fn).group()
` extends \PHPUnit_Framework_TestCase
{
public function test${1}()
{
${2}
}
}
endsnippet
snippet exp "phpunit expects" i
expects($this->${1:once}())
->method('${2}')
->with($this->equalTo(${3})${4})
->will($this->returnValue(${5}));
endsnippet
snippet testcmt "phpunit comment with group" b
/**
* @group ${1}
*/
endsnippet

View File

@ -3,166 +3,56 @@ priority -50
## Snippets from SnipMate, taken from
## https://github.com/scrooloose/snipmate-snippets.git
snippet array "array"
$${1:arrayName} = array('${2}' => ${3});${4}
endsnippet
snippet def "def"
define('${1:VARIABLE_NAME}', ${2:'definition'});${3}
endsnippet
snippet wh "while"
while (${1}) {
${0:${VISUAL}}
}
endsnippet
snippet do "do"
do {
${2:// code... }
} while (${1:/* condition */});
endsnippet
snippet doc_f "doc_f"
/**
* $2
* @return ${4:void}
* @author ${5:`!v g:snips_author`}
**/
${1:public }function ${2:someFunc}(${3})
{${6}
}
endsnippet
snippet doc_i "doc_i"
/**
* $1
* @package ${2:default}
* @author ${3:`!v g:snips_author`}
**/
interface ${1:someClass}
{${4}
} // END interface $1"
endsnippet
snippet el "else"
else {
${0:${VISUAL}}
}
endsnippet
snippet for "for"
for ($${2:i} = 0; $$2 < ${1:count}; $$2${3:++}) {
${4:// code...}
}
endsnippet
snippet foreachk "foreachk"
foreach ($${1:variable} as $${2:key} => $${3:value}) {
${4:// code...}
}
endsnippet
snippet get "get"
$_GET['${1}']${2}
endsnippet
snippet if "if"
if (${1}) {
${0:${VISUAL}}
}
endsnippet
snippet eif "elseif"
elseif (${1}) {
${0:${VISUAL}}
}
endsnippet
snippet inc "inc"
include '${1:file}';${2}
endsnippet
snippet log "log"
error_log(var_export(${1}, true));${2}
endsnippet
snippet post "post"
$_POST['${1}']${2}
endsnippet
snippet req "req1"
require_once '${1:file}';${2}
endsnippet
snippet req1 "req1"
require_once '${1:file}';${2}
endsnippet
snippet session "session"
$_SESSION['${1}']${2}
endsnippet
snippet t "t"
$${1:retVal} = (${2:condition}) ? ${3:a} : ${4:b};${5}
endsnippet
snippet var "var"
var_export(${1});${2}
endsnippet
snippet getter "PHP Class Getter" b
snippet gm "PHP Class Getter" b
/**
* Getter for $1
*
* ${2:return string}
* @return ${2:string}
*/
public function get${1/\w+\s*/\u$0/}()
{
return $this->$1;$3
return $this->$1;
}
endsnippet
snippet setter "PHP Class Setter" b
snippet sm "PHP Class Setter" b
/**
* Setter for $1
*
* @param ${2:string} $$1
* @param ${2:string} $$1
* @return ${3:`!p snip.rv=snip.basename`}
*/
public function set${1/\w+\s*/\u$0/}(${4:${2/(void|string|int|integer|double|float|object|boolear|null|mixed|number|resource)|(.*)/(?1::$2 )/}}$$1)
{
$this->$1 = $$1;$5
$this->$1 = $$1;
${6:return $this;}
${5:return $this;}
}
$0
endsnippet
snippet gs "PHP Class Getter Setter" b
/**
* Getter for $1
*
* return ${2:string}
* @return ${2:string}
*/
public function get${1/\w+\s*/\u$0/}()
{
return $this->$1;$3
return $this->$1;
}
/**
* Setter for $1
*
* @param $2 $$1
* @return ${4:`!p snip.rv=snip.basename`}
* @return ${3:`!p snip.rv=snip.basename`}
*/
public function set${1/\w+\s*/\u$0/}(${5:${2/(void|string|int|integer|double|float|object|boolear|null|mixed|number|resource)|(.*)/(?1::$2 )/}}$$1)
public function set${1/\w+\s*/\u$0/}(${4:${2/(void|string|int|integer|double|float|object|boolear|null|mixed|number|resource)|(.*)/(?1::$2 )/}}$$1)
{
$this->$1 = $$1;$6
$this->$1 = $$1;
${7:return $this;}
${5:return $this;}
}
$0
endsnippet
snippet pub "Public function" b
@ -251,27 +141,11 @@ function ${1:name}(${2:$param})
$0
endsnippet
snippet fore "Foreach loop"
foreach ($${1:variable} as $${3:value}) {
${VISUAL}${4}
}
$0
endsnippet
snippet new "New class instance" b
$${1:variableName} = new ${2:${1/\w+\s*/\u$0/}}($3);
$0
endsnippet
snippet ife "if else"
if (${1:/* condition */}) {
${2:// code...}
} else {
${3:// code...}
}
$0
endsnippet
snippet ns "namespace declaration" b
namespace ${1:`!p
relpath = os.path.relpath(path)
@ -316,7 +190,7 @@ if m:
*/
interface $1
{
public function ${3:someFunction}();$4
public function ${3:someFunction}();$4
}
endsnippet
@ -349,18 +223,29 @@ public function __construct(${1:$dependencies})
$0
endsnippet
snippet ve "Dumb debug helper in HTML"
echo '<pre>' . var_export($1, 1) . '</pre>';$0
endsnippet
# PHPUnit snippets
snippet testcase "class XYZTest extends \PHPUnit_Framework_TestCase { ... }"
<?php
snippet pc "Dumb debug helper in cli"
var_export($1);$0
endsnippet
namespace `!p
relpath = os.path.relpath(path)
m = re.search(r'[A-Z].+(?=/)', relpath)
if m:
snip.rv = m.group().replace('/', '\\')
`;
snippet inheritdoc "@inheritdoc docblock"
/**
* {@inheritdoc}
* @author `!v g:snips_author`
*/
class `!p
snip.rv = re.match(r'.*(?=\.)', fn).group()
` extends \PHPUnit_Framework_TestCase
{
public function test${1}()
{
${0:${VISUAL}}
}
}
endsnippet
# :vim:ft=snippets:

View File

@ -1,53 +0,0 @@
priority -50
snippet bl "twig block" b
{% block ${1} %}
${2}
{% endblock $1 %}
endsnippet
snippet js "twig javascripts" b
{% javascripts '${1}' %}
<script src="{{ asset_url }}"></script>
{% endjavascripts %}
endsnippet
snippet css "twig stylesheets" b
{% stylesheets '${1}' %}
<link rel="stylesheet" href="{{ asset_url }}">
{% endstylesheets %}
endsnippet
snippet if "twig if" b
{% if ${1} %}
${0:${VISUAL}}
{% endif %}
endsnippet
snippet ife "twig if ... else" b
{% if ${1} %}
${2}
{% else %}
${0}
{% endif %}
endsnippet
snippet el "twig else"
{% else %}
${0:${VISUAL}}
endsnippet
snippet eif "twig elseif"
{% elseif ${1} %}
${0:${VISUAL}}
endsnippet
snippet for "twig for" b
{% for ${1} in ${2} %}
${3}
{% endfor %}
endsnippet
snippet ext "twig extends" b
{% extends ${1} %}
endsnippet

View File

@ -7,6 +7,8 @@ snippet date
`strftime("%Y-%m-%d")`
snippet ddate
`strftime("%B %d, %Y")`
snippet diso
`strftime("%Y-%m-%dT%H:%M:%S")`
snippet time
`strftime("%H:%M")`
snippet datetime

View File

@ -146,9 +146,9 @@ snippet itera
## Lambdas
# lamda (one line)
snippet ld
[${1}](${2}){${3}}
[${1}](${2}){${3}};
# lambda (multi-line)
snippet lld
[${1}](${2}){
${3}
}
};

View File

@ -1,3 +1,5 @@
extends html
snippet %
<% ${0} %>
snippet =

View File

@ -114,7 +114,7 @@ snippet testa
end
snippet exunit
defmodule ${1:`substitute(vim_snippets#Filename(), '\(_\|^\)\(.\)', '\u\2', 'g')`} do
use ExUnit.Case
use ExUnit.Case, async: true
${0}
end
@ -131,3 +131,6 @@ snippet qu
quote do
${1}
end
snippet beh
@behaviour ${1:Mix.Task}
${0}

View File

@ -0,0 +1,50 @@
snippet mod
module `substitute(substitute(expand('%:r'), '[/\\]','.','g'),'^\%(\l*\.\)\?','','')` exposing (${1})
${0}
snippet imp
import ${0:List}
snippet impe
import ${1:List} exposing (${0:map})
snippet fn
${1:fn} : ${2:a} -> ${3:a}
$1 ${4} =
${0}
snippet fn1
${1:fn} : ${2:a} -> ${3:a}
$1 ${4} =
${0}
snippet fn2
${1:fn} : ${2:a} -> ${3:a} -> ${4:a}
$1 ${5} =
${0}
snippet fn3
${1:fn} : ${2:a} -> ${3:a} -> ${4:a} -> ${5:a}
$1 ${6} =
${0}
snippet fn0
${1:fn} : ${2:a}
$1 =
${0}
snippet case
case ${1} of
${2} ->
${0}
snippet -
${1} ->
${0}
snippet let
let
${1} = ${2}
in
${0}
snippet if
if ${1} then
${2}
else
${0}
snippet ty
type ${1:Msg}
= ${0}
snippet tya
type alias ${1:Model} =
${0}

View File

@ -482,6 +482,37 @@ snippet gen_event
%%%===================================================================
%%% Internal functions
%%%===================================================================
# EUnit snippets
snippet eunit
-module(${1:`vim_snippets#Filename('', 'my')`}).
-include_lib("eunit/include/eunit.hrl").
${0}
snippet ieunit
-ifdef(TEST).
-include_lib("eunit/include/eunit.hrl").
${0}
-endif.
snippet as
?assert(${0})
snippet asn
?assertNot(${0})
snippet aseq
?assertEqual(${1}, ${0})
snippet asneq
?assertNotEqual(${1}, ${0})
snippet asmat
?assertMatch(${1:Pattern}, ${0:Expression})
snippet asnmat
?assertNotMatch(${1:Pattern}, ${0:Expression})
snippet aserr
?assertError(${1:Pattern}, ${0:Expression})
snippet asex
?assertExit(${1:Pattern}, ${0:Expression})
snippet asexc
?assertException(${1:Class}, ${2:Pattern}, ${0:Expression})
# common_test test_SUITE
snippet testsuite
-module(${0:`vim_snippets#Filename('', 'my')`}).

View File

@ -0,0 +1,14 @@
snippet des "Describe" b
describe('${1:}', () => {
${0}
});
snippet it "it" b
it('${1:}', () => {
${0}
});
snippet exp "expect" b
expect(${1:})${0};
snippet expe "expect" b
expect(${1:}).to.equal(${0});
snippet expd "expect" b
expect(${1:}).to.deep.equal(${0});

View File

@ -43,3 +43,8 @@ snippet el
# .DEFAULT_GOAL := target
snippet default
.DEFAULT_GOAL := ${1}
# help target for self-documented Makefile
snippet help
help: ## Prints help for targets with comments
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $\$1, $\$2}'
${0}

View File

@ -0,0 +1,18 @@
# if {{#value}} ... {{/value}}
snippet if
{{#${1:value}}}
${0}
{{/$1}}
# if not {{^value}} ... {{/value}}
snippet ifn
{{^${1:value}}}
${0}
{{/$1}}
# if else {{#value}} ... {{/value}} {{^value}} ... {{/value}}
snippet ife
{{#${1:value}}}
${2}
{{/$1}}
{{^$1}}
${3}
{{/$1}}

View File

@ -24,10 +24,7 @@ snippet ?i
snippet ns
namespace ${1:Foo\Bar\Baz};
${0}
snippet use
use ${1:Foo\Bar\Baz};
${0}
snippet c
snippet c
class ${1:`vim_snippets#Filename()`}
{
${0}
@ -50,28 +47,27 @@ snippet m
{
${0}
}
# setter method
snippet sm
snippet sm "PHP Class Setter"
/**
* Sets the value of ${1:foo}
*
* @param ${2:$1} $$1 ${3:description}
* @param ${2:string} $$1 ${3:description}
*
* @return ${4:`vim_snippets#Filename()`}
*/
${5:public} function set${6:$2}(${7:$2 }$$1)
${5:public} function set${6:$1}(${7:$2 }$$1)
{
$this->${8:$1} = $$1;
return $this;
}
# getter method
snippet gm
snippet gm "PHP Class Getter Setter"
/**
* Gets the value of ${1:foo}
*
* @return ${2:$1}
* @return ${2:string}
*/
${3:public} function get${4:$2}()
${3:public} function get${4:$1}()
{
return $this->${5:$1};
}
@ -81,13 +77,14 @@ snippet $s
#getter
snippet $g
${1:$foo}->get${0:Bar}();
# Tertiary conditional
snippet =?:
$${1:foo} = ${2:true} ? ${3:a} : ${0};
snippet ?:
${1:true} ? ${2:a} : ${0}
snippet t "$retVal = (condition) ? a : b"
$${1:retVal} = (${2:condition}) ? ${3:a} : ${4:b};
# Predefined variables
snippet C
$_COOKIE['${1:variable}']
snippet E
@ -104,7 +101,12 @@ snippet S
$_SERVER['${1:variable}']
snippet SS
$_SESSION['${1:variable}']
snippet get "get"
$_GET['${1}']
snippet post "post"
$_POST['${1}']
snippet session "session"
$_SESSION['${1}']
# the following are old ones
snippet inc
include '${1:file}';
@ -205,7 +207,19 @@ snippet doc_h
* @copyright ${4:$2}, `strftime('%d %B, %Y')`
* @package ${0:default}
*/
snippet doc_i "interface someClass {}"
/**
* $1
* @package ${2:default}
* @author ${3:`!v g:snips_author`}
**/
interface ${1:someClass}
{${4}
}
snippet inheritdoc "@inheritdoc docblock"
/**
* {@inheritdoc}
*/
# Interface
snippet interface
/**
@ -254,55 +268,54 @@ snippet nc
${0}
}
# define(...)
snippet def
define('${1}'${2});
snippet def "define('VARIABLE_NAME', 'definition')"
define('${1:VARIABLE_NAME}', ${2:'definition'});
# defined(...)
snippet def?
${1}defined('${2}')
snippet wh
snippet wh "while (condition) { ... }"
while (${1:/* condition */}) {
${0}
}
# do ... while
snippet do
snippet do "do { ... } while (condition)"
do {
${0}
} while (${1:/* condition */});
snippet if
if (${1:/* condition */}) {
} while (${1});
snippet if "if (condition) { ... }"
if (${1}) {
${0}
}
snippet ifn
if (!${1:/* condition */}) {
snippet ifn "if (!condition) { ... }"
if (!${1}) {
${2}
}
snippet ifil
<?php if (${1:/* condition */}): ?>
snippet ifil "<?php if (condition): ?> ... <?php endif; ?>"
<?php if (${1}): ?>
${0}
<?php endif; ?>
snippet ife
if (${1:/* condition */}) {
snippet ife "if (cond) { ... } else { ... }"
if (${1}) {
${2}
} else {
${3}
}
${0}
snippet ifeil
<?php if (${1:/* condition */}): ?>
${2:<!-- html... -->}
snippet ifeil "<?php if (condition): ?> ... <?php else: ?> ... <?php endif; ?>"
<?php if (${1}): ?>
${2}
<?php else: ?>
${3:<!-- html... -->}
${3}
<?php endif; ?>
${0}
snippet el
snippet el "else { ... }"
else {
${0}
}
snippet eif
snippet eif "elseif(condition) { ... }"
elseif (${1}) {
${0}
}
snippet switch
snippet switch "switch($var) { case 'xyz': ... default: .... }"
switch ($${1:variable}) {
case '${2:value}':
${3}
@ -312,34 +325,33 @@ snippet switch
${4}
break;
}
snippet case
snippet case "case 'value': ... break"
case '${1:value}':
${2}
break;
snippet for
snippet for "for ($i = 0; $i < $count; $i++) { ... }"
for ($${2:i} = 0; $$2 < ${1:count}; $$2${3:++}) {
${0}
}
snippet foreach
snippet foreach "foreach ($var as $value) { .. }"
foreach ($${1:variable} as $${2:value}) {
${0}
}
snippet foreachil
snippet foreachil "<?php foreach ($var as $value): ?> ... <?php endforeach; ?>"
<?php foreach ($${1:variable} as $${2:value}): ?>
${0:<!-- html... -->}
${0}
<?php endforeach; ?>
snippet foreachk
snippet foreachk "foreach ($var as $key => $value) { .. }"
foreach ($${1:variable} as $${2:key} => $${3:value}) {
${0}
}
snippet foreachkil
snippet foreachkil "<?php foreach ($var as $key => $value): ?> ... <?php endforeach; ?>"
<?php foreach ($${1:variable} as $${2:key} => $${3:value}): ?>
${0:<!-- html... -->}
<?php endforeach; ?>
# $... = array (...)
snippet array b
snippet array "$... = array(...)"
$${1:arrayName} = array('${2}' => ${3});
snippet try
snippet try "try { ... } catch (Exception $e) { ... }"
try {
${0}
} catch (${1:Exception} $e) {
@ -369,14 +381,22 @@ snippet http_redirect
header ("HTTP/1.1 301 Moved Permanently");
header ("Location: ".URL);
exit();
snippet log "error_log(var_export($var, true));"
error_log(var_export(${1}, true));
snippet var "var_export($var)"
var_export(${1});
snippet ve "Dumb debug helper in HTML"
echo '<pre>' . var_export(${1}, 1) . '</pre>';
snippet pc "Dumb debug helper in cli"
var_export($1);$0
# Getters & Setters
snippet gs
snippet gs "PHP Class Getter Setter"
/**
* Gets the value of ${1:foo}
*
* @return ${2:$1}
* @return ${2:string}
*/
public function get${3:$2}()
public function get${3:$1}()
{
return $this->${4:$1};
}
@ -425,14 +445,12 @@ snippet aw
array_walk($${1:foo}, function(&$${2:v}, $${3:k}) {
$$2 = ${0};
});
# static var assign once
snippet static_var
static $${1} = null;
if (is_null($$1)){
$$1 = ${2};
}
snippet CSVWriter
<?php
@ -467,7 +485,6 @@ snippet CSVWriter
}
}
snippet CSVIterator
// http://snipplr.com/view.php?codeview&id=1986 // modified
@ -570,72 +587,75 @@ snippet CSVIterator
}
} // end class
snippet is
isset($1{VISUAL})
# phpunit
snippet ase
# phpunit
snippet ase "$this->assertEquals()"
$this->assertEquals(${1:expected}, ${2:actual});
snippet asne
snippet asne "$this->assertNotEquals()"
$this->assertNotEquals(${1:expected}, ${2:actual});
snippet asf
$this->assertFalse(${1:Something});
snippet ast
$this->assertTrue(${1:Something});
snippet asfex
$this->assertFileExists(${1:path/to/file});
snippet asfnex
$this->assertFileNotExists(${1:path/to/file});
snippet ascon
$this->assertContains(${1:Search Value}, ${2:Array or Iterator});
snippet ashk
$this->assertArrayHasKey(${1:key}, ${2:array});
snippet asnhk
this->assertArrayNotHasKey(${1:value}, ${2:array});
snippet ascha
$this->assertClassHasAttribute('${1:Attribute Name}', '${2:ClassName}');
snippet asi
snippet asf "$this->assertFalse()"
$this->assertFalse(${1});
snippet ast "$this->assertTrue()"
$this->assertTrue(${1});
snippet asfex "$this->assertFileExists()"
$this->assertFileExists(${1:'path/to/file'});
snippet asfnex "$this->assertFileNotExists()"
$this->assertFileNotExists(${1:'path/to/file'});
snippet ascon "$this->assertContains()"
$this->assertContains(${1:$needle}, ${2:$haystack});
snippet ashk "$this->assertArrayHasKey()"
$this->assertArrayHasKey(${1:$key}, ${2:$array});
snippet asnhk "$this->assertArrayNotHasKey()"
this->assertArrayNotHasKey(${1:$key}, ${2:$array});
snippet ascha "$this->assertClassHasAttribute()"
$this->assertClassHasAttribute(${1:$attributeName}, '${2:$className}');
snippet asi "$this->assertInstanceOf(...)"
$this->assertInstanceOf(${1:expected}, ${2:actual});
snippet tc
public function test${1:name_of_the_test}()
snippet test "public function testXYZ() { ... }"
public function test${1}()
{
${0:code}
${0}
}
snippet te
snippet setup "protected function setUp() { ... }"
protected function setUp()
{
${0}
}
snippet teardown "protected function tearDown() { ... }"
protected function tearDown()
{
${0}
}
snippet exp "phpunit expects"
expects($this->${1:once}())
->method('${2}')
->with($this->equalTo(${3})${4})
->will($this->returnValue(${5}));
snippet testcmt "phpunit comment with group"
/**
* @group ${1}
*/
snippet fail "$this->fail()"
$this->fail(${1});
snippet marki "$this->markTestIncomplete()"
$this->markTestIncomplete(${1});
snippet marks "$this->markTestSkipped()"
$this->markTestSkipped(${1});
# end of phpunit snippets
snippet te "throw new Exception()"
throw new ${1:Exception}("${2:Error Processing Request}");
snippet fpc "file_put_contents" b
file_put_contents(${1:file}, ${2:content}${3:, FILE_APPEND});$0
snippet sr "str_replace"
str_replace(${1:search}, ${2:replace}, ${3:subject})$0
snippet ia "in_array"
in_array(${1:needle}, ${2:haystack})$0
snippet is "isset"
isset(${1:var})$0
snippet isa "isset array"
isset($${1:array}[${2:key}])$0
snippet in "is_null"
is_null($${1:var})$0
snippet fe "file_exists"
file_exists(${1:file})$0
snippet id "is_dir"
is_dir(${1:path})$0

View File

@ -1,5 +1,7 @@
snippet enc
# encoding: utf-8
snippet frozen
# frozen_string_literal: true
snippet #!
#!/usr/bin/env ruby
# New Block

View File

@ -0,0 +1,36 @@
extends css
snippet $
$${1:variable}: ${0:value}
snippet imp
@import '${0}'
snippet mix
@mixin ${1:name}(${2})
${0}
snippet inc
@include ${1:mixin}(${2})
snippet ext
@extend ${0}
snippet fun
@function ${1:name}(${2:args})
${0}
snippet if
@if ${1:condition}
${0}
snippet ife
@if ${1:condition}
${2}
@else
${0}
snippet eif
@else if ${1:condition}
${0}
snippet for
@for ${1:$i} from ${2:1} through ${3:3}
${0}
snippet each
@each ${1:$item} in ${2:items}
${0}
snippet while
@while ${1:$i} ${2:>} ${3:0}
${0}

View File

@ -16,57 +16,57 @@ snippet dmo \DeclareMathOperator
# \begin{}...\end{}
snippet begin \begin{} ... \end{} block
\begin{${1:env}}
${0}
${0:${VISUAL}}
\end{$1}
# Tabular
snippet tab tabular (or arbitrary) environment
\begin{${1:tabular}}{${2:c}}
${0}
${0:${VISUAL}}
\end{$1}
snippet thm thm (or arbitrary) environment with optional argument
\begin[${1:author}]{${2:thm}}
${0}
${0:${VISUAL}}
\end{$2}
snippet center center environment
\begin{center}
${0}
${0:${VISUAL}}
\end{center}
# Align(ed)
snippet ali align(ed) environment
\begin{align${1:ed}}
\label{eq:${2}}
${0}
${0:${VISUAL}}
\end{align$1}
# Gather(ed)
snippet gat gather(ed) environment
\begin{gather${1:ed}}
${0}
${0:${VISUAL}}
\end{gather$1}
# Equation
snippet eq equation environment
\begin{equation}
${0}
${0:${VISUAL}}
\end{equation}
# Equation
snippet eql Labeled equation environment
\begin{equation}
\label{eq:${2}}
${0}
${0:${VISUAL}}
\end{equation}
# Equation
snippet eq* unnumbered equation environment
\begin{equation*}
${0}
${0:${VISUAL}}
\end{equation*}
# Unnumbered Equation
snippet \ unnumbered equation: \[ ... \]
\[
${0}
${0:${VISUAL}}
\]
# Equation array
snippet eqnarray eqnarray environment
\begin{eqnarray}
${0}
${0:${VISUAL}}
\end{eqnarray}
# Label
snippet lab \label
@ -90,7 +90,7 @@ snippet itemize itemize environment
\item ${0}
\end{itemize}
snippet item \item
\item ${1}
\item ${1:${VISUAL}}
# Description
snippet desc description environment
\begin{description}
@ -103,18 +103,18 @@ snippet ]i \item (recursive)
# Matrix
snippet mat smart matrix environment
\begin{${1:p/b/v/V/B/small}matrix}
${0}
${0:${VISUAL}}
\end{$1matrix}
# Cases
snippet cas cases environment
\begin{cases}
${1:equation}, &\text{ if }${2:case}\\
${0}
${0:${VISUAL}}
\end{cases}
# Split
snippet spl split environment
\begin{split}
${0}
${0:${VISUAL}}
\end{split}
# Part
snippet part document \part
@ -203,32 +203,32 @@ snippet fcite \footcite[]{}
\footcite[${1}]{${2}}${0}
#Formating text: italic, bold, underline, small capital, emphase ..
snippet it italic text
\textit{${0:text}}
\textit{${0:${VISUAL:text}}}
snippet bf bold face text
\textbf{${0:text}}
\textbf{${0:${VISUAL:text}}}
snippet under underline text
\underline{${0:text}}
\underline{${0:${VISUAL:text}}}
snippet emp emphasize text
\emph{${0:text}}
\emph{${0:${VISUAL:text}}}
snippet sc small caps text
\textsc{${0:text}}
\textsc{${0:${VISUAL:text}}}
#Choosing font
snippet sf sans serife text
\textsf{${0:text}}
\textsf{${0:${VISUAL:text}}}
snippet rm roman font text
\textrm{${0:text}}
\textrm{${0:${VISUAL:text}}}
snippet tt typewriter (monospace) text
\texttt{${0:text}}
\texttt{${0:${VISUAL:text}}}
#Math font
snippet mf mathfrak
\mathfrak{${0:text}}
\mathfrak{${0:${VISUAL:text}}}
snippet mc mathcal
\mathcal{${0:text}}
\mathcal{${0:${VISUAL:text}}}
snippet ms mathscr
\mathscr{${0:text}}
\mathscr{${0:${VISUAL:text}}}
#misc
snippet ft \footnote
\footnote{${0:text}}
\footnote{${0:${VISUAL:text}}}
snippet fig figure environment (includegraphics)
\begin{figure}
\begin{center}
@ -260,19 +260,19 @@ snippet lim \lim_{}
\lim_{${1:n \to \infty}} ${0}
snippet frame frame environment
\begin{frame}[${1:t}]{${2:title}}
${0}
${0:${VISUAL}}
\end{frame}
snippet block block environment
\begin{block}{${1:title}}
${0}
${0:${VISUAL}}
\end{block}
snippet alert alertblock environment
\begin{alertblock}{${1:title}}
${0}
${0:${VISUAL}}
\end{alertblock}
snippet example exampleblock environment
\begin{exampleblock}{${1:title}}
${0}
${0:${VISUAL}}
\end{exampleblock}
snippet col2 two-column environment
\begin{columns}
@ -301,7 +301,7 @@ snippet lra langle rangle
# Code listings
snippet lst
\begin{listing}[language=${1:language}]
${0}
${0:${VISUAL}}
\end{listing}
snippet lsi
\lstinline|${1}| ${0}

View File

@ -1,43 +1,34 @@
# twig block
snippet bl
snippet bl "{% block xyz %} .. {% endblock xyz %}"
{% block ${1} %}
${2}
{% endblock $1 %}
# twig javascripts
snippet js
snippet js "{% javascripts 'xyz' %} .. {% endjavascripts %}"
{% javascripts '${1}' %}
<script src="{{ asset_url }}"></script>
{% endjavascripts %}
# twig stylesheets
snippet css
snippet css "{% stylesheets 'xyz' %} .. {% endstylesheets %}"
{% stylesheets '${1}' %}
<link rel="stylesheet" href="{{ asset_url }}">
{% endstylesheets %}
# twig if
snippet if
snippet if "{% if %} .. {% endif %}"
{% if ${1} %}
${2}
{% endif %}
# twig if ... else
snippet ife
snippet ife "{% if %} .. {% else %} .. {% endif %}"
{% if ${1} %}
${2}
{% else %}
${0}
{% endif %}
# twig else
snippet el
snippet el "{% else %}"
{% else %}
${0}
# twig elseif
snippet eif
snippet eif "{% elseif %}"
{% elseif ${1} %}
${0}
# twig for
snippet for
snippet for "{% for x in y %} .. {% endfor %}"
{% for ${1} in ${2} %}
${3}
{% endfor %}
# twig extends
snippet ext
snippet ext "{% extends xyz %}"
{% extends ${1} %}