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

Updated vimrc

This commit is contained in:
amix
2015-07-13 11:22:46 +01:00
parent 9a2843c2a5
commit d7752b59ae
301 changed files with 4699 additions and 7969 deletions

View File

@ -0,0 +1,8 @@
language: c
sudo: false
notifications:
email: false
script:
- ./tests.sh

View File

@ -1,6 +1,8 @@
snipMate & UltiSnip Snippets
============================
[![Build Status](https://travis-ci.org/honza/vim-snippets.svg)](https://travis-ci.org/honza/vim-snippets)
This repository contains snippets files for various programming languages.
It is community-maintained and many people have contributed snippet files and
@ -205,7 +207,7 @@ 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.
* Elixir - [iurifq](https://github.com/iurifq)
* Elixir - [lpil](https://github.com/lpil), [iurifq](https://github.com/iurifq)
* Falcon - [steveno](https://github.com/steveno)
* HTML Django - [honza](http://github.com/honza)
* Javascript - [honza](http://github.com/honza)

View File

@ -89,7 +89,8 @@ endsnippet
snippet bbox "A nice box over the full width" b
`!p
width = int(vim.eval("&textwidth")) or 71
if not snip.c:
width = int(vim.eval("&textwidth - (virtcol('.') == 1 ? 0 : virtcol('.'))")) or 71
box = make_box(len(t[1]), width)
snip.rv = box[0]
snip += box[1]

View File

@ -46,15 +46,13 @@ int main(int argc, char *argv[])
endsnippet
snippet for "for loop (for)"
for (${2:i} = 0; $2 < ${1:count}; ${3:++$2})
{
for (${2:i} = 0; $2 < ${1:count}; ${3:++$2}) {
${VISUAL}${0}
}
endsnippet
snippet fori "for int loop (fori)"
for (${4:int} ${2:i} = 0; $2 < ${1:count}; ${3:++$2})
{
for (${4:int} ${2:i} = 0; $2 < ${1:count}; ${3:++$2}) {
${VISUAL}${0}
}
endsnippet
@ -99,43 +97,18 @@ snippet fprintf "fprintf ..."
fprintf(${1:stderr}, "${2:%s}\n"${2/([^%]|%%)*(%.)?.*/(?2:, :\);)/}$3${2/([^%]|%%)*(%.)?.*/(?2:\);)/}
endsnippet
snippet if "if .. (if)"
if (${1:/* condition */})
{
${VISUAL}${0}
}
endsnippet
snippet el "else .. (else)"
else {
${VISUAL}${0}
}
endsnippet
snippet eli "else if .. (eli)"
else if (${1:/* condition */}) {
${VISUAL}${0}
}
endsnippet
snippet ife "if .. else (ife)"
if (${1:/* condition */})
{
${2}
}
else
{
${3:/* else */}
}
endsnippet
snippet printf "printf .. (printf)"
printf("${1:%s}\n"${1/([^%]|%%)*(%.)?.*/(?2:, :\);)/}$2${1/([^%]|%%)*(%.)?.*/(?2:\);)/}
endsnippet
snippet st "struct"
struct ${1:`!p snip.rv = (snip.basename or "name") + "_t"`}
{
struct ${1:`!p snip.rv = (snip.basename or "name") + "_t"`} {
${0:/* data */}
};
endsnippet

View File

@ -1,3 +1,39 @@
priority -50
extends html
snippet % "<% %>" w
<% $0 %>
endsnippet
snippet = "<%= %>" w
<%= $0 %>
endsnippet
snippet end "<% end %>" w
<% end %>
endsnippet
snippet for
<%= for ${1:item} <- ${2:$1s} ${3:@conn} do %>
$0
<% end %>
endsnippet
snippet ft "form_tag" w
<%= form_tag(${1:"${2:/users}"}, method: ${3::post}) %>
$0
</form>
endsnippet
snippet lin "link" w
<%= link ${1:"${2:Submit}"}, to: ${3:"${4:/users}"}, method: ${5::delete} %>
endsnippet
snippet ff "form_for" w
<%= form_for @changeset, ${1:"${2:/users}"}, fn f -> %>
$0
<%= submit "Submit" %>
<% end %>
endsnippet

View File

@ -198,6 +198,18 @@ snippet h1 "XHTML <h1>" w
<h1>$0</h1>
endsnippet
snippet h2 "XHTML <h2>" w
<h2>$0</h2>
endsnippet
snippet h3 "XHTML <h3>" w
<h3>$0</h3>
endsnippet
snippet h4 "XHTML <h4>" w
<h4>$0</h4>
endsnippet
snippet head "XHTML <head>"
<head>
<meta charset="utf-8">

View File

@ -8,7 +8,7 @@ $${1:arrayName} = array('${2}' => ${3});${4}
endsnippet
snippet def "def"
define('${1}'${2});${3}
define('${1:VARIABLE_NAME}', ${2:'definition'});${3}
endsnippet
snippet do "do"
@ -52,7 +52,7 @@ for ($${2:i} = 0; $$2 < ${1:count}; $$2${3:++}) {
endsnippet
snippet foreachk "foreachk"
foreach ($${1:variable} as $${2:key} => $${3:value}){
foreach ($${1:variable} as $${2:key} => $${3:value}) {
${4:// code...}
}
endsnippet
@ -85,6 +85,10 @@ 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
@ -123,6 +127,7 @@ snippet setter "PHP Class Setter" b
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
${6:return $this;}
}
$0
@ -148,6 +153,7 @@ public function get${1/\w+\s*/\u$0/}()
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;$6
${7:return $this;}
}
$0
@ -240,14 +246,14 @@ $0
endsnippet
snippet fore "Foreach loop"
foreach ($${1:variable} as $${3:value}){
foreach ($${1:variable} as $${3:value}) {
${VISUAL}${4}
}
$0
endsnippet
snippet new "New class instance" b
$$1 = new $1($2);
$${1:variableName} = new ${2:${1/\w+\s*/\u$0/}}($3);
$0
endsnippet

View File

@ -1,15 +1,14 @@
#resource controller
snippet l_rsc "Laravel resource controller" b
/*!
* \class ${1:`!v expand('%:t:r')`}
* \class $1
*
* \author ${2:`!v g:snips_author`}
* \author ${3:`!v g:snips_author`}
* \date `!v strftime('%d-%m-%y')`
*/
class $1 extends ${3: BaseController} {
class ${1:`!v expand('%:t:r')`} extends ${2:BaseController} {
function __construct() {
${4}
}
public function index() {
@ -18,7 +17,7 @@ class $1 extends ${3: BaseController} {
public function create() {
}
public function store($id) {
public function store() {
}
public function show($id) {
@ -38,18 +37,18 @@ endsnippet
#service service provider
snippet l_ssp "Laravel service provider for service" b
/*!
* \namespace ${1:Services}
* \class ${2:`!v expand('%:t:r')`}
* \namespace $1
* \class $2
*
* \author ${3:`!v g:snips_author`}
* \date `!v strftime('%d-%m-%y')`
*/
namespace $1;
namespace ${1:Services};
use Illuminate\Support\ServiceProvider;
class $2 extends ServiceProvider {
class ${2:`!v expand('%:t:r')`} extends ServiceProvider {
public function register() {
$this->app->bind('${4}Service', function ($app) {
@ -64,20 +63,20 @@ endsnippet
#repository service provider
snippet l_rsp "Laravel service provider for repository" b
/*!
* \namespace ${2:Repositories\\${1:}}
* \class ${3:`!v expand('%:t:r')`}
* \namespace $2
* \class $3
*
* \author ${4:`!v g:snips_author`}
* \date `!v strftime('%d-%m-%y')`
*/
namespace $2;
namespace ${2:Repositories\\${1:}};
use Entities\\$1;
use $2\\$1Repository;
use Illuminate\Support\ServiceProvider;
class $3 extends ServiceProvider {
class ${3:`!v expand('%:t:r')`} extends ServiceProvider {
/*!
* \var defer
* \brief Defer service
@ -102,16 +101,16 @@ endsnippet
#model
snippet l_md "Laravel simple model" b
/*!
* \namespace ${1:Entities}
* \class ${2:`!v expand('%:t:r')`}
* \namespace $1
* \class $2
*
* \author ${3:`!v g:snips_author`}
* \date `!v strftime('%d-%m-%y')`
*/
namespace $1;
namespace ${1:Entities};
class $2 extends \Eloquent {
class ${2:`!v expand('%:t:r')`} extends \Eloquent {
protected $table = '${4:`!p snip.rv = t[2].lower()`}';
public $timestamps = ${5:false};
@ -125,19 +124,19 @@ endsnippet
#abstract repository
snippet l_ar "Laravel abstract Repository" b
/*!
* \namespace ${1:Repositories}
* \class ${2:`!v expand('%:t:r')`}
* \implements ${3:BaseRepositoryInterface}
* \namespace $1
* \class $2
* \implements $3
*
* \author ${4:`!v g:snips_author`}
* \date `!v strftime('%d-%m-%y')`
*/
namespace $1;
namespace ${1:Repositories};
use Illuminate\Database\Eloquent\Model;
abstract class $2 implements $3 {
abstract class ${2:`!v expand('%:t:r')`} implements ${3:BaseRepositoryInterface} {
protected $model;
/*!
@ -191,17 +190,17 @@ endsnippet
#repository
snippet l_r "Laravel Repository" b
/*!
* \namespace ${1:Repositories\\${2}}
* \class ${3:`!v expand('%:t:r')`}
* \implements ${4:$3RepositoryInterface}
* \namespace $1
* \class $3
* \implements $4
*
* \author ${5:`!v g:snips_author`}
* \date `!v strftime('%d-%m-%y')`
*/
namespace $1;
namespace ${1:Repositories\\${2}};
class $3 extends \\${6} implements $4 {
class ${3:`!v expand('%:t:r')`} extends \\${6} implements ${4:$3RepositoryInterface} {
${7}
}
endsnippet
@ -209,25 +208,25 @@ endsnippet
#service
snippet l_s "Laravel Service" b
/*!
* \namespace ${1:Services}
* \class ${2:`!v expand('%:t:r')`}
* \namespace $1
* \class $2
*
* \author ${3:`!v g:snips_author`}
* \author ${6:`!v g:snips_author`}
* \date `!v strftime('%d-%m-%y')`
*/
namespace $1;
namespace Services\\${1};
use ${4:Repositories\\${5:Interface}};
use ${3:Repositories\\${4:Interface}};
class $2 {
protected $${6:repo};
class ${2:`!v expand('%:t:r')`} {
protected $${5:repo};
/*!
* \fn __construct
*/
public function __construct($5 $repo) {
$this->$6 = $repo;
public function __construct($4 $repo) {
$this->$5 = $repo;
}
}
endsnippet
@ -235,23 +234,23 @@ endsnippet
#facade
snippet l_f "Laravel Facade" b
/*!
* \namespace ${1:Services}
* \class ${2:`!v expand('%:t:r')`}
* \namespace $1
* \class $2
*
* \author ${3:`!v g:snips_author`}
* \author ${5:`!v g:snips_author`}
* \date `!v strftime('%d-%m-%y')`
*/
namespace $1;
namespace ${1:Services};
use \Illuminate\Support\Facades\Facade;
class $2 extends Facade {
class ${2:`!v expand('%:t:r')`} extends Facade {
/*!
* \fn getFacadeAccessor
*
* \return string
*/
protected static function getFacadeAccessor() { return '${5:${4}Service}'; }
protected static function getFacadeAccessor() { return '${4:${3}Service}'; }
}
endsnippet

View File

@ -278,6 +278,55 @@ snip.rv = re.match(r'.*(?=\.)', fn).group()
}
endsnippet
snippet redir "Symfony2 redirect"
snippet redir "Symfony2 redirect" b
$this->redirect($this->generateUrl('${1}', ${2}));
endsnippet
snippet usecontroller "Symfony2 use Symfony\..\Controller" b
use Symfony\Bundle\FrameworkBundle\Controller\Controller;${1}
endsnippet
snippet usereauest "Symfony2 use Symfony\..\Request" b
use Symfony\Component\HttpFoundation\Request;${1}
endsnippet
snippet useroute "Symfony2 use Sensio\..\Route" b
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;${1}
endsnippet
snippet useresponse "Symfony2 use Symfony\..\Response" b
use Symfony\Component\HttpFoundation\Response;${1}
endsnippet
snippet usefile "Symfony2 use Symfony\..\File" b
use Symfony\Component\HttpFoundation\File\UploadedFile;${1}
endsnippet
snippet useassert "Symfony2 use Symfony\..\Constraints as Assert" b
use Symfony\Component\Validator\Constraints as Assert;${1}
endsnippet
snippet usetemplate "Symfony2 use Sensio\..\Template" b
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;${1}
endsnippet
snippet usecache "Symfony2 use Sensio\..\Cache" b
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Cache;${1}
endsnippet
snippet usemethod "Symfony2 use Sensio\..\Method" b
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;${1}
endsnippet
snippet usearray "Symfony2 use Doctrine\..\ArrayCollection" b
use Doctrine\Common\Collections\ArrayCollection;${1}
endsnippet
snippet useorm "Symfony2 use Doctrine\..\Mapping as ORM" b
use Doctrine\ORM\Mapping as ORM;${1}
endsnippet
snippet usesecure "Symfony2 use JMS\..\Secure" b
use JMS\SecurityExtraBundle\Annotation\Secure;${1}
endsnippet

View File

@ -7,18 +7,18 @@ priority -50
#! header
snippet #! "Shebang header for python scripts" b
#!/usr/bin/env python
# encoding: utf-8
# -*- coding: utf-8 -*-
$0
endsnippet
snippet ifmain "ifmain" b
if __name__ == '__main__':
${1:main()}$0
${1:${VISUAL:main()}}
endsnippet
snippet for "for loop" b
for ${1:item} in ${2:iterable}:
${3:pass}
${3:${VISUAL:pass}}
endsnippet
##########
@ -447,7 +447,7 @@ if snip.indent:
snip.rv = 'self' + (", " if len(t[2]) else "")`${2:arg1}):
`!p snip.rv = triple_quotes(snip)`${4:TODO: Docstring for $1.}`!p
write_function_docstring(t, snip) `
${0:pass}
${5:${VISUAL:pass}}
endsnippet
@ -458,7 +458,7 @@ if snip.indent:
snip.rv = 'cls' + (", " if len(t[2]) else "")`${2:arg1}):
`!p snip.rv = triple_quotes(snip)`${4:TODO: Docstring for $1.}`!p
write_function_docstring(t, snip) `
${0:pass}
${5:${VISUAL:pass}}
endsnippet
@ -467,7 +467,7 @@ snippet defs "static method with docstrings" b
def ${1:function}(${2:arg1}):
`!p snip.rv = triple_quotes(snip)`${4:TODO: Docstring for $1.}`!p
write_function_docstring(t, snip) `
${0:pass}
${5:${VISUAL:pass}}
endsnippet
@ -520,19 +520,19 @@ endsnippet
####################
snippet if "If" b
if ${1:condition}:
${2:pass}
${2:${VISUAL:pass}}
endsnippet
snippet ife "If / Else" b
if ${1:condition}:
${2:pass}
${2:${VISUAL:pass}}
else:
${3:pass}
endsnippet
snippet ifee "If / Elif / Else" b
if ${1:condition}:
${2:pass}
${2:${VISUAL:pass}}
elif ${3:condition}:
${4:pass}
else:
@ -545,32 +545,32 @@ endsnippet
##########################
snippet try "Try / Except" b
try:
${1:pass}
${1:${VISUAL:pass}}
except ${2:Exception}, ${3:e}:
${4:raise $3}
endsnippet
snippet try "Try / Except / Else" b
snippet trye "Try / Except / Else" b
try:
${1:pass}
${1:${VISUAL:pass}}
except ${2:Exception}, ${3:e}:
${4:raise $3}
else:
${5:pass}
endsnippet
snippet try "Try / Except / Finally" b
snippet tryf "Try / Except / Finally" b
try:
${1:pass}
${1:${VISUAL:pass}}
except ${2:Exception}, ${3:e}:
${4:raise $3}
finally:
${5:pass}
endsnippet
snippet try "Try / Except / Else / Finally" b
snippet tryef "Try / Except / Else / Finally" b
try:
${1:pass}
${1:${VISUAL:pass}}
except${2: ${3:Exception}, ${4:e}}:
${5:raise}
else:
@ -597,31 +597,31 @@ import pudb; pudb.set_trace()
endsnippet
snippet ae "Assert equal" b
self.assertEqual(${1:first},${2:second})
self.assertEqual(${1:${VISUAL:first}},${2:second})
endsnippet
snippet at "Assert True" b
self.assertTrue(${0:exp})
self.assertTrue(${1:${VISUAL:expression}})
endsnippet
snippet af "Assert False" b
self.assertFalse(${1:expression})
self.assertFalse(${1:${VISUAL:expression}})
endsnippet
snippet aae "Assert almost equal" b
self.assertAlmostEqual(${1:first},${2:second})
self.assertAlmostEqual(${1:${VISUAL:first}},${2:second})
endsnippet
snippet ar "Assert raises" b
self.assertRaises(${1:exception}, ${2:func}${3/.+/, /}${3:arguments})
self.assertRaises(${1:exception}, ${2:${VISUAL:func}}${3/.+/, /}${3:arguments})
endsnippet
snippet an "Assert is None" b
self.assertIsNone(${0:expression})
self.assertIsNone(${1:${VISUAL:expression}})
endsnippet
snippet ann "Assert is not None" b
self.assertIsNotNone(${0:expression})
self.assertIsNotNone(${1:${VISUAL:expression}})
endsnippet
snippet testcase "pyunit testcase" b
@ -636,24 +636,24 @@ class Test${1:Class}(${2:unittest.TestCase}):
${5:pass}
def test_${6:name}(self):
${7:pass}
${7:${VISUAL:pass}}
endsnippet
snippet " "triple quoted string (double quotes)" b
"""
${1:doc}
${1:${VISUAL:doc}}
`!p triple_quotes_handle_trailing(snip, '"')`
endsnippet
snippet ' "triple quoted string (single quotes)" b
'''
${1:doc}
${1:${VISUAL:doc}}
`!p triple_quotes_handle_trailing(snip, "'")`
endsnippet
snippet doc "doc block (triple quotes)"
`!p snip.rv = triple_quotes(snip)`
${1:doc}
${1:${VISUAL:doc}}
`!p snip.rv = triple_quotes(snip)`
endsnippet

View File

@ -302,18 +302,6 @@ begin
end while ${1:expression}
endsnippet
snippet "\b(r|attr)" "attr_reader :<attr_names>" r
attr_reader :${0:attr_names}
endsnippet
snippet "\b(w|attr)" "attr_writer :<attr_names>" r
attr_writer :${0:attr_names}
endsnippet
snippet "\b(rw|attr)" "attr_accessor :<attr_names>" r
attr_accessor :${0:attr_names}
endsnippet
snippet begin "begin ... rescue ... end"
begin
$1

View File

@ -59,7 +59,7 @@ mod ${1:`!p snip.rv = snip.basename.lower() or "name"`} {
endsnippet
snippet for "for .. in .." b
for ${1:i} in ${2:${3:0us}..${4:10}} {
for ${1:i} in ${2} {
${VISUAL}${0}
}
endsnippet

View File

@ -3,6 +3,19 @@ if exists("b:done_vimsnippets")
endif
let b:done_vimsnippets = 1
" Some variables need default value
if !exists("g:snips_author")
let g:snips_author = "yourname"
endif
if !exists("g:snips_email")
let g:snips_email = "yourname@email.com"
endif
if !exists("g:snips_github")
let g:snips_github = "https://github.com/yourname"
endif
" Expanding the path is not needed on Vim 7.4
if &cp || version >= 704
finish

View File

@ -15,7 +15,7 @@ snippet lorem
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
snippet GPL2
${1:One line to give the program's name and a brief description.}
Copyright (C) `strftime("%Y")` ${2:`g:snips_author`}
Copyright `&enc[:2] == "utf" ? "©" : "(c)"` `strftime("%Y")` ${2:`g:snips_author`}
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@ -32,7 +32,7 @@ snippet GPL2
${0}
snippet LGPL2
${1:One line to give the program's name and a brief description.}
Copyright (C) `strftime("%Y")` ${2:`g:snips_author`}
Copyright `&enc[:2] == "utf" ? "©" : "(c)"` `strftime("%Y")` ${2:`g:snips_author`}
This library is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published
@ -49,7 +49,7 @@ snippet LGPL2
${0}
snippet GPL3
${1:one line to give the program's name and a brief description.}
Copyright (C) `strftime("%Y")` ${2:`g:snips_author`}
Copyright `&enc[:2] == "utf" ? "©" : "(c)"` `strftime("%Y")` ${2:`g:snips_author`}
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@ -66,7 +66,7 @@ snippet GPL3
${0}
snippet LGPL3
${1:One line to give the program's name and a brief description.}
Copyright (C) `strftime("%Y")` ${2:`g:snips_author`}
Copyright `&enc[:2] == "utf" ? "©" : "(c)"` `strftime("%Y")` ${2:`g:snips_author`}
This library is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published
@ -83,7 +83,7 @@ snippet LGPL3
${0}
snippet AGPL3
${1:one line to give the program's name and a brief description.}
Copyright (C) `strftime("%Y")` ${2:`g:snips_author`}
Copyright `&enc[:2] == "utf" ? "©" : "(c)"` `strftime("%Y")` ${2:`g:snips_author`}
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
@ -109,7 +109,7 @@ snippet GMGPL linking exception
${0}
snippet BSD2
${1:one line to give the program's name and a brief description}
Copyright (C) `strftime("%Y")` ${2:`g:snips_author`}
Copyright `&enc[:2] == "utf" ? "©" : "(c)"` `strftime("%Y")` ${2:`g:snips_author`}
All rights reserved.
Redistribution and use in source and binary forms, with or without
@ -138,7 +138,7 @@ snippet BSD2
${0}
snippet BSD3
${1:one line to give the program's name and a brief description}
Copyright (C) `strftime("%Y")` ${2:`g:snips_author`}
Copyright `&enc[:2] == "utf" ? "©" : "(c)"` `strftime("%Y")` ${2:`g:snips_author`}
All rights reserved.
Redistribution and use in source and binary forms, with or without
@ -165,7 +165,7 @@ snippet BSD3
${0}
snippet BSD4
${1:one line to give the program's name and a brief description}
Copyright (C) `strftime("%Y")` ${2:`g:snips_author`}
Copyright `&enc[:2] == "utf" ? "©" : "(c)"` `strftime("%Y")` ${2:`g:snips_author`}
All rights reserved.
Redistribution and use in source and binary forms, with or without
@ -195,7 +195,7 @@ snippet BSD4
${0}
snippet MIT
${1:one line to give the program's name and a brief description}
Copyright (C) `strftime("%Y")` ${2:`g:snips_author`}
Copyright `&enc[:2] == "utf" ? "©" : "(c)"` `strftime("%Y")` ${2:`g:snips_author`}
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the "Software"),
@ -261,3 +261,19 @@ snippet MPL2
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}
snippet AGPL
${1:One line to give the program's name and a brief description.}
Copyright `&enc[:2] == "utf" ? "©" : "(c)"` `strftime("%Y")` ${2:`g:snips_author`}
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 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 Affero General Public License for more details.
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/>.

View File

@ -0,0 +1,106 @@
snippet setup
void setup()
{
${0}
Serial.begin(9600);
}
snippet loop
void loop()
{
${0}
}
snippet inc
#include <${1}.h>
# if
snippet if
if (${1:/* condition */}) {
${2}
}
# else
snippet el
else {
${1}
}
# else if
snippet elif
else if (${1:/* condition */}) {
${2}
}
# ifi
snippet ifi
if (${1:/* condition */}) ${2};
# switch
snippet switch
switch (${1:/* variable */}) {
case ${2:/* variable case */}:
${3}
${4:break;}${5}
default:
${6}
}
snippet case
case ${1:/* variable case */}:
${2}
${3:break;}
# for
snippet for
for (${2:i} = 0; $2 < ${1:count}; $2${3:++}) {
${4}
}
# for (custom)
snippet forr
for (${1:i} = ${2:0}; ${3:$1 < 10}; $1${4:++}) {
${5}
}
# while
snippet wh
while (${1:/* condition */}) {
${2}
}
# do... while
snippet do
do {
${2}
} while (${1:/* condition */});
##
## Functions
# function definition
snippet fun
${1:void} ${2:function_name}(${3})
{
${4}
}
## IO
# pinMode OUTPUT
snippet pinout
pinMode(${1}, OUTPUT);
# pinMode INPUT
snippet pinin
pinMode(${1}, INPUT);
# digitalWrite HIGH
snippet dwHigh
digitalWrite(${1}, HIGH);
# digitalWrite LOW
snippet dwLow
digitalWrite(${1}, LOW);
# digitalRead
snippet dr
digitalRead(${1});
# serialRead
snippet sr
serialRead();
# serial.println
snippet sp
serial.println(${1});
# delay
snippet dl
delay(${1});

View File

@ -52,22 +52,28 @@ snippet once
## Control Statements
# if
snippet if
if (${1:/* condition */}) {
if (${1:true}) {
${0}
}
snippet ife
if (${1:true}) {
${2}
} else {
${0}
}
# else
snippet el
else {
${1}
${0}
}
# else if
snippet elif
else if (${1:/* condition */}) {
${2}
else if (${1:true}) {
${0}
}
# ifi
snippet ifi
if (${1:/* condition */}) ${2};
if (${1:true}) ${0};
# ternary
snippet t
${1:/* condition */} ? ${2:a} : ${3:b}

View File

@ -42,98 +42,51 @@ snippet ci_model_crudl
${3:// code...}
}
// public create(data) {{{
/**
* create
*
* @param mixed $data
* @access public
* @return boolean
*/
public function create($data)
{
if($this->db->insert($table, $data))
if($this->db->insert($this->table, $data))
return true;
else
return false;
}
// }}}
// public read(id) {{{
/**
* read
*
* @param int $id
* @access public
* @return boolean
*/
public function read($id)
{
return $this->db->get_where($table, array('id', $id))->result();
return $this->db->get_where($this->table, array('id', $id))->result();
}
// }}}
// public update(id,data) {{{
/**
* update
*
* @param int $id
* @param mixed $data
* @access public
* @return boolean
*/
public function update($id, $data)
{
if($this->db->update($table, $data, array('id' => $id)))
if($this->db->update($this->table, $data, array('id' => $id)))
return true;
else
return false;
}
// }}}
// public delete(id) {{{
/**
* delete
*
* @param mixed $id (int o array of int)
* @access public
* @return boolean
*/
public function delete($id)
{
if(is_array($id))
{
$this->db->trans_start();
foreach($id as $elem)
$this->db->delete($table, array('id' => $elem));
$this->db->delete($this->table, array('id' => $elem));
$this->db->trans_complete();
}
else
{
if($this->db->delete($table, array('id' => $id)))
if($this->db->delete($this->table, array('id' => $id)))
return true;
else
return false;
}
}
// }}}
// public listRows(limit=null,offset=0) {{{
/**
* listRows
*
* @param int $limit
* @param int $offset
* @access public
* @return boolean
*/
public function listRows($limit = null, $offset = 0)
{
if(!is_null($limit))
$this->db->limit($limit, $offset);
return $this->db->get($table)->result();
return $this->db->get($this->table)->result();
}
// }}}
}
# Load view
snippet ci_load-view

View File

@ -1,3 +1,5 @@
extends c
## STL Collections
# std::array
snippet array

View File

@ -56,22 +56,26 @@
#
# Feedback is welcome!
#
# entry point
# Main
snippet sim
public static int Main(string[] args) {
${1:public }static int Main(string[] args) {
${0}
return 0;
}
snippet simc
public class Application {
public static int Main(string[] args) {
${1:public }static int Main(string[] args) {
${0}
return 0;
}
}
snippet svm
${1:public }static void Main(string[] args) {
${0}
}
# if condition
snippet if
if (${1}) {
if (${1:true}) {
${0}
}
snippet el
@ -90,10 +94,10 @@ snippet ?
snippet do
do {
${0}
} while (${1});
} while (${1:true});
# while loop
snippet wh
while (${1}) {
while (${1:true}) {
${0}
}
# for loop
@ -101,17 +105,21 @@ snippet for
for (int ${1:i} = 0; $1 < ${2:count}; $1${3:++}) {
${0}
}
snippet forr
for (int ${1:i} = ${2:length}; $1 >= 0; $1--) {
${0}
}
# foreach
snippet fore
foreach (var ${1:entry} in ${2}) {
foreach (${1:var} ${2:entry} in ${3}) {
${0}
}
snippet foreach
foreach (var ${1:entry} in ${2}) {
foreach (${1:var} ${2:entry} in ${3}) {
${0}
}
snippet each
foreach (var ${1:entry} in ${2}) {
foreach (${1:var} ${2:entry} in ${3}) {
${0}
}
# interfaces
@ -164,32 +172,32 @@ snippet ctor
# properties - auto properties by default.
# default type is int with layout get / set.
snippet prop
${1:public} ${2:int} ${3:} { get; set; }
${1:public} ${2:int} ${3} { get; set; }
snippet p
${1:public} ${2:int} ${3:} { get; set; }
${1:public} ${2:int} ${3} { get; set; }
snippet p+
public ${1:int} ${2:} { get; set; }
public ${1:int} ${2} { get; set; }
snippet p+&
public ${1:int} ${2:} { get; internal set; }
public ${1:int} ${2} { get; internal set; }
snippet p+|
public ${1:int} ${2:} { get; protected set; }
public ${1:int} ${2} { get; protected set; }
snippet p+-
public ${1:int} ${2:} { get; private set; }
public ${1:int} ${2} { get; private set; }
snippet p&
internal ${1:int} ${2:} { get; set; }
internal ${1:int} ${2} { get; set; }
snippet p&|
internal ${1:int} ${2:} { get; protected set; }
internal ${1:int} ${2} { get; protected set; }
snippet p&-
internal ${1:int} ${2:} { get; private set; }
internal ${1:int} ${2} { get; private set; }
snippet p|
protected ${1:int} ${2:} { get; set; }
protected ${1:int} ${2} { get; set; }
snippet p|-
protected ${1:int} ${2:} { get; private set; }
protected ${1:int} ${2} { get; private set; }
snippet p-
private ${1:int} ${2:} { get; set; }
private ${1:int} ${2} { get; set; }
# property - bool
snippet pi
${1:public} int ${2:} { get; set; }
${1:public} int ${2} { get; set; }
snippet pi+
public int ${1} { get; set; }
snippet pi+&
@ -212,7 +220,7 @@ snippet pi-
private int ${1} { get; set; }
# property - bool
snippet pb
${1:public} bool ${2:} { get; set; }
${1:public} bool ${2} { get; set; }
snippet pb+
public bool ${1} { get; set; }
snippet pb+&
@ -235,7 +243,7 @@ snippet pb-
private bool ${1} { get; set; }
# property - string
snippet ps
${1:public} string ${2:} { get; set; }
${1:public} string ${2} { get; set; }
snippet ps+
public string ${1} { get; set; }
snippet ps+&
@ -258,87 +266,87 @@ snippet ps-
private string ${1} { get; set; }
# members - void
snippet m
${1:public} ${2:void} ${3:}(${4:}) {
${5:}
${1:public} ${2:void} ${3}(${4}) {
${0}
}
snippet m+
public ${1:void} ${2:}(${3:}) {
${4:}
public ${1:void} ${2}(${3}) {
${0}
}
snippet m&
internal ${1:void} ${2:}(${3:}) {
${4:}
internal ${1:void} ${2}(${3}) {
${0}
}
snippet m|
protected ${1:void} ${2:}(${3:}) {
${4:}
protected ${1:void} ${2}(${3}) {
${0}
}
snippet m-
private ${1:void} ${2:}(${3:}) {
${4:}
private ${1:void} ${2}(${3}) {
${0}
}
# members - int
snippet mi
${1:public} int ${2:}(${3:}) {
${4:return 0;}
${1:public} int ${2}(${3}) {
${0:return 0;}
}
snippet mi+
public int ${1:}(${2:}) {
${3:return 0;}
public int ${1}(${2}) {
${0:return 0;}
}
snippet mi&
internal int ${1:}(${2:}) {
${3:return 0;}
internal int ${1}(${2}) {
${0:return 0;}
}
snippet mi|
protected int ${1:}(${2:}) {
${3:return 0;}
protected int ${1}(${2}) {
${0:return 0;}
}
snippet mi-
private int ${1:}(${2:}) {
${3:return 0;}
private int ${1}(${2}) {
${0:return 0;}
}
# members - bool
snippet mb
${1:public} bool ${2:}(${3:}) {
${4:return false;}
${1:public} bool ${2}(${3}) {
${0:return false;}
}
snippet mb+
public bool ${1:}(${2:}) {
${3:return false;}
public bool ${1}(${2}) {
${0:return false;}
}
snippet mb&
internal bool ${1:}(${2:}) {
${3:return false;}
internal bool ${1}(${2}) {
${0:return false;}
}
snippet mb|
protected bool ${1:}(${2:}) {
${3:return false;}
protected bool ${1}(${2}) {
${0:return false;}
}
snippet mb-
private bool ${1:}(${2:}) {
${3:return false;}
private bool ${1}(${2}) {
${0:return false;}
}
# members - string
snippet ms
${1:public} string ${2:}(${3:}) {
${4:return "";}
${1:public} string ${2}(${3}) {
${0:return "";}
}
snippet ms+
public string ${1:}(${2:}) {
${3:return "";}
public string ${1}(${2}) {
${0:return "";}
}
snippet ms&
internal string ${1:}(${2:}) {
${3:return "";}
internal string ${1}(${2}) {
${0:return "";}
}
snippet ms|
protected string ${1:}(${2:}) {
${3:return "";}
${0:return "";}
}
snippet ms-
private string ${1:}(${2:}) {
${3:return "";}
private string ${1}(${2}) {
${0:return "";}
}
# structure
snippet struct
@ -347,6 +355,11 @@ snippet struct
}
# enumeration
snippet enum
enum ${1} {
${0}
}
snippet enum+
public enum ${1} {
${0}
}
@ -372,3 +385,86 @@ snippet <rem
<remarks>${1}</remarks>
snippet <c
<code>${1}</code>
snippet cw
Console.WriteLine(${1});
# equals override
snippet eq
public override bool Equals(object obj) {
if (obj == null || GetType() != obj.GetType()) {
return false;
}
${0:throw new NotImplementedException();}
return base.Equals(obj);
}
# exception
snippet exc
public class ${1:MyException} : ${2:Exception} {
public $1() { }
public $1(string message) : base(message) { }
public $1(string message, Exception inner) : base(message, inner) { }
protected $1(
System.Runtime.Serialization.SerializationInfo info,
System.Runtime.Serialization.StreamingContext context)
: base(info, context) { }
}
# indexer
snippet index
public ${1:object} this[${2:int} index] {
get { ${0} }
set { ${0} }
}
# eventhandler
snippet inv
EventHandler temp = ${1:MyEvent};
if (${2:temp} != null) {
$2();
}
# lock
snippet lock
lock (${1:this}) {
${0}
}
# namespace
snippet namespace
namespace ${1:MyNamespace} {
${0}
}
# property
snippet prop
public ${1:int} ${2:MyProperty} { get; set; }
snippet propf
private ${1:int} ${2:myVar};
public $1 ${3:MyProperty} {
get { return $2; }
set { $2 = value; }
}
snippet propg
public ${1:int} ${2:MyProperty} { get; private set; }
# switch
snippet switch
switch (${1:switch_on}) {
${0}
default:
}
# try
snippet try
try {
${0}
}
catch (${1:System.Exception}) {
throw;
}
snippet tryf
try {
${0}
}
finally {
${1}
}
# using
snippet usi
using(${1:resource}) {
${0}
}

View File

@ -1,6 +1,40 @@
snippet %
<% ${0} %>
snippet =
<%= ${1} %>
<%= ${0} %>
snippet end
<% end %>
snippet for
<%= for ${1:item} <- ${2:items} ${3:@conn} do %>
${0}
<% end %>
snippet if
<%= if ${1} do %>
${0}
<% end %>
snippet ife
<%= if ${1} do %>
${2}
<%= else %>
${0}
<% end %>
snippet ft
<%= form_tag(${1:"/users"}, method: ${2::post}) %>
${0}
</form>
snippet lin
<%= link "${1:Submit}", to: ${2:"/users"}, method: ${3::delete} %>
snippet ff
<%= form_for @changeset, ${1:"/users"}, fn f -> %>
${0}
<%= submit "Submit" %>
<% end %>

View File

@ -40,6 +40,14 @@ snippet case
${2} ->
${0}
end
snippet for
for ${1:item} <- ${2:items} do
${0}
end
snippet fori
for ${1:item} <- ${2:items}, into: ${3} do
${0}
end
snippet df
def ${1:name}, do: ${2}
snippet def
@ -89,8 +97,8 @@ snippet mdoc
"""
snippet rec
receive do
${1} ->
${0}
${1} ->
${0}
end
snippet req
require ${0:module_name}

View File

@ -103,8 +103,8 @@ snippet supervisor
supervisor:start_link({local, ?SERVER}, ?MODULE, []).
init([]) ->
Server = {${0:my_server}, {$2, start_link, []},
permanent, 2000, worker, [$2]},
Server = {${0:my_server}, {${2}, start_link, []},
permanent, 2000, worker, [${2}]},
Children = [Server],
RestartStrategy = {one_for_one, 0, 1},
{ok, {RestartStrategy, Children}}.

View File

@ -226,6 +226,8 @@ snippet printf
System.out.printf("${1:Message}", ${0:args});
snippet println
System.out.println(${0});
snippet printlna
System.out.println(Arrays.toString(${0}));
##
## Render Methods
snippet ren

View File

@ -1,3 +1,5 @@
snippet #!
#!/usr/bin/env node
# module exports
snippet ex
module.exports = ${1};

View File

@ -235,7 +235,8 @@ snippet qsa
${1:document}.querySelectorAll('${0:CSS selector}')
# Debugging
snippet de
debugger;
# console.log
snippet cl
console.log(${0});

View File

@ -0,0 +1,242 @@
#resource controller
snippet l_rsc
/*!
* \class $1
*
* \author ${3:`!v g:snips_author`}
* \date `!v strftime('%d-%m-%y')`
*/
class ${1:`!v expand('%:t:r')`} extends ${2:BaseController} {
function __construct() {
}
public function index() {
}
public function create() {
}
public function store() {
}
public function show($id) {
}
public function edit($id) {
}
public function update($id) {
}
public function destroy($id) {
}
}
#service service provider
snippet l_ssp
/*!
* \namespace $1
* \class $2
*
* \author ${3:`!v g:snips_author`}
* \date `!v strftime('%d-%m-%y')`
*/
namespace ${1:Services};
use Illuminate\Support\ServiceProvider;
class ${2:`!v expand('%:t:r')`} extends ServiceProvider {
public function register() {
$this->app->bind('${4}Service', function ($app) {
return new ${5}(
$app->make('Repositories\\${6}Interface')
);
});
}
}
#repository service provider
snippet l_rsp
/*!
* \namespace $2
* \class $3
*
* \author ${4:`!v g:snips_author`}
* \date `!v strftime('%d-%m-%y')`
*/
namespace ${2:Repositories\\${1:}};
use Entities\\$1;
use $2\\$1Repository;
use Illuminate\Support\ServiceProvider;
class ${3:`!v expand('%:t:r')`} 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'];
}
}
#model
snippet l_md
/*!
* \namespace $1
* \class $2
*
* \author ${3:`!v g:snips_author`}
* \date `!v strftime('%d-%m-%y')`
*/
namespace ${1:Entities};
class ${2:`!v expand('%:t:r')`} extends \Eloquent {
protected $table = '${4:`!p snip.rv = t[2].lower()`}';
public $timestamps = ${5:false};
protected $hidden = array(${6});
protected $guarded = array(${7:'id'});
}
#abstract repository
snippet l_ar
/*!
* \namespace $1
* \class $2
* \implements $3
*
* \author ${4:`!v g:snips_author`}
* \date `!v strftime('%d-%m-%y')`
*/
namespace ${1:Repositories};
use Illuminate\Database\Eloquent\Model;
abstract class ${2:`!v expand('%:t:r')`} implements ${3:BaseRepositoryInterface} {
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);
}
}
#repository
snippet l_r
/*!
* \namespace $1
* \class $3
* \implements $4
*
* \author ${5:`!v g:snips_author`}
* \date `!v strftime('%d-%m-%y')`
*/
namespace ${1:Repositories\\${2}};
class ${3:`!v expand('%:t:r')`} extends \\${6} implements ${4:$3RepositoryInterface} {
${7}
}
#service
snippet l_s
/*!
* \namespace $1
* \class $2
*
* \author ${6:`!v g:snips_author`}
* \date `!v strftime('%d-%m-%y')`
*/
namespace Services\\${1};
use ${3:Repositories\\${4:Interface}};
class ${2:`!v expand('%:t:r')`} {
protected $${5:repo};
/*!
* \fn __construct
*/
public function __construct($4 $repo) {
$this->$5 = $repo;
}
}
#facade
snippet l_f
/*!
* \namespace $1
* \class $2
*
* \author ${5:`!v g:snips_author`}
* \date `!v strftime('%d-%m-%y')`
*/
namespace ${1:Services};
use \Illuminate\Support\Facades\Facade;
class ${2:`!v expand('%:t:r')`} extends Facade {
/*!
* \fn getFacadeAccessor
*
* \return string
*/
protected static function getFacadeAccessor() { return '${4:${3}Service}'; }
}

View File

@ -1,4 +1,31 @@
# base
snippet base
.PHONY: clean, mrproper
CC = gcc
CFLAGS = -g -Wall
all: $1
%.o: %.c
$(CC) $(CFLAGS) -c -o $@ $<
${1:out}: $1.o
$(CC) $(CFLAGS) -o $@ $+
clean:
rm -f *.o core.*
mrproper: clean
rm -f $1
# add
snippet add
${1:out}: $1.o
$(CC) $(CFLAGS) -o $@ $+
# print
snippet print
print-%: ; @echo $*=$($*)
# ifeq
snippet ifeq
ifeq (${1:cond0},${2:cond1})
ifeq (${1:cond0}, ${2:cond1})
${0}
endif

View File

@ -47,7 +47,7 @@ snippet deff
def ${1:fname}(${2:`indent('.') ? 'self' : ''`}):
${0}
# New Method
snippet defs
snippet defm
def ${1:mname}(self, ${2:arg}):
${0}
# New Property
@ -138,18 +138,17 @@ snippet pdbbb
# 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})
# ptpython
snippet ptpython
from ptpython.repl import embed
embed(globals(), locals(), vi_mode=${1:False}, history_filename=${2:None})
# python console debugger (pudb)
snippet pudb
import pudb; pudb.set_trace()
snippet pprint
import pprint; pprint.pprint(${1})
snippet "
"""
${0:doc}
"""${0:doc}
"""
# assertions
snippet a=
@ -200,8 +199,7 @@ snippet lc
snippet li
logger.info(${0:msg})
snippet epydoc
"""
${1:Description}
"""${1:Description}
@param ${2:param}: ${3: Description}
@type $2: ${4: Type}

View File

@ -121,23 +121,17 @@ snippet cla class .. initialize .. end
${0}
end
end
snippet cla class .. < ParentClass .. initialize .. end
snippet cla< class .. < ParentClass .. initialize .. end
class ${1:`substitute(vim_snippets#Filename(), '\(_\|^\)\(.\)', '\u\2', 'g')`} < ${2:ParentClass}
def initialize(${3:args})
${0}
end
end
snippet cla ClassName = Struct .. do .. end
${1:`substitute(vim_snippets#Filename(), '\(_\|^\)\(.\)', '\u\2', 'g')`} = Struct.new(:${2:attr_names}) do
def ${3:method_name}
${0}
end
end
snippet cla class BlankSlate .. initialize .. end
snippet blankslate class BlankSlate .. initialize .. end
class ${0:BlankSlate}
instance_methods.each { |meth| undef_method(meth) unless meth =~ /\A__/ }
end
snippet cla class << self .. end
snippet claself class << self .. end
class << ${1:self}
${0}
end
@ -152,12 +146,6 @@ snippet cla-
end
snippet mod module .. end
module ${1:`substitute(vim_snippets#Filename(), '\(_\|^\)\(.\)', '\u\2', 'g')`}
${0}
end
snippet mod module .. module_function .. end
module ${1:`substitute(vim_snippets#Filename(), '\(_\|^\)\(.\)', '\u\2', 'g')`}
module_function
${0}
end
snippet mod module .. ClassMethods .. end
@ -735,3 +723,11 @@ snippet is
it { should ${0} }
snippet isn
it { should_not ${0} }
snippet iexp
it { expect(${1:object}).${1} ${0} }
snippet iexpb
it { expect { ${1:object} }.${1} ${0} }
snippet iiexp
it { is_expected.to ${0} }
snippet iiexpn
it { is_expected.not_to ${0} }

View File

@ -111,7 +111,7 @@ snippet while "while loop"
${0}
}
snippet for "for ... in ... loop"
for ${1:i} in ${2:0u..10} {
for ${1:i} in ${2} {
${0}
}
# TODO commenting

View File

@ -0,0 +1,127 @@
# if statement
snippet if
if (${1}) begin
${0}
end
# If/else statements
snippet ife
if (${1}) begin
${2}
end
else begin
${1}
end
# Else if statement
snippet eif
else if (${1}) begin
${0}
end
#Else statement
snippet el
else begin
${0}
end
# While statement
snippet wh
while (${1}) begin
${0}
end
# Repeat Loop
snippet rep
repeat (${1}) begin
${0}
end
# Foreach Loopo
snippet fe
foreach (${1}) begin
${0}
end
# Do-while statement
snippet dowh
do begin
${0}
end while (${1});
# Case statement
snippet case
case (${1})
{$2}: begin
${0}
end
default: begin
end
endcase
# CaseZ statement
snippet casez
casez (${1})
{$2}: begin
${0}
end
default: begin
end
endcase
# Combinational always block
snippet alc
always_comb begin ${1:: statement_label}
${0}
end $1
# Sequential logic
snippet alff
always_ff @(posedge ${1:clk}) begin ${2:: statement_label}
${0}
end $2
# Latched logic
snippet all
always_latch begin ${1:: statement_label}
${0}
end $1
# Module block
snippet mod
module ${1:module_name} (${2});
${0}
endmodule : $1
# Class
snippet cl
class ${1:class_name};
// data or class properties
${0}
// initialization
function new();
endfunction : new
endclass : $1
# Typedef structure
snippet types
typedef struct {
${0}
} ${1:name_t};
# Program block
snippet prog
program ${1:program_name} ();
${0}
endprogram : $1
# Interface block
snippet intf
interface ${1:program_name} ();
// nets
${0}
// clocking
// modports
endinterface : $1
# Clocking Block
snippet clock
clocking ${1:clocking_name} @(${2:posedge} ${3:clk});
${0}
endclocking : $1
# Covergroup construct
snippet cg
covergroup ${1:group_name} @(${2:posedge} ${3:clk});
${0}
endgroup : $1
# Package declaration
snippet pkg
package ${1:package_name};
${0}
endpackage : $1

View File

@ -45,10 +45,15 @@ snippet gat gather(ed) environment
# Equation
snippet eq equation environment
\begin{equation}
\label{eq:${2}}
${0}
\end{equation}
# Equation
snippet eql Labeled equation environment
\begin{equation}
\label{eq:${2}}
${0}
\end{equation}
# Equation
snippet eq* unnumbered equation environment
\begin{equation*}
${0}
@ -206,6 +211,13 @@ snippet rm roman font text
\textrm{${0:text}}
snippet tt typewriter (monospace) text
\texttt{${0:text}}
#Math font
snippet mf mathfrak
\mathfrak{${0:text}}
snippet mc mathcal
\mathcal{${0:text}}
snippet ms mathscr
\mathscr{${0:text}}
#misc
snippet ft \footnote
\footnote{${0:text}}
@ -263,6 +275,18 @@ snippet col2 two-column environment
${0}
\end{column}
\end{columns}
#delimiter
snippet lr( left( right)
\left( ${0} \right)
snippet lr| left| right|
\left| ${0} \right|
snippet lr{ left\{ right\}
\left\\{ ${0} \right\\}
snippet lr[ left[ right]
\left[ ${0} \right]
snippet lra langle rangle
\langle ${0} \rangle
# Code listings
snippet lst
\begin{listing}[language=${1:language}]

View File

@ -0,0 +1,15 @@
#!/usr/bin/env bash
SPACED=$(grep -REn '^ .+' --include '*.snippets' snippets);
if [[ $? -ne 1 ]]; then
echo These snippet lines are indented with spaces:;
echo;
echo "$SPACED";
echo;
echo Tests failed!
exit 1;
fi
echo Tests passed!
exit 0;