1
0
mirror of https://github.com/amix/vimrc synced 2025-06-16 01:25:00 +08:00

Updated plugins

This commit is contained in:
amix
2016-06-11 15:56:50 +02:00
parent cc0e8a9907
commit 0228ad0e9e
60 changed files with 1341 additions and 784 deletions

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

@ -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}
@ -81,13 +78,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 +102,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 +208,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 +269,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 +326,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,6 +382,14 @@ 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
/**
@ -425,14 +446,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 +486,6 @@ snippet CSVWriter
}
}
snippet CSVIterator
// http://snipplr.com/view.php?codeview&id=1986 // modified
@ -570,72 +588,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

@ -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} %}