This commit is contained in:
rcolombo 2015-03-04 10:42:22 -03:00
commit 083fd3ea8f
24 changed files with 1181 additions and 1156 deletions

View File

@ -205,7 +205,6 @@ to maintain snippets for a language, please get in touch.
Notes: People are interested in snippets - and their interest may wane again.
This list is kept up-to-date on a best effort basis.
* Clojure - [lpil](https://github.com/lpil)
* Elixir - [iurifq](https://github.com/iurifq)
* Falcon - [steveno](https://github.com/steveno)
* HTML Django - [honza](http://github.com/honza)

View File

@ -11,10 +11,6 @@ def ada_case(word):
out = out + word[i]
return out
def get_year():
import time
return time.strftime("%Y")
endglobal
snippet wi "with"
@ -281,44 +277,4 @@ snippet newline "Ada.Text_IO.New_Line"
Ada.Text_IO.New_Line(${1:1});$0
endsnippet
snippet gpl "GPL license header"
-- This program is free software; you can redistribute it and/or modify
-- it under the terms of the GNU ${1}General Public License as published by
-- the Free Software Foundation; either version ${2:3} of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU $1General Public License for more details.
--
-- You should have received a copy of the GNU $1General Public License
-- along with this program; if not, see <http://www.gnu.org/licenses/>.
--
-- Copyright (C) ${3:Author}, ${4:`!p snip.rv = get_year()`}
$0
endsnippet
snippet gplf "GPL file license header"
-- This file is part of ${1:Program-Name}.
--
-- $1 is free software: you can redistribute it and/or modify
-- it under the terms of the GNU ${2}General Public License as published by
-- the Free Software Foundation, either version ${3:3} of the License, or
-- (at your option) any later version.
--
-- $1 is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU $2General Public License for more details.
--
-- You should have received a copy of the GNU $2General Public License
-- along with $1. If not, see <http://www.gnu.org/licenses/>.
--
-- Copyright (C) ${4:Author}, ${5:`!p snip.rv = get_year()`}
$0
endsnippet
# vim:ft=snippets:

View File

@ -29,7 +29,7 @@ def _parse_comments(s):
if len(flags) == 0:
rv.append((text, text, text, ""))
# parse 3-part comment, but ignore those with O flag
elif flags[0] == 's' and 'O' not in flags:
elif 's' in flags and 'O' not in flags:
ctriple = []
indent = ""
@ -47,7 +47,7 @@ def _parse_comments(s):
ctriple.append(indent)
rv.append(ctriple)
elif flags[0] == 'b':
elif 'b' in flags:
if len(text) == 1:
rv.insert(0, (text,text,text, ""))
except StopIteration:
@ -78,10 +78,12 @@ endglobal
snippet box "A nice box with the current comment symbol" b
`!p
box = make_box(len(t[1]))
snip.rv = box[0] + '\n' + box[1]
snip.rv = box[0]
snip += box[1]
`${1:content}`!p
box = make_box(len(t[1]))
snip.rv = box[2] + '\n' + box[3]`
snip.rv = box[2]
snip += box[3]`
$0
endsnippet
@ -89,10 +91,12 @@ snippet bbox "A nice box over the full width" b
`!p
width = int(vim.eval("&textwidth")) or 71
box = make_box(len(t[1]), width)
snip.rv = box[0] + '\n' + box[1]
snip.rv = box[0]
snip += box[1]
`${1:content}`!p
box = make_box(len(t[1]), width)
snip.rv = box[2] + '\n' + box[3]`
snip.rv = box[2]
snip += box[3]`
$0
endsnippet

View File

@ -1,168 +0,0 @@
priority -50
snippet do
do
${1}
end
endsnippet
snippet if "if .. do .. end"
if ${1:condition} do
${2:expression}
end
endsnippet
snippet if "if .. do: .."
if ${1:condition}, do: ${2:expression}
endsnippet
snippet ife "if .. do .. else .. end"
if ${1:condition} do
${2:expression}
else
${3:expression}
end
endsnippet
snippet ife "if .. do: .. else:"
if ${1:condition}, do: ${2}, else: ${3}
endsnippet
snippet unless "unless .. do .. end"
unless ${1} do
${2}
end
endsnippet
snippet unless "unless .. do: .."
unless ${1:condition}, do: ${2}
endsnippet
snippet unlesse "unless .. do .. else .. end"
unless ${1:condition} do
${2}
else
${3}
end
endsnippet
snippet unlesse "unless .. do: .. else:"
unless ${1:condition}, do: ${2}, else: ${3}
endsnippet
snippet cond
"cond do"
${1} ->
${2}
end
endsnippet
snippet case
case ${1} do
${2} ->
${3}
end
endsnippet
snippet def
def ${1:name} do
${2}
end
endsnippet
snippet defin "def function(n), do: n"
def ${1:name}, do: ${2}
endsnippet
snippet defg
def ${1:name} when ${2:guard-condition} do
${3}
end
endsnippet
snippet defim
defimpl ${1:protocol_name}, for: ${2:data_type} do
${3}
end
endsnippet
snippet defma
defmacro ${1:name} do
${2}
end
endsnippet
snippet defmo
defmodule ${1:module_name} do
${2}
end
endsnippet
snippet defp
defp ${1:name} do
${2}
end
endsnippet
snippet defpr
defprotocol ${1:name}, [${2:function}]
endsnippet
snippet defr
defrecord ${1:record_name}, ${2:fields}
endsnippet
snippet doc
@doc """
${1}
"""
endsnippet
snippet fn
fn(${1:args}) -> ${2} end
endsnippet
snippet fun
function do
${1}
end
endsnippet
snippet mdoc
@moduledoc """
${1}
"""
endsnippet
snippet rec
receive do
${1} ->
${2}
end
endsnippet
snippet req
require ${1:module_name}
endsnippet
snippet imp
import ${1:module_name}
endsnippet
snippet ali "alias old-module to shorthand"
alias ${1:module_name}
endsnippet
snippet test
test "${1:test_name}" do
${2}
end
endsnippet
snippet try "try .. rescue .. end"
try do
${1}
rescue
${2} -> ${3}
end
endsnippet

View File

@ -5,12 +5,12 @@
priority -50
snippet pat "Case:Receive:Try Clause"
${1:pattern}${2: when ${3:guard}} ->;
${1:pattern}${2: when ${3:guard}} ->
${4:body}
endsnippet
snippet beh "Behaviour Directive"
-behaviour (${1:behaviour}).
snippet beh "Behaviour Directive" b
-behaviour(${1:behaviour}).
endsnippet
snippet case "Case Expression"
@ -20,12 +20,12 @@ case ${1:expression} of
end
endsnippet
snippet def "Define Directive"
-define (${1:macro}${2: (${3:param})}, ${4:body}).
snippet def "Define Directive" b
-define(${1:macro}${2: (${3:param})}, ${4:body}).
endsnippet
snippet exp "Export Directive"
-export ([${1:function}/${2:arity}]).
snippet exp "Export Directive" b
-export([${1:function}/${2:arity}]).
endsnippet
snippet fun "Fun Expression"
@ -36,7 +36,7 @@ end
endsnippet
snippet fu "Function"
${1:function} (${2:param})${3: when ${4:guard}} ->
${1:function}(${2:param})${3: when ${4:guard}} ->
${5:body}
endsnippet
@ -47,24 +47,24 @@ if
end
endsnippet
snippet ifdef "Ifdef Directive"
-ifdef (${1:macro}).
snippet ifdef "Ifdef Directive" b
-ifdef(${1:macro}).
endsnippet
snippet ifndef "Ifndef Directive"
-ifndef (${1:macro}).
snippet ifndef "Ifndef Directive" b
-ifndef(${1:macro}).
endsnippet
snippet imp "Import Directive"
-import (${1:module}, [${2:function}/${3:arity}]).
snippet imp "Import Directive" b
-import(${1:module}, [${2:function}/${3:arity}]).
endsnippet
snippet inc "Include Directive"
-include ("${1:file}").
snippet inc "Include Directive" b
-include("${1:file}").
endsnippet
snippet mod "Module Directive"
-module (${1:`!p snip.rv = snip.basename or "module"`}).
snippet mod "Module Directive" b
-module(${1:`!p snip.rv = snip.basename or "module"`}).
endsnippet
snippet rcv "Receive Expression"
@ -77,8 +77,8 @@ ${6:after
end
endsnippet
snippet rec "Record Directive"
-record (${1:record}, {${2:field}${3: = ${4:value}}}).
snippet rec "Record Directive" b
-record(${1:record}, {${2:field}${3: = ${4:value}}}).
endsnippet
snippet try "Try Expression"
@ -93,8 +93,16 @@ ${13:after
end
endsnippet
snippet undef "Undef Directive"
-undef (${1:macro}).
snippet undef "Undef Directive" b
-undef(${1:macro}).
endsnippet
snippet || "List Comprehension"
[${1:X} || ${2:X} <- ${3:List}${4:, gen}]
endsnippet
snippet gen "Generator Expression"
${1:X} <- ${2:List}${3:, gen}
endsnippet
# vim:ft=snippets:

View File

@ -44,66 +44,13 @@ snippet fi "<%= Fixtures.identify(:symbol) %>"
endsnippet
snippet ft "form_tag"
`!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_INLINE', snip)`form_tag(${1::action => "${5:update}"}${6:, {:${8:class} => "${9:form}"\}}) do`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)`
`!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_INLINE', snip)`form_tag(${1::action => '${5:update}'}${6:, {:${8:class} => '${9:form}'\}}) do`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)`
$0
`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_BLOCK', snip)`
endsnippet
snippet end "end (ERB)"
<% end -%>
endsnippet
snippet for "for loop (ERB)"
<% if !${1:list}.blank? %>
<% for ${2:item} in ${1} %>
$3
<% end %>
<% else %>
$4
<% end %>
endsnippet
snippet ffcb "form_for check_box"
`!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR', snip)`f.check_box :${1:attribute}`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)`
endsnippet
snippet ffff "form_for file_field 2"
`!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR', snip)`f.file_field :${1:attribute}`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)`
endsnippet
snippet ffhf "form_for hidden_field 2"
`!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR', snip)`f.hidden_field :${1:attribute}`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)`
endsnippet
snippet ffl "form_for label 2"
`!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR', snip)`f.label :${1:attribute}${2:, "${3:${1/[[:alpha:]]+|(_)/(?1: :\u$0)/g}}"}`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)`
endsnippet
snippet ffpf "form_for password_field 2"
`!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR', snip)`f.password_field :${1:attribute}`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)`
endsnippet
snippet ffrb "form_for radio_box 2"
`!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR', snip)`f.radio_box :${1:attribute}, :${2:tag_value}`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)`
endsnippet
snippet ffs "form_for submit 2"
`!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR', snip)`f.submit "${1:Submit}"${2:, :disable_with => '${3:$1ing...}'}`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)`
endsnippet
snippet ffta "form_for text_area 2"
`!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR', snip)`f.text_area :${1:attribute}`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)`
endsnippet
snippet fftf "form_for text_field 2"
`!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR', snip)`f.text_field :${1:attribute}`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)`
endsnippet
snippet fields "fields_for"
`!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_INLINE', snip)`fields_for :${1:model}, @${2:$1} do |$1|`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_INLINE', snip)`
$0
`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_BLOCK', snip)`
`!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR', snip)`${1:f}.submit '${2:Submit}'${3:, :disable_with => '${4:$2ing...}'}`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)`
endsnippet
snippet f. "f_fields_for (nff)"
@ -132,8 +79,8 @@ snippet f. "f.password_field"
`!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR', snip)`f.password_field :${1:attribute}`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)`
endsnippet
snippet f. "f.radio_box"
`!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR', snip)`f.radio_box :${1:attribute}, :${2:tag_value}`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)`
snippet f. "f.radio_button"
`!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR', snip)`f.radio_button :${1:attribute}, :${2:tag_value}`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)`
endsnippet
snippet f. "f.submit"
@ -279,10 +226,6 @@ snippet else "else (ERB)"
$0
endsnippet
snippet if "if (ERB)"
<% if ${1:condition} %>$0
endsnippet
snippet lf "link_to_function"
`!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR', snip)`link_to_function ${1:"${2:Greeting}"}, "${3:alert('Hello world!')}"$4`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)`
endsnippet

View File

@ -17,7 +17,7 @@ snippet label_and_input
endsnippet
snippet input
<input type="${1:text}" value="${2}" name="${3}"${4: id="${5:$3}}/>${7}
<input type="${1:text}" value="${2}" name="${3}"${4: id="${5:$3}"}/>${7}
endsnippet
snippet submit

View File

@ -19,49 +19,59 @@ config(function($1) {
endsnippet
snippet acont "angular controller" i
controller('${1:name}', ['${2:param_annotation}', function(${3:param}) {
controller('${1:name}', [${2}function(${2/('|")([A-Z_$]+)?\1?((, ?)$)?/$2(?3::$4)/ig}) {
$0
}]);
endsnippet
snippet aconts "angular controller with scope" i
controller('${1:name}', ['$scope', function($scope) {
controller('${1:name}', [${2:'$scope', }function(${2/('|")([A-Z_$]+)?\1?((, ?)$)?/$2(?3::$4)/ig}) {
$0
}]);
endsnippet
snippet adir "angular directive" i
directive('${1:name}', ['${2:param_annotation}', function(${3:param}) {
$0
directive('${1}', [${2}function(${2/('|")([A-Z_$]+)?\1?((, ?)$)?/$2(?3::$4)/ig}) {
return {
restrict: '${3:EA}',
link: function(scope, element, attrs) {
${0}
}
};
}]);
endsnippet
snippet adirs "angular directive with scope" i
directive('${1:name}', ['$scope', function($scope) {
$0
directive('${1}', [${2:'$scope', }function(${2/('|")([A-Z_$]+)?\1?((, ?)$)?/$2(?3::$4)/ig}) {
return {
restrict: '${3:EA}',
link: function(scope, element, attrs) {
${0}
}
};
}]);
endsnippet
snippet afact "angular factory" i
factory('${1:name}', ['${2:param_annotation}', function(${3:param}) {
factory('${1:name}', [${2}function(${2/('|")([A-Z_$]+)?\1?((, ?)$)?/$2(?3::$4)/ig}) {
$0
}]);
endsnippet
snippet afacts "angular factory with scope" i
factory('${1:name}', ['$scope', function($scope) {
factory('${1:name}', [${2:'$scope', }function(${2/('|")([A-Z_$]+)?\1?((, ?)$)?/$2(?3::$4)/ig}) {
$0
}]);
endsnippet
snippet aserv "angular service" i
service('${1:name}', ['${2:param_annotation}', function(${3:param}) {
service('${1:name}', [${2}function(${2/('|")([A-Z_$]+)?\1?((, ?)$)?/$2(?3::$4)/ig}) {
$0
}]);
endsnippet
snippet aservs "angular service" i
service('${1:name}', ['$scope', function($scope) {
service('${1:name}', [${2:'$scope', }function(${2/('|")([A-Z_$]+)?\1?((, ?)$)?/$2(?3::$4)/ig}) {
$0
}]);
endsnippet

View File

@ -102,44 +102,53 @@ var_export(${1});${2}
endsnippet
snippet getter "PHP Class Getter" b
/*
/**
* Getter for $1
*
* ${2:return string}
*/
public function get${1/\w+\s*/\u$0/}()
{
return $this->$1;$2
return $this->$1;$3
}
$4
endsnippet
snippet setter "PHP Class Setter" b
/*
/**
* Setter for $1
*
* @param ${2:string} $$1
* @return ${3:`!p snip.rv=snip.basename`}
*/
public function set${1/\w+\s*/\u$0/}($$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;$3
${4:return $this;}
$this->$1 = $$1;$5
${6:return $this;}
}
$0
endsnippet
snippet gs "PHP Class Getter Setter" b
/*
/**
* Getter for $1
*
* return ${2:string}
*/
public function get${1/\w+\s*/\u$0/}()
{
return $this->$1;$2
return $this->$1;$3
}
/*
/**
* Setter for $1
*
* @param $2 $$1
* @return ${4:`!p snip.rv=snip.basename`}
*/
public function set${1/\w+\s*/\u$0/}($$1)
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)
{
$this->$1 = $$1;$3
${4:return $this;}
$this->$1 = $$1;$6
${7:return $this;}
}
$0
endsnippet
@ -251,36 +260,55 @@ if (${1:/* condition */}) {
$0
endsnippet
snippet class "Class declaration template" b
/**
* Class ${2:`!p snip.rv=snip.fn.split('.')[0]`}
* @author ${3:`!v g:snips_author`}
*/
$1class $2
{
public function ${4:__construct}(${5:$options})
{
${6:// code}
}
}
$0
snippet ns "namespace declaration" 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 interface "interface declaration template" b
snippet class "Class declaration template" b
<?php
namespace ${1:`!p
abspath = os.path.abspath(path)
m = re.search(r'[A-Z].+(?=/)', abspath)
if m:
snip.rv = m.group().replace('/', '\\')
`};
/**
* Interface ${1:`!p snip.rv=snip.fn.split('.')[0]`}
* Class ${1:`!p snip.rv=snip.basename`}
* @author ${2:`!v g:snips_author`}
*/
class $1
{
}
endsnippet
snippet interface "Interface declaration template" b
<?php
namespace ${1:`!p
abspath = os.path.abspath(path)
m = re.search(r'[A-Z].+(?=/)', abspath)
if m:
snip.rv = m.group().replace('/', '\\')
`};
/**
* Interface ${1:`!p snip.rv=snip.basename`}
* @author ${2:`!v g:snips_author`}
*/
interface $1
{
public function ${3:__construct}(${4:$options})
{
${5:// code}
}
public function ${3:someFunction}();$4
}
$0
endsnippet
snippet construct "__construct()" b
/**
* @param $2mixed ${1/, /\n * \@param mixed /g}

View File

@ -0,0 +1,257 @@
#resource controller
snippet l_rsc "Laravel resource controller" b
/*!
* \class ${1:`!v expand('%:t:r')`}
*
* \author ${2:`!v g:snips_author`}
* \date `!v strftime('%d-%m-%y')`
*/
class $1 extends ${3: BaseController} {
function __construct() {
${4}
}
public function index() {
}
public function create() {
}
public function store($id) {
}
public function show($id) {
}
public function edit($id) {
}
public function update($id) {
}
public function destroy($id) {
}
}
endsnippet
#service service provider
snippet l_ssp "Laravel service provider for service" b
/*!
* \namespace ${1:Services}
* \class ${2:`!v expand('%:t:r')`}
*
* \author ${3:`!v g:snips_author`}
* \date `!v strftime('%d-%m-%y')`
*/
namespace $1;
use Illuminate\Support\ServiceProvider;
class $2 extends ServiceProvider {
public function register() {
$this->app->bind('${4}Service', function ($app) {
return new ${5}(
$app->make('Repositories\\${6}Interface')
);
});
}
}
endsnippet
#repository service provider
snippet l_rsp "Laravel service provider for repository" b
/*!
* \namespace ${2:Repositories\\${1:}}
* \class ${3:`!v expand('%:t:r')`}
*
* \author ${4:`!v g:snips_author`}
* \date `!v strftime('%d-%m-%y')`
*/
namespace $2;
use Entities\\$1;
use $2\\$1Repository;
use Illuminate\Support\ServiceProvider;
class $3 extends ServiceProvider {
/*!
* \var defer
* \brief Defer service
*/
protected $defer = ${5:true};
public function register() {
$this->app->bind('$2\\$1Interface', function($app) {
return new $1Repository(new $1());
});
}
/*!
* \brief If $defer == true need this fn
*/
public function provides() {
return ['$2\\$1Interface'];
}
}
endsnippet
#model
snippet l_md "Laravel simple model" b
/*!
* \namespace ${1:Entities}
* \class ${2:`!v expand('%:t:r')`}
*
* \author ${3:`!v g:snips_author`}
* \date `!v strftime('%d-%m-%y')`
*/
namespace $1;
class $2 extends \Eloquent {
protected $table = '${4:`!p snip.rv = t[2].lower()`}';
public $timestamps = ${5:false};
protected $hidden = array(${6});
protected $guarded = array(${7:'id'});
}
endsnippet
#abstract repository
snippet l_ar "Laravel abstract Repository" b
/*!
* \namespace ${1:Repositories}
* \class ${2:`!v expand('%:t:r')`}
* \implements ${3:BaseRepositoryInterface}
*
* \author ${4:`!v g:snips_author`}
* \date `!v strftime('%d-%m-%y')`
*/
namespace $1;
use Illuminate\Database\Eloquent\Model;
abstract class $2 implements $3 {
protected $model;
/*!
* \fn __construct
*
* \brief Take the model
*/
public function __construct(Model $model) {
$this->model = $model;
}
/*!
* \fn all
*
* \return Illuminate\Database\Eloquent\Collection
*/
public function all($columns = array('*')) {
return $this->model->all()->toArray();
}
/*!
* \fn create
*
* \return Illuminate\Database\Eloquent\Model
*/
public function create(array $attributes) {
return $this->model->create($attributes);
}
/*!
* \fn destroy
*
* \return int
*/
public function destroy($ids) {
return $this->model->destroy($ids);
}
/*!
* \fn find
*
* \return mixed
*/
public function find($id, $columns = array('*')) {
return $this->model->find($id, $columns);
}
}
endsnippet
#repository
snippet l_r "Laravel Repository" b
/*!
* \namespace ${1:Repositories\\${2}}
* \class ${3:`!v expand('%:t:r')`}
* \implements ${4:$3RepositoryInterface}
*
* \author ${5:`!v g:snips_author`}
* \date `!v strftime('%d-%m-%y')`
*/
namespace $1;
class $3 extends \\${6} implements $4 {
${7}
}
endsnippet
#service
snippet l_s "Laravel Service" b
/*!
* \namespace ${1:Services}
* \class ${2:`!v expand('%:t:r')`}
*
* \author ${3:`!v g:snips_author`}
* \date `!v strftime('%d-%m-%y')`
*/
namespace $1;
use ${4:Repositories\\${5:Interface}};
class $2 {
protected $${6:repo};
/*!
* \fn __construct
*/
public function __construct($5 $repo) {
$this->$6 = $repo;
}
}
endsnippet
#facade
snippet l_f "Laravel Facade" b
/*!
* \namespace ${1:Services}
* \class ${2:`!v expand('%:t:r')`}
*
* \author ${3:`!v g:snips_author`}
* \date `!v strftime('%d-%m-%y')`
*/
namespace $1;
use \Illuminate\Support\Facades\Facade;
class $2 extends Facade {
/*!
* \fn getFacadeAccessor
*
* \return string
*/
protected static function getFacadeAccessor() { return '${5:${4}Service}'; }
}
endsnippet

View File

@ -10,43 +10,6 @@ fn ${1:function_name}(${2})${3/..*/ -> /}${3} {
}
endsnippet
snippet test "Test function" b
#[test]
fn ${1:test_function_name}() {
${VISUAL}${0}
}
endsnippet
snippet bench "Bench function" b
#[bench]
fn ${1:bench_function_name}(b: &mut test::Bencher) {
b.iter(|| {
${VISUAL}${0}
})
}
endsnippet
snippet new "A new function" b
pub fn new(${2}) -> ${1:Name} {
${VISUAL}${0}return $1 { ${3} };
}
endsnippet
snippet main "The main function" b
pub fn main() {
${VISUAL}${0}
}
endsnippet
snippet let "A let statement" b
let ${1:name}${3} = ${VISUAL}${2};
endsnippet
snippet lmut "let mut = .." b
let mut ${1:name}${3} = ${VISUAL}${2};
endsnippet
snippet pri "print!(..)" b
print!("${1}"${2/..*/, /}${2});
endsnippet
@ -67,130 +30,22 @@ macro_rules! ${1:name} (
)
endsnippet
snippet ec "extern crate ..." b
extern crate ${1:sync};
endsnippet
snippet ecl "...extern crate log;" b
#![feature(phase)]
#[phase(plugin, link)] extern crate log;
endsnippet
snippet mod "A module" b
mod ${1:`!p snip.rv = snip.basename.lower() or "name"`} {
${VISUAL}${0}
}
endsnippet
snippet crate "Create header information" b
// Crate name
#![crate_name = "${1:crate_name}"]
// Additional metadata attributes
#![desc = "${2:Descrption.}"]
#![license = "${3:BSD}"]
#![comment = "${4:Comment.}"]
// Specify the output type
#![crate_type = "${5:lib}"]
endsnippet
snippet allow "#[allow(..)]" b
#[allow(${1:unused_variable})]
endsnippet
snippet feat "#![feature(..)]" b
#![feature(${1:macro_rules})]
endsnippet
snippet der "#[deriving(..)]" b
#[deriving(${1:Show})]
endsnippet
snippet attr "#[..]" b
#[${1:inline}]
endsnippet
snippet opt "Option<..>"
Option<${1:int}>
endsnippet
snippet res "Result<.., ..>"
Result<${1:int}, ${2:()}>
endsnippet
snippet if "if .. (if)" b
if ${1} {
${VISUAL}${0}
}
endsnippet
snippet el "else .. (el)"
else {
${VISUAL}${0}
}
endsnippet
snippet eli "else if .. (eli)"
else if ${1} {
${VISUAL}${0}
}
endsnippet
snippet ife "if .. else (ife)"
if ${1} {
${2}
} else {
${3}
}
endsnippet
snippet mat "match"
match ${1} {
${2} => ${3},
}
endsnippet
snippet loop "loop {}" b
loop {
${VISUAL}${0}
}
endsnippet
snippet while "while .. {}" b
while ${1} {
${VISUAL}${0}
}
endsnippet
snippet for "for .. in .." b
for ${1:i} in ${2:range(0u, 10)} {
for ${1:i} in ${2:${3:0us}..${4:10}} {
${VISUAL}${0}
}
endsnippet
snippet spawn "spawn(proc() { .. });" b
spawn(proc() {
${VISUAL}${0}
});
endsnippet
snippet chan "A channel" b
let (${1:tx}, ${2:rx}): (Sender<${3:int}>, Receiver<${4:int}>) = channel();
endsnippet
snippet duplex "Duplex stream" b
let (${1:from_child}, ${2:to_child}) = sync::duplex();
endsnippet
snippet todo "A Todo comment"
// [TODO]: ${1:Description} - `!v strftime("%Y-%m-%d %I:%M%P")`
endsnippet
snippet fixme "FIXME comment"
// FIXME: ${1}
endsnippet
snippet st "Struct" b
struct ${1:`!p snip.rv = snip.basename.title() or "Name"`} {
${VISUAL}${0}
@ -211,42 +66,4 @@ impl $1 {
}
endsnippet
snippet enum "An enum" b
enum ${1:Name} {
${VISUAL}${0},
}
endsnippet
snippet type "A type" b
type ${1:NewName} = ${VISUAL}${0};
endsnippet
snippet imp "An impl" b
impl ${1:Name} {
${VISUAL}${0}
}
endsnippet
snippet drop "Drop implementation" b
impl Drop for ${1:Name} {
fn drop(&mut self) {
${VISUAL}${0}
}
}
endsnippet
snippet trait "Trait definition" b
trait ${1:Name} {
${VISUAL}${0}
}
endsnippet
snippet ss "A static string."
static ${1}: &'static str = "${VISUAL}${0}";
endsnippet
snippet stat "A static variable."
static ${1}: ${2:uint} = ${VISUAL}${0};
endsnippet
# vim:ft=snippets:

View File

@ -29,7 +29,6 @@ snippet GPL2
You should have received a copy of the GNU General Public License
along with this program; if not, see <http://www.gnu.org/licenses/>.
${0}
snippet LGPL2
${1:One line to give the program's name and a brief description.}
@ -47,7 +46,6 @@ snippet LGPL2
You should have received a copy of the GNU Lesser General Public License
along with this library; if not, see <http://www.gnu.org/licenses/>.
${0}
snippet GPL3
${1:one line to give the program's name and a brief description.}
@ -65,7 +63,6 @@ snippet GPL3
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
${0}
snippet LGPL3
${1:One line to give the program's name and a brief description.}
@ -83,7 +80,6 @@ snippet LGPL3
You should have received a copy of the GNU Lesser General Public License
along with this library; if not, see <http://www.gnu.org/licenses/>.
${0}
snippet AGPL3
${1:one line to give the program's name and a brief description.}
@ -101,6 +97,14 @@ snippet AGPL3
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
${0}
snippet GMGPL linking exception
As a special exception, if other files instantiate generics from
this unit, or you link this unit with other files to produce an
executable, this unit does not by itself cause the resulting
executable to be covered by the GNU General Public License.
This exception does not however invalidate any other reasons why the
executable file might be covered by the GNU Public License.
${0}
snippet BSD2
@ -131,7 +135,6 @@ snippet BSD2
The views and conclusions contained in the software and documentation
are those of the authors and should not be interpreted as representing
official policies, either expressedor implied, of $2.
${0}
snippet BSD3
${1:one line to give the program's name and a brief description}
@ -159,7 +162,6 @@ snippet BSD3
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
${0}
snippet BSD4
${1:one line to give the program's name and a brief description}
@ -190,7 +192,6 @@ snippet BSD4
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
${0}
snippet MIT
${1:one line to give the program's name and a brief description}
@ -213,7 +214,6 @@ snippet MIT
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
${0}
snippet APACHE
${1:one line to give the program's name and a brief description}
@ -230,7 +230,6 @@ snippet APACHE
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
${0}
snippet BEERWARE
${1:one line to give the program's name and a brief description}
@ -240,7 +239,6 @@ snippet BEERWARE
$2 wrote this file. As long as you retain this notice you
can do whatever you want with this stuff. If we meet some day, and you think
this stuff is worth it, you can buy me a beer or coffee in return
${0}
snippet WTFPL
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
@ -262,5 +260,4 @@ snippet MPL2
This Source Code Form is subject to the terms of the Mozilla Public
License, v. 2.0. If a copy of the MPL was not distributed with this
file, You can obtain one at http://mozilla.org/MPL/2.0/.
${0}

View File

@ -215,41 +215,3 @@ snippet getl Ada.Text_IO.Get_Line
snippet newline Ada.Text_IO.New_Line
Ada.Text_IO.New_Line(${1:1});${0}
snippet gpl GPL license header
-- This program is free software; you can redistribute it and/or modify
-- it under the terms of the GNU ${1}General Public License as published by
-- the Free Software Foundation; either version ${2:3} of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU $1General Public License for more details.
--
-- You should have received a copy of the GNU $1General Public License
-- along with this program; if not, see <http://www.gnu.org/licenses/>.
--
-- Copyright (C) ${3:Author}, ${4:`strftime("%Y")`}
${0}
snippet gplf GPL file license header
-- This file is part of ${1:Program-Name}.
--
-- $1 is free software: you can redistribute it and/or modify
-- it under the terms of the GNU ${2}General Public License as published by
-- the Free Software Foundation, either version ${3:3} of the License, or
-- (at your option) any later version.
--
-- $1 is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU $2General Public License for more details.
--
-- You should have received a copy of the GNU $2General Public License
-- along with $1. If not, see <http://www.gnu.org/licenses/>.
--
-- Copyright (C) ${4:Author}, ${5:`strftime("%Y")`}
${0}

102
snippets/awk.snippets Normal file
View File

@ -0,0 +1,102 @@
# cannot use /usr/bin/env because it does not support parameters (as -f)
snippet #! #!/usr/bin/awk -f
#!/usr/bin/awk -f
# @include is a gawk extension
snippet inc @include
@include "${1}"${0}
# @load is a gawk extension
snippet loa @load
@load "${1}"${0}
snippet beg BEGIN { ... }
BEGIN {
${0}
}
# BEGINFILE is a gawk extension
snippet begf BEGINFILE { ... }
BEGINFILE {
${0}
}
snippet end END { ... }
END {
${0}
}
# ENDFILE is a gawk extension
snippet endf ENDFILE { ... }
ENDFILE {
${0}
}
snippet pri print
print ${1:"${2}"}${0}
snippet printf printf
printf("${1:%s}\n", ${2})${0}
snippet ign IGNORECASE
IGNORECASE = ${1:1}
snippet if if {...}
if (${1}) {
${0}
}
snippet ife if ... else ...
if (${1}) {
${2}
} else {
${0}
}
snippet eif else if ...
else if (${1}) {
${0}
}
snippet el else {...}
else {
${0}
}
snippet wh while
while (${1}) {
${2}
}
snippet do do ... while
do {
${0}
} while (${1})
snippet for for
for (${2:i} = 0; i < ${1:n}; ${3:++i}) {
${0}
}
snippet fore for each
for (${1:i} in ${2:array}) {
${0}
}
# the switch is a gawk extension
snippet sw switch
switch (${1}) {
case ${2}:
${3}
break
default:
${0}
break
}
# the switch is a gawk extension
snippet case case
case ${1}:
${0}
break

View File

@ -0,0 +1,6 @@
snippet %
<% ${0} %>
snippet =
<%= ${1} %>
snippet end
<% end %>

View File

@ -6,7 +6,7 @@ snippet if if .. do .. end
if ${1} do
${0}
end
snippet if if .. do: ..
snippet if: if .. do: ..
if ${1:condition}, do: ${0}
snippet ife if .. do .. else .. end
if ${1:condition} do
@ -14,13 +14,13 @@ snippet ife if .. do .. else .. end
else
${0}
end
snippet ife if .. do: .. else:
snippet ife: if .. do: .. else:
if ${1:condition}, do: ${2}, else: ${0}
snippet unless unless .. do .. end
unless ${1} do
${0}
end
snippet unless unless .. do: ..
snippet unless: unless .. do: ..
unless ${1:condition}, do: ${0}
snippet unlesse unless .. do .. else .. end
unless ${1:condition} do
@ -28,17 +28,17 @@ snippet unlesse unless .. do .. else .. end
else
${0}
end
snippet unlesse unless .. do: .. else:
snippet unlesse: unless .. do: .. else:
unless ${1:condition}, do: ${2}, else: ${0}
snippet cond
cond do
${1} ->
${0}
${1} ->
${0}
end
snippet case
case ${1} do
${2} ->
${0}
${2} ->
${0}
end
snippet df
def ${1:name}, do: ${2}
@ -46,6 +46,13 @@ snippet def
def ${1:name} do
${0}
end
snippet defd
@doc """
${1:doc string}
"""
def ${2:name} do
${0}
end
snippet defim
defimpl ${1:protocol_name}, for: ${2:data_type} do
${0}
@ -71,7 +78,7 @@ snippet doc
${0}
"""
snippet fn
fn(${1:args}) -> ${0} end
fn ${1:args} -> ${0} end
snippet fun
function do
${0}
@ -95,9 +102,16 @@ snippet test
test "${1:test_name}" do
${0}
end
snippet testa
test "${1:test_name}", %{${2:arg: arg}} do
${0}
end
snippet try try .. rescue .. end
try do
${1}
rescue
${2} -> ${0}
end
snippet pry
require IEx; IEx.pry
${0}

View File

@ -173,6 +173,9 @@ snippet main
# new
snippet nw
new(${0:type})
# package
snippet pa
package ${1:main}
# panic
snippet pn
panic("${0:msg}")

View File

@ -15,6 +15,11 @@ snippet f
function(${1}) {
${0}
}
# Anonymous Function assigned to variable
snippet vaf
var ${1:function_name} = function(${2}) {
${0}
};
# Function assigned to variable
snippet vf
var ${1:function_name} = function $1(${2}) {
@ -112,8 +117,8 @@ snippet fori
# Object Method
snippet :f
${1:method_name}: function (${2:attribute}) {
${0}
}${3:,}
${3}
},
# hasOwnProperty
snippet has
hasOwnProperty(${0})

View File

@ -75,6 +75,8 @@ snippet ===
`repeat('=', strlen(getline(line(".") - 1)) - strlen(getline('.')))`
${0}
snippet -
- ${0}
snippet ---
`repeat('-', strlen(getline(line(".") - 1)) - strlen(getline('.')))`

View File

@ -90,7 +90,7 @@ snippet class
${0}
}
snippet node
node '${1:`vim_snippets#Filename('', 'fqdn')`}' {
node "${1:`vim_snippets#Filename('', 'fqdn')`}" {
${0}
}
snippet case
@ -107,13 +107,21 @@ snippet if
if $${1:variable} {
${0}
}
snippet ifd
if defined(${1:Resource}["${2:name}"]) {
${0}
}
snippet ifnd
if !defined(${1:Resource}["${2:name}"]) {
${0}
}
snippet el
else {
${0}
}
snippet ?
? {
'${1}' => ${0}
"${1}" => ${0}
}
#
# blocks etc and general syntax sugar
@ -122,98 +130,98 @@ snippet [
snippet >
${1} => ${0}
snippet p:
'puppet://puppet/${1:module name}/${0:file name}'
"puppet://puppet/${1:module name}/${0:file name}"
#
# Functions
snippet alert
alert('${1:message}')
alert("${1:message}")
snippet crit
crit('${1:message}')
crit("${1:message}")
snippet debug
debug('${1:message}')
debug("${1:message}")
snippet defined
defined(${1:Resource}['${2:name}'])
defined(${1:Resource}["${2:name}"])
snippet emerg
emerg('${1:message}')
emerg("${1:message}")
snippet extlookup Simple extlookup
extlookup('${1:variable}')
extlookup("${1:variable}")
snippet extlookup Extlookup with defaults
extlookup('${1:variable}', '${2:default}')
extlookup("${1:variable}", "${2:default}")
snippet extlookup Extlookup with defaults and custom data file
extlookup('${1:variable}', '${2:default}', '${3:data source}')
extlookup("${1:variable}", "${2:default}", "${3:data source}")
snippet fail
fail('${1:message}')
fail("${1:message}")
snippet info
info('${1:message}')
info("${1:message}")
snippet inline_template
inline_template('<%= ${1} %>')
inline_template("<%= ${1} %>")
snippet notice
notice('${1:message}')
notice("${1:message}")
snippet realize
realize(${1:Resource}[${2:name}])
snippet regsubst
regsubst(${1:hay stack}, ${2:needle}, '${3:replacement}')
regsubst(${1:hay stack}, ${2:needle}, "${3:replacement}")
snippet inc
include ${1:classname}
snippet split
split(${1:hay stack}, '${2:patten}')
split(${1:hay stack}, "${2:patten}")
snippet versioncmp
versioncmp('${1:version}', '${2:version}')
versioncmp("${1:version}", "${2:version}")
snippet warning
warning('${1:message}')
warning("${1:message}")
#
# Types
snippet cron
cron { '${1:name}':
command => '${2}',
user => '${3:root}',
cron { "${1:name}":
command => "${2}",
user => "${3:root}",
${4} => ${0},
}
snippet exec
exec { '${1:name}':
command => '${2:$1}',
user => '${3:root}',
exec { "${1:name}":
command => "${2:$1}",
user => "${3:root}",
${4} => ${0},
}
snippet user
user { '${1:user}':
user { "${1:user}":
ensure => present,
comment => '${2:$1}',
comment => "${2:$1}",
managehome => true,
home => '${0:/home/$1}',
home => "${0:/home/$1}",
}
snippet group
group { '${1:group}':
group { "${1:group}":
ensure => ${0:present},
}
snippet host
host { '${1:hostname}':
host { "${1:hostname}":
ip => ${0:127.0.0.1},
}
snippet mailalias
mailalias { '${1:localpart}':
recipient => '${0:recipient}',
mailalias { "${1:localpart}":
recipient => "${0:recipient}",
}
snippet mount
mount { '${1:destination path}':
mount { "${1:destination path}":
ensure => ${2:mounted},
device => '${0:device name or path}',
device => "${0:device name or path}",
}
snippet package
package { '${1:package name}':
package { "${1:package name}":
ensure => ${0:present},
}
snippet yumrepo
yumrepo { '${1:repo name}':
Descr => '${2:$1}',
yumrepo { "${1:repo name}":
Descr => "${2:$1}",
enabled => ${0:1},
}
@ -223,22 +231,39 @@ snippet define
}
snippet service
service { '${1:service}' :
service { "${1:service}" :
ensure => running,
enable => true,
require => [ Package['${2:package}'], File['${3:file}'], ],
subscribe => [ File['${4:configfile1}'], File['${5:configfile2}'], Package['${6:package}'], ],
require => [ Package["${2:package}"], File["${3:file}"], ],
subscribe => [ File["${4:configfile1}"], File["${5:configfile2}"], Package["${6:package}"], ],
}
snippet file
file { '${1:filename}' :
file { "${1:filename}" :
ensure => ${2:present},
owner => '${3:root}',
group => '${4:root}',
mode => '${5:0644}',
source => 'puppet:///modules/${6:module}/${7:source}',
content => template('/etc/puppet/templates/${8:template}'),
alias => '${9:alias}',
require => [ Package['${10:package}'], File['${11:file}'], ],
owner => "${3:root}",
group => "${4:root}",
mode => "${5:0644}",
source => "puppet:///modules/${6:module}/${7:source}",
content => template("${8:module}/${9:template}"),
alias => "${10:alias}",
require => [ Package["${11:package}"], File["${12:file}"], ],
}
snippet archive
archive { "${1:filename}" :
ensure => ${2:present},
url => "http://${3:url}",
extension => "${4:tgz}",
target => "${5:target}",
checksum => ${6:false},
src_target => "${7:/tmp}",
}
snippet firewall
firewall { "${1:comment}" :
proto => ${2:tcp},
action => ${3:accept},
port => ${4},
}

View File

@ -129,9 +129,19 @@ snippet pdb
# ipython debugger (ipdb)
snippet ipdb
import ipdb; ipdb.set_trace()
# embed ipython itself
snippet iem
import IPython; IPython.embed()
# ipython debugger (pdbbb)
snippet pdbbb
import pdbpp; pdbpp.set_trace()
# remote python debugger (rpdb)
snippet rpdb
import rpdb; rpdb.set_trace()
# python_prompt_toolkit
snippet ppt
from prompt_toolkit.contrib.repl import embed
embed(globals(), locals(), vi_mode=${1:default=False}, history_filename=${2:default=None})
# python console debugger (pudb)
snippet pudb
import pudb; pudb.set_trace()
@ -208,3 +218,9 @@ snippet kwg
self.${1:var_name} = kwargs.get('$1', ${2:None})
snippet lkwg
${1:var_name} = kwargs.get('$1', ${2:None})
snippet args
*args${1:,}${0}
snippet kwargs
**kwargs${1:,}${0}
snippet akw
*args, **kwargs${1:,}${0}

View File

@ -4,11 +4,7 @@
# Functions
snippet fn
fn ${1:function_name}(${2}) {
${0}
}
snippet fn-
fn ${1:function_name}(${2}) -> ${3} {
fn ${1:function_name}(${2})${3} {
${0}
}
snippet test
@ -16,6 +12,13 @@ snippet test
fn ${1:test_function_name}() {
${0}
}
snippet bench "Bench function" b
#[bench]
fn ${1:bench_function_name}(b: &mut test::Bencher) {
b.iter(|| {
${0}
})
}
snippet new
pub fn new(${2}) -> ${1:Name} {
${0}return $1 { ${3} };
@ -25,7 +28,9 @@ snippet main
${0}
}
snippet let
let ${1:name}${3} = ${2};
let ${1:name: type} = ${2};
snippet let
let mut ${1:name: type} = ${2};
snippet pln
println!("${1}");
snippet pln,
@ -52,25 +57,48 @@ snippet allow
#[allow(${1:unused_variable})]
snippet feat
#![feature(${1:macro_rules})]
snippet der "#[deriving(..)]" b
#[deriving(${1:Show})]
snippet attr "#[..]" b
#[${1:inline}]
# Common types
snippet opt
Option<${1:int}>
snippet res
Result<${1:~str}, ${2:()}>
snippet if
if ${1:/* condition */} {
if ${1} {
${0}
}
snippet ife
if ${1} {
${2}
} else {
${0}
}
snippet el
else {
${0}
}
snippet eli
else if ${1} {
${0}
}
snippet mat
match ${1} {
${2} => ${3},
}
snippet loop "loop {}" b
loop {
${0}
}
snippet while
while ${1:condition} {
${0}
}
snippet for
for ${1:i} in ${2:range(0u, 10)} {
for ${1:i} in ${2:0u..10} {
${0}
}
snippet spawn
@ -83,12 +111,19 @@ snippet duplex
let (${1:from_child}, ${2:to_child}) = sync::duplex();
# TODO commenting
snippet todo
// [TODO]: ${1:Description}
// [TODO]: ${0:Description}
snippet fixme "FIXME comment"
// FIXME: $0
# Struct
snippet st
struct ${1:`substitute(vim_snippets#Filename(), '\(_\|^\)\(.\)', '\u\2', 'g')`} {
${0}
}
snippet stn
struct ${1:`substitute(vim_snippets#Filename(), '\(_\|^\)\(.\)', '\u\2', 'g')`} {
${0}
}
impl $1 {
pub fn new(${2}) -> $1 {
@ -97,9 +132,11 @@ snippet st
};
}
}
snippet typ
type ${1:NewName} = $0;
# Enum
snippet enum
enum ${1:enum_name} {
enum ${1:Name} {
${0},
}
# Impl
@ -122,4 +159,4 @@ snippet trait
snippet ss
static ${1}: &'static str = "${0}";
snippet stat
static ${1}: ${2:uint} = ${0};
static ${1}: ${2:usize} = ${0};

View File

@ -1,5 +1,8 @@
# Shebang. Executing bash via /usr/bin/env makes scripts more portable.
snippet #!
#!/usr/bin/env sh
snippet bash
#!/usr/bin/env bash
snippet if
@ -51,15 +54,12 @@ snippet getopt
#===============================================================================
function usage ()
{
cat <<- EOT
echo "Usage : $${0:0} [options] [--]
Usage : $${0:0} [options] [--]
Options:
-h|help Display this message
-v|version Display script version"
Options:
-h|help Display this message
-v|version Display script version
EOT
} # ---------- end of function usage ----------
#-----------------------------------------------------------------------
@ -74,7 +74,7 @@ snippet getopt
v|version ) echo "$${0:0} -- Version $__ScriptVersion"; exit 0 ;;
\? ) echo -e "\n Option does not exist : $OPTARG\n"
* ) echo -e "\n Option does not exist : $OPTARG\n"
usage; exit 1 ;;
esac # --- end of case ---
@ -82,11 +82,13 @@ snippet getopt
shift $(($OPTIND-1))
snippet root
if [ \$(id -u) -ne 0 ]; then exec sudo \$0; fi
snippet fun
snippet fun-sh
${1:function_name}() {
${0:#function_body}
}
snippet ffun
snippet fun
function ${1:function_name}() {
${0:#function_body}
}

File diff suppressed because it is too large Load Diff