1
0
mirror of https://github.com/amix/vimrc synced 2025-07-31 09:45:00 +08:00

Updated plugins

This commit is contained in:
amix
2013-08-03 14:50:12 +02:00
parent a448b32309
commit 351979d3e0
20 changed files with 603 additions and 670 deletions

View File

@ -27,46 +27,46 @@ endsnippet
snippet proto "Prototype (proto)"
${1:class_name}.prototype.${2:method_name} = function(${3:first_argument}) ,,{
${0:// body...}
};
${0}
}
endsnippet
snippet for "for (...) {...} (faster)"
for (var ${2:i} = ${1:Things}.length - 1; $2 >= 0; $2--){
${3:$1[$2]}$0
};
}
endsnippet
snippet for "for (...) {...}"
for (var ${2:i}=0; $2 < ${1:Things}.length; $2++) {
${3:$1[$2]}$0
};
}
endsnippet
snippet fun "function (fun)"
function ${1:function_name} (${2:argument}) {
${0:// body...}
${0}
}
endsnippet
# for one line if .. else you usually use a ? b : c
snippet ife "if ___ else"
if (${1}) {
{$2}
${2}
} else {
{$3}
};
${3}
}
endsnippet
snippet if "if"
if (${1}) {
{$2}
};
${2}
}
endsnippet
snippet timeout "setTimeout function"
setTimeout(function() {$0}${2:}, ${1:10});
setTimeout(function() {$0}${2:}, ${1:10})
endsnippet
# vim:ft=snippets:

View File

@ -1,258 +1,82 @@
## Snippets from SnipMate, taken from
## https://github.com/scrooloose/snipmate-snippets.git
snippet <? "php open tag" b
<?php
snippet array "array"
$${1:arrayName} = array('${2}' => ${3});${4}
endsnippet
snippet def "def"
define('${1}'${2});${3}
snippet vdd "php var_dump and die"
var_dump(${1}); die();
endsnippet
snippet do "do"
do {
${2}
} while (${1});"
snippet ns "php namespace" b
namespace ${1:`!p
abspath = os.path.abspath(path)
m = re.search(r'[A-Z].+(?=/)', abspath)
if m:
snip.rv = m.group().replace('/', '\\')
`};
endsnippet
snippet doc_f "doc_f"
snippet nc "php namespace and class" b
namespace ${1:`!p
abspath = os.path.abspath(path)
m = re.search(r'[A-Z].+(?=/)', abspath)
if m:
snip.rv = m.group().replace('/', '\\')
`};
/**
* $2
* @return ${4:void}
* @author ${5:`!v g:snips_author`}
**/
${1:public }function ${2:someFunc}(${3})
{${6}
* ${3:@author `whoami`}${4}
*/
class ${2:`!p
snip.rv = re.match(r'.*(?=\.)', fn).group()
`}
{
}
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 {
${1}
}
endsnippet
snippet for "for"
for ($${2:i} = 0; $$2 < ${1:count}; $$2${3:++}) {
snippet st "php static function" b
${1:public} static function $2($3)
{
${4}
}
endsnippet
snippet foreachk "foreachk"
foreach ($${1:variable} as $${2:key} => $${3:value}){
${4}
snippet __ "php constructor" b
${1:public} function __construct($2)
{
${3}
}
endsnippet
snippet get "get"
$_GET['${1}']${2}
snippet sg "Setter and Getter" b
/**
* @var ${3:`!p snip.rv = t[2].capitalize()`}${4}
*/
${1:protected} $$2;
public function set`!p snip.rv = t[2].capitalize()`(`!p
if re.match(r'[A-Z].*', t[3]):
snip.rv = t[3] + ' '
else:
snip.rv = ''
`$$2)
{
$this->$2 = $$2;
return $this;
}
public function get`!p snip.rv = t[2].capitalize()`()
{
return $this->$2;
}
endsnippet
snippet if "if"
snippet if "php if" !b
if (${1}) {
${2}
}
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 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
/*
* Getter for $1
*/
public function get${1/\w+\s*/\u$0/}()
{
return $this->$1;$2
}
$4
endsnippet
snippet setter "PHP Class Setter" !b
/*
* Setter for $1
*/
public function set${1/\w+\s*/\u$0/}($$1)
{
$this->$1 = $$1;$3
${4:return $this;}
}
$0
endsnippet
snippet gs "PHP Class Getter Setter" !b
protected $$1
/*
* Getter for $1
*/
public function get${1/\w+\s*/\u$0/}()
{
return $this->$1;$2
}
/*
* Setter for $1
*/
public function set${1/\w+\s*/\u$0/}($$1)
{
$this->$1 = $$1;$3
${4:return $this;}
}
$0
endsnippet
snippet pub "Public function" !b
public function ${1:name}(${2:$param})
{
${VISUAL}${3:return null;}
}
$0
endsnippet
snippet pro "Protected function" !b
protected function ${1:name}(${2:$param})
{
${VISUAL}${3:return null;}
}
$0
endsnippet
snippet pri "Private function" !b
private function ${1:name}(${2:$param})
{
${VISUAL}${3:return null;}
}
$0
endsnippet
snippet pubs "Public static function" !b
public static function ${1:name}(${2:$param})
{
${VISUAL}${3:return null;}
}
$0
endsnippet
snippet pros "Protected static function" !b
protected static function ${1:name}(${2:$param})
{
${VISUAL}${3:return null;}
}
$0
endsnippet
snippet pris "Private static function" !b
private static function ${1:name}(${2:$param})
{
${VISUAL}${3:return null;}
}
$0
endsnippet
snippet fu "Function snip" !b
function ${1:name}(${2:$param})
{
${VISUAL}${3:return null;}
}
$0
endsnippet
# :vim:ft=snippets
snippet fore "Foreach loop"
foreach ($${1:variable} as $${3:value}){
${VISUAL}${4}
}
$0
endsnippet
snippet new "New class instance" !b
$$1 = new $1($2);
$0
endsnippet
snippet ife "if else"
if (${1:/* condition */}) {
${2}
} else {
${3}
}
$0
endsnippet
snippet class "Class declaration template" !b
/**
* Class ${1:`!p snip.rv=snip.fn.capitalize().split('.')[0]`}
* @author $2
*/
class $1
{
public function ${3:__construct}(${4:$options})
{
${4}
}
}
$0
endsnippet
snippet pr "Dumb debug helper in HTML"
echo '<pre>' . var_export($1, 1) . '</pre>';$0
endsnippet
snippet pc "Dumb debug helper in cli"
var_export($1);$0
endsnippet
# Symfony 2 based snippets
snippet sfa "Symfony 2 Controller action"
/**
* @Route("/${1:route_name}", name="$1")
* @Template()
*/
public function $1Action($2)
{
$3
return ${4:array();}$0
}
endsnippet
# :vim:ft=snippets:

View File

@ -0,0 +1,75 @@
snippet contr "symfony2 controller" b
namespace `!p
abspath = os.path.abspath(path)
m = re.search(r'[A-Z].+(?=/)', abspath)
if m:
snip.rv = m.group().replace('/', '\\')
`;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;
/**
* ${1:@author `whoami`}${2}
*/
class `!p
snip.rv = re.match(r'.*(?=\.)', fn).group()
` extends Controller
{
}
endsnippet
snippet act "symfony2 action" b
/**
* @Route("${3}", name="${4}")
* @Method({${5:"GET"}})
* @Template()
*/
public function ${1}Action(${2})
{
${6}
return [];
}
endsnippet
snippet comm "symfony2 command" b
namespace `!p
abspath = os.path.abspath(path)
m = re.search(r'[A-Z].+(?=/)', abspath)
if m:
snip.rv = m.group().replace('/', '\\')
`;
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
/**
* ${3:@author `whoami`}${4}
*/
class `!p
snip.rv = re.match(r'.*(?=\.)', fn).group()
` extends ContainerAwareCommand
{
protected function configure()
{
$this
->setName('${1}')
->setDescription('${2}')
->setDefinition([
new InputArgument('', InputArgument::REQUIRED, ''),
new InputOption('', null, InputOption::VALUE_NONE, ''),
])
;
}
protected function execute(InputInterface $input, OutputInterface $output)
{
}
}
endsnippet

View File

@ -89,6 +89,11 @@ snippet doc
snippet fn
fn(${1:args}) -> ${2} end
snippet fun
function do
${1}
end
snippet mdoc
@moduledoc """
${1}

View File

@ -103,6 +103,8 @@ snippet lipp
<%= link_to "${1:Link text...}", ${2:model}s_path %>
snippet lt
<%= link_to "${1:name}", ${2:dest} %>
snippet ntc
<%= number_to_currency(${1}) %>
snippet ofcfs
<%= options_from_collection_for_select ${1:collection}, ${2:value_method}, ${3:text_method}, ${4:selected_value} %>
snippet rf

View File

@ -211,3 +211,11 @@ snippet t
# variable declaration
snippet v
var ${1:t} ${2:string}
# goroutine named function
snippet g
go ${1:funcName}(${2})
# goroutine anonymous function
snippet ga
go func(${1} ${2:type}) {
${3:/* code */}
}(${4})

View File

@ -27,4 +27,5 @@ snippet ife
snippet ifp
- if ${1:condition}.presence?
${2}
snippet ntc
= number_to_currency(${1})

View File

@ -6,8 +6,8 @@ snippet html5
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>$2</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
$3
</head>
<body>
@ -34,15 +34,15 @@ snippet idn
snippet label_and_input
<label for="${2:$1}">${1}</label>
<input type="${3:text}" name="${4:$2}" id="${5:$2}" value="${6}" />${7}
<input type="${3:text}" name="${4:$2}" id="${5:$2}" value="${6}">${7}
# FORMS
# use idn . or n to add id
snippet input
<input type="${1:text}" value="${2}" ${3}/>${7}
<input type="${1:text}" value="${2}" ${3}>${7}
snippet submit
<input type="submit" value="${2}" ${3}/>${7}
<input type="submit" value="${2}" ${3}>${7}
snippet textarea
<textarea $1>$2</textarea>
@ -61,7 +61,7 @@ snippet img
<img src="$1" alt="$2"/>
# JS/CSS
snippet css_file
<link rel="stylesheet" href="${1:style.css}" type="text/css" media="${2:all}" />${3}
<link rel="stylesheet" href="${1:style.css}" type="text/css" media="${2:all}">${3}
snippet css_block
<link rel="stylesheet" href="${1:style.css}" type="text/css" media="${2:all}">
</link>

View File

@ -0,0 +1,30 @@
snippet .attr
.attr("${1}", ${2})
snippet .style
.style("${1}", ${2})
snippet axis
d3.svg.axis()
.orient(${1})
.scale(${2})
snippet fd
function(d) { ${1} }
snippet fdi
function(d, i) { ${1} }
snippet marginconvention
var ${1:margin} = { top: ${2:10}, right: ${3:10}, bottom: ${4:10}, left: ${5:10} };
var ${6:width} = ${7:970} - $1.left - $1.right;
var ${8:height} = ${9:500} - $1.top - $1.bottom;
var ${10:svg} = d3.select("${11}").append("svg")
.attr("width", $6)
.attr("height", $8)
.append("g")
.attr("transform", "translate(" + $1.left + "," + $1.top + ")")
snippet nest
d3.nest()
.key(${1})
.entries(${2})
snippet scale
d3.scale.linear()
.domain(${1})
.range(${2})

View File

@ -185,3 +185,15 @@ snippet lc
logger.critical(${1:msg})
snippet li
logger.info(${1:msg})
snippet epydoc
"""
${1:Description}
@param ${2:param}: ${3: Description}
@type $2: ${4: Type}
@return: ${5: Description}
@rtype : ${6: Type}
@raise e: ${7: Description}
"""