mirror of
https://github.com/amix/vimrc
synced 2025-06-16 01:25:00 +08:00
Updated plugins
This commit is contained in:
@ -16,7 +16,7 @@ endsnippet
|
||||
|
||||
snippet #if "#if #endif" b
|
||||
#if ${1:0}
|
||||
${VISUAL}${0:${VISUAL/(.*)/(?1::code)/}}
|
||||
${VISUAL}${0}
|
||||
#endif
|
||||
endsnippet
|
||||
|
||||
@ -40,7 +40,7 @@ endsnippet
|
||||
snippet main "main() (main)"
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
${VISUAL}${0:${VISUAL/(.*)/(?1::\/* code *\/)/}}
|
||||
${VISUAL}${0}
|
||||
return 0;
|
||||
}
|
||||
endsnippet
|
||||
@ -48,14 +48,14 @@ endsnippet
|
||||
snippet for "for loop (for)"
|
||||
for (${2:i} = 0; $2 < ${1:count}; ${3:++$2})
|
||||
{
|
||||
${VISUAL}${0:${VISUAL/(.*)/(?1::\/* code *\/)/}}
|
||||
${VISUAL}${0}
|
||||
}
|
||||
endsnippet
|
||||
|
||||
snippet fori "for int loop (fori)"
|
||||
for (${4:int} ${2:i} = 0; $2 < ${1:count}; ${3:++$2})
|
||||
{
|
||||
${VISUAL}${0:${VISUAL/(.*)/(?1::\/* code *\/)/}}
|
||||
${VISUAL}${0}
|
||||
}
|
||||
endsnippet
|
||||
|
||||
@ -74,7 +74,7 @@ else:
|
||||
snip.rv = snip.c`}
|
||||
#define $1
|
||||
|
||||
${0}
|
||||
${VISUAL}${0}
|
||||
|
||||
#endif /* end of include guard: $1 */
|
||||
|
||||
@ -86,13 +86,13 @@ endsnippet
|
||||
|
||||
snippet wh "while loop"
|
||||
while(${1:/* condition */}) {
|
||||
${VISUAL}${0:${VISUAL/(.*)/(?1::\/* code *\/)/}}
|
||||
${VISUAL}${0}
|
||||
}
|
||||
endsnippet
|
||||
|
||||
snippet do "do...while loop (do)"
|
||||
do {
|
||||
${VISUAL}${0:${VISUAL/(.*)/(?1::\/* code *\/)/}}
|
||||
${VISUAL}${0}
|
||||
} while(${1:/* condition */});
|
||||
endsnippet
|
||||
|
||||
@ -103,26 +103,26 @@ endsnippet
|
||||
snippet if "if .. (if)"
|
||||
if (${1:/* condition */})
|
||||
{
|
||||
${VISUAL}${0:${VISUAL/(.*)/(?1::\/* code *\/)/}}
|
||||
${VISUAL}${0}
|
||||
}
|
||||
endsnippet
|
||||
|
||||
snippet el "else .. (else)"
|
||||
else {
|
||||
${VISUAL}${0:${VISUAL/(.*)/(?1::\/* code *\/)/}}
|
||||
${VISUAL}${0}
|
||||
}
|
||||
endsnippet
|
||||
|
||||
snippet eli "else if .. (eli)"
|
||||
else if (${1:/* condition */}) {
|
||||
${VISUAL}${0:${VISUAL/(.*)/(?1::\/* code *\/)/}}
|
||||
${VISUAL}${0}
|
||||
}
|
||||
endsnippet
|
||||
|
||||
snippet ife "if .. else (ife)"
|
||||
if (${1:/* condition */})
|
||||
{
|
||||
${2:/* code */}
|
||||
${2}
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -144,7 +144,7 @@ endsnippet
|
||||
snippet fun "function" b
|
||||
${1:void} ${2:function_name}(${3})
|
||||
{
|
||||
${VISUAL}${0:${VISUAL/(.*)/(?1::\/* code *\/)/}}
|
||||
${VISUAL}${0}
|
||||
}
|
||||
endsnippet
|
||||
|
||||
|
@ -27,7 +27,7 @@ endsnippet
|
||||
snippet ns "namespace .. (namespace)"
|
||||
namespace${1/.+/ /m}${1:`!p snip.rv = snip.basename or "name"`}
|
||||
{
|
||||
${VISUAL}${0:${VISUAL/(.*)/(?1::\/* code *\/)/}}
|
||||
${VISUAL}${0}
|
||||
}${1/.+/ \/* /m}$1${1/.+/ *\/ /m}
|
||||
endsnippet
|
||||
|
||||
|
@ -106,14 +106,14 @@ endsnippet
|
||||
snippet if "if .. (if)"
|
||||
if(${1:/*condition*/})
|
||||
{
|
||||
${VISUAL}${0:/*code*/}
|
||||
${VISUAL}${0}
|
||||
}
|
||||
endsnippet
|
||||
|
||||
snippet ife "if .. else (ife)" b
|
||||
if(${1:/*condition*/})
|
||||
{
|
||||
${2:/*code*/}
|
||||
${2}
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -124,14 +124,14 @@ endsnippet
|
||||
snippet el "else (el)" b
|
||||
else
|
||||
{
|
||||
${VISUAL}${1:/*code*/}
|
||||
${VISUAL}${1}
|
||||
}
|
||||
endsnippet
|
||||
|
||||
snippet elif "else if (elif)" b
|
||||
else if(${1:/*condition*/})
|
||||
{
|
||||
${VISUAL}${0:/*code*/}
|
||||
${VISUAL}${0}
|
||||
}
|
||||
endsnippet
|
||||
|
||||
@ -139,10 +139,10 @@ snippet sw "switch (sw)"
|
||||
switch(${1:/*var*/})
|
||||
{
|
||||
case ${2:/*value*/}:
|
||||
${3:/*code*/}
|
||||
${3}
|
||||
break;
|
||||
case ${4:/*value*/}:
|
||||
${5:/*code*/}
|
||||
${5}
|
||||
break;
|
||||
${7:/*more cases*/}
|
||||
default:
|
||||
@ -151,13 +151,13 @@ switch(${1:/*var*/})
|
||||
endsnippet
|
||||
|
||||
snippet fsw "final switch (fsw)"
|
||||
switch(${1:/*var*/})
|
||||
final switch(${1:/*var*/})
|
||||
{
|
||||
case ${2:/*value*/}:
|
||||
${3:/*code*/}
|
||||
${3}
|
||||
break;
|
||||
case ${4:/*value*/}:
|
||||
${5:/*code*/}
|
||||
${5}
|
||||
break;
|
||||
${7:/*more cases*/}
|
||||
}
|
||||
@ -165,7 +165,7 @@ endsnippet
|
||||
|
||||
snippet case "case (case)" b
|
||||
case ${1:/*value*/}:
|
||||
${2:/*code*/}
|
||||
${2}
|
||||
break;
|
||||
endsnippet
|
||||
|
||||
@ -178,42 +178,42 @@ endsnippet
|
||||
snippet do "do while (do)" b
|
||||
do
|
||||
{
|
||||
${VISUAL}${2:/*code*/}
|
||||
${VISUAL}${2}
|
||||
} while(${1:/*condition*/});
|
||||
endsnippet
|
||||
|
||||
snippet wh "while (wh)" b
|
||||
while(${1:/*condition*/})
|
||||
{
|
||||
${VISUAL}${2:/*code*/}
|
||||
${VISUAL}${2}
|
||||
}
|
||||
endsnippet
|
||||
|
||||
snippet for "for (for)" b
|
||||
for (${4:size_t} ${2:i} = 0; $2 < ${1:count}; ${3:++$2})
|
||||
{
|
||||
${VISUAL}${0:/*code*/}
|
||||
${VISUAL}${0}
|
||||
}
|
||||
endsnippet
|
||||
|
||||
snippet forever "forever (forever)" b
|
||||
for(;;)
|
||||
{
|
||||
${VISUAL}${0:/*code*/}
|
||||
${VISUAL}${0}
|
||||
}
|
||||
endsnippet
|
||||
|
||||
snippet fore "foreach (fore)"
|
||||
foreach(${1:/*elem*/}; ${2:/*range*/})
|
||||
{
|
||||
${VISUAL}${3:/*code*/}
|
||||
${VISUAL}${3}
|
||||
}
|
||||
endsnippet
|
||||
|
||||
snippet forif "foreach if (forif)" b
|
||||
foreach(${1:/*elem*/}; ${2:/*range*/}) if(${3:/*condition*/})
|
||||
{
|
||||
${VISUAL}${4:/*code*/}
|
||||
${VISUAL}${4}
|
||||
}
|
||||
endsnippet
|
||||
|
||||
@ -249,21 +249,21 @@ endsnippet
|
||||
snippet fun "function definition (fun)"
|
||||
${1:void} ${2:/*function name*/}(${3:/*args*/}) ${4:@safe pure nothrow}
|
||||
{
|
||||
${VISUAL}${5:/*code*/}
|
||||
${VISUAL}${5}
|
||||
}
|
||||
endsnippet
|
||||
|
||||
snippet void "void function definition (void)"
|
||||
void ${1:/*function name*/}(${2:/*args*/}) ${3:@safe pure nothrow}
|
||||
{
|
||||
${VISUAL}${4:/*code*/}
|
||||
${VISUAL}${4}
|
||||
}
|
||||
endsnippet
|
||||
|
||||
snippet this "ctor (this)" w
|
||||
this(${1:/*args*/})
|
||||
{
|
||||
${VISUAL}${2:/*code*/}
|
||||
${VISUAL}${2}
|
||||
}
|
||||
endsnippet
|
||||
|
||||
@ -295,7 +295,7 @@ endsnippet
|
||||
snippet scope "scope (scope)" b
|
||||
scope(${1:exit})
|
||||
{
|
||||
${VISUAL}${2:/*code*/}
|
||||
${VISUAL}${2}
|
||||
}
|
||||
endsnippet
|
||||
|
||||
@ -304,7 +304,7 @@ endsnippet
|
||||
snippet with "with (with)"
|
||||
with(${1})
|
||||
{
|
||||
${VISUAL}${2:/*code*/}
|
||||
${VISUAL}${2}
|
||||
}
|
||||
endsnippet
|
||||
|
||||
@ -405,14 +405,14 @@ endsnippet
|
||||
snippet version "version (version)" b
|
||||
version(${1:/*version name*/})
|
||||
{
|
||||
${VISUAL}${2:/*code*/}
|
||||
${VISUAL}${2}
|
||||
}
|
||||
endsnippet
|
||||
|
||||
snippet debug "debug" b
|
||||
debug
|
||||
{
|
||||
${VISUAL}${1:/*code*/}
|
||||
${VISUAL}${1}
|
||||
}
|
||||
endsnippet
|
||||
|
||||
@ -422,7 +422,7 @@ endsnippet
|
||||
snippet temp "template (temp)" b
|
||||
template ${2:/*name*/}(${1:/*args*/})
|
||||
{
|
||||
${3:/*code*/}
|
||||
${3}
|
||||
}
|
||||
endsnippet
|
||||
|
||||
@ -440,7 +440,7 @@ endsnippet
|
||||
snippet unittest "unittest (unittest)" b
|
||||
unittest
|
||||
{
|
||||
${1:/*code*/}
|
||||
${1}
|
||||
}
|
||||
endsnippet
|
||||
|
||||
@ -450,21 +450,21 @@ endsnippet
|
||||
snippet opDis "opDispatch (opDis)" b
|
||||
${1:/*return type*/} opDispatch(string s)()
|
||||
{
|
||||
${2:/*code*/};
|
||||
${2};
|
||||
}
|
||||
endsnippet
|
||||
|
||||
snippet op= "opAssign (op=)" b
|
||||
void opAssign(${1} rhs) ${2:@safe pure nothrow}
|
||||
{
|
||||
${2:/*code*/}
|
||||
${2}
|
||||
}
|
||||
endsnippet
|
||||
|
||||
snippet opCmp "opCmp (opCmp)" b
|
||||
int opCmp(${1} rhs) @safe const pure nothrow
|
||||
{
|
||||
${2:/*code*/}
|
||||
${2}
|
||||
}
|
||||
endsnippet
|
||||
|
||||
@ -484,7 +484,7 @@ endsnippet
|
||||
snippet toString "toString (toString)" b
|
||||
string toString() @safe const pure nothrow
|
||||
{
|
||||
${1:/*code*/}
|
||||
${1}
|
||||
}
|
||||
endsnippet
|
||||
|
||||
|
@ -52,6 +52,12 @@ for ${1:condition}${1/(.+)/ /}{
|
||||
}
|
||||
endsnippet
|
||||
|
||||
snippet fori "Integer for loop" b
|
||||
for ${1:i} := 0; $1 < ${2:N}; $1++ {
|
||||
${0:${VISUAL}}
|
||||
}
|
||||
endsnippet
|
||||
|
||||
snippet forr "For range loop" b
|
||||
for ${2:name} := range ${1:collection} {
|
||||
${0:${VISUAL}}
|
||||
|
@ -60,7 +60,7 @@ abstract $0
|
||||
endsnippet
|
||||
|
||||
snippet as "assert" b
|
||||
assert ${1:test}${2/(.+)/(?1: \: ")/}${2:Failure message}${2/(.+)/(?1:")/};$0
|
||||
assert ${1:test}${2/(.+)/(?1: \: ")/}${2:Failure message}${2/(.+)/(?1:")/};
|
||||
endsnippet
|
||||
|
||||
snippet at "assert true" b
|
||||
@ -68,7 +68,7 @@ assertTrue(${1:actual});
|
||||
endsnippet
|
||||
|
||||
snippet af "assert false" b
|
||||
assertFalse(${1:actual});$0
|
||||
assertFalse(${1:actual});
|
||||
endsnippet
|
||||
|
||||
snippet ae "assert equals" b
|
||||
@ -141,7 +141,7 @@ if len(args) > 0:
|
||||
public `!p snip.rv = snip.basename or "unknown"`($1) { `!p
|
||||
args = getArgs(t[1])
|
||||
for i in args:
|
||||
snip.rv += "\n\t\tthis." + i[1] + " = " + i[1]
|
||||
snip.rv += "\n\t\tthis.%s = %s;" % (i[1], i[1])
|
||||
if len(args) == 0:
|
||||
snip.rv += "\n"`
|
||||
}
|
||||
@ -224,7 +224,7 @@ $0
|
||||
endsnippet
|
||||
|
||||
snippet im "import" b
|
||||
import ${1:java}.${2:util}.$0
|
||||
import ${1:java}.${2:util}.$0;
|
||||
endsnippet
|
||||
|
||||
snippet in "interface" b
|
||||
@ -269,7 +269,7 @@ if len(args) > 0:
|
||||
public `!p snip.rv = snip.basename or "unknown"`($1) { `!p
|
||||
args = getArgs(t[1])
|
||||
for i in args:
|
||||
snip.rv += "\n\t\tthis." + i[1] + " = " + i[1]
|
||||
snip.rv += "\n\t\tthis.%s = %s;" % (i[1], i[1])
|
||||
if len(args) == 0:
|
||||
snip.rv += "\n"`
|
||||
}
|
||||
|
@ -79,6 +79,14 @@ setTimeout(function() {
|
||||
}${2:.bind(${3:this})}, ${1:10});
|
||||
endsnippet
|
||||
|
||||
snippet fi "for prop in obj using hasOwnProperty" b
|
||||
for (${1:prop} in ${2:obj}){
|
||||
if ($2.hasOwnProperty($1)) {
|
||||
${VISUAL}$0
|
||||
}
|
||||
}
|
||||
endsnippet
|
||||
|
||||
# Snippets for Console Debug Output
|
||||
|
||||
snippet ca "console.assert" b
|
||||
@ -121,6 +129,10 @@ snippet cl "console.log" b
|
||||
console.log(${1:"${2:value}"});
|
||||
endsnippet
|
||||
|
||||
snippet cd "console.debug" b
|
||||
console.debug(${1:"${2:value}"});
|
||||
endsnippet
|
||||
|
||||
snippet cprof "console.profile" b
|
||||
console.profile("${1:label}");
|
||||
${VISUAL}$0
|
||||
|
@ -0,0 +1,25 @@
|
||||
priority -50
|
||||
|
||||
snippet iti "it (js, inject)" b
|
||||
it('${1:description}', inject(function($2) {
|
||||
$0
|
||||
}));
|
||||
endsnippet
|
||||
|
||||
snippet befi "before each (js, inject)" b
|
||||
beforeEach(inject(function($1) {
|
||||
$0
|
||||
}));
|
||||
endsnippet
|
||||
|
||||
snippet aconf "angular config" i
|
||||
config(function($1) {
|
||||
$0
|
||||
});
|
||||
endsnippet
|
||||
|
||||
snippet acont "angular controller" i
|
||||
controller('${1:name}', function($2) {
|
||||
$0
|
||||
});
|
||||
endsnippet
|
34
sources_non_forked/vim-snippets/UltiSnips/julia.snippets
Normal file
34
sources_non_forked/vim-snippets/UltiSnips/julia.snippets
Normal file
@ -0,0 +1,34 @@
|
||||
# Documentation
|
||||
snippet docf "function documentation" b
|
||||
#' @description
|
||||
#'
|
||||
#' ${1:function description}
|
||||
#'
|
||||
#' ${2:@param ${3:name}::${4:Type} ${5:Description}}
|
||||
#'
|
||||
#' ${6:@returns ${7:name}::${8:Type} ${9:Description}}
|
||||
#'
|
||||
#' @examples
|
||||
#'
|
||||
#' ${10: function call examples}
|
||||
endsnippet
|
||||
|
||||
snippet doct "type definition" b
|
||||
#' @description
|
||||
#'
|
||||
#' ${1:type description}
|
||||
#'
|
||||
#' ${2:@field ${3:name}::${4:Type} ${5:Description}}
|
||||
#'
|
||||
#' @examples
|
||||
#'
|
||||
#' ${10: constructor examples}
|
||||
endsnippet
|
||||
|
||||
snippet par "function parameter documentation" b
|
||||
#' @param ${1:name}::${2:Type} ${0:Description}
|
||||
endsnippet
|
||||
|
||||
snippet fld "type field documentation" b
|
||||
#' @field ${1:name}::${2:Type} ${0:Description}
|
||||
endsnippet
|
@ -39,4 +39,15 @@ snippet img "Image"
|
||||
$0
|
||||
endsnippet
|
||||
|
||||
snippet ilc "Inline Code" i
|
||||
\`$1\`$0
|
||||
endsnippet
|
||||
|
||||
snippet cbl "Codeblock" b
|
||||
\`\`\`
|
||||
$1
|
||||
\`\`\`
|
||||
$0
|
||||
endsnippet
|
||||
|
||||
# vim:ft=snippets:
|
||||
|
@ -0,0 +1,3 @@
|
||||
priority -49
|
||||
|
||||
extends markdown
|
@ -3,6 +3,28 @@
|
||||
|
||||
priority -50
|
||||
|
||||
snippet classn "Basic class with namespace snippet" b
|
||||
namespace `!p
|
||||
abspath = os.path.abspath(path)
|
||||
m = re.search(r'[A-Z].+(?=/)', abspath)
|
||||
if m:
|
||||
snip.rv = m.group().replace('/', '\\')
|
||||
`;
|
||||
|
||||
/**
|
||||
* ${1:@author `whoami`}
|
||||
*/
|
||||
class `!p
|
||||
snip.rv = re.match(r'.*(?=\.)', fn).group()
|
||||
`$2
|
||||
{
|
||||
public function __construct(${3:$options})
|
||||
{
|
||||
${4:// code}
|
||||
}$0
|
||||
}
|
||||
endsnippet
|
||||
|
||||
snippet contr "Symfony2 controller" b
|
||||
namespace `!p
|
||||
abspath = os.path.abspath(path)
|
||||
|
@ -1,9 +1,42 @@
|
||||
priority -50
|
||||
|
||||
global !p
|
||||
import os
|
||||
from vimsnippets import complete
|
||||
|
||||
FIELD_TYPES = [
|
||||
'character',
|
||||
'data.frame',
|
||||
'integer',
|
||||
'list',
|
||||
'logical',
|
||||
'matrix',
|
||||
'numeric',
|
||||
'vector']
|
||||
endglobal
|
||||
|
||||
snippet #! "Hashbang for Rscript (#!)" b
|
||||
#!/usr/bin/env Rscript
|
||||
endsnippet
|
||||
|
||||
snippet setwd "Set workingdir" b
|
||||
setwd("${1:`!p snip.rv = os.getcwd()`}")
|
||||
endsnippet
|
||||
|
||||
snippet as "Apply type on variable" w
|
||||
as.$1`!p snip.rv = complete(t[1], FIELD_TYPES)`(${2}${VISUAL})
|
||||
endsnippet
|
||||
|
||||
snippet is "Test type on variable" w
|
||||
is.$1`!p snip.rv = complete(t[1], FIELD_TYPES)`(${2}${VISUAL})
|
||||
endsnippet
|
||||
|
||||
snippet dl "Download and install a package" b
|
||||
download.file("${1:${VISUAL:url to package}}", destfile = "${2:${1/.*\/(\S*)$/(?1:$1)/ga}}")
|
||||
install.packages("$2", type = "source", repos = NULL)
|
||||
library("${3:${2/^(\w+)_.*$/(?1:$1)/ga}}")
|
||||
endsnippet
|
||||
|
||||
snippet lib "Import a library"
|
||||
library(${0:package})
|
||||
endsnippet
|
||||
@ -48,7 +81,7 @@ while(${1}) {
|
||||
endsnippet
|
||||
|
||||
snippet for "for loop"
|
||||
for ({${1:item} in ${2:list}) {
|
||||
for (${1:item} in ${2:list}) {
|
||||
${3}
|
||||
}
|
||||
endsnippet
|
||||
@ -88,7 +121,7 @@ lapply(${1:list}, ${0:function})
|
||||
endsnippet
|
||||
|
||||
snippet sapply "sapply function"
|
||||
lapply(${1:list}, ${0:function})
|
||||
sapply(${1:list}, ${0:function})
|
||||
endsnippet
|
||||
|
||||
snippet vapply "vapply function"
|
||||
|
@ -2,45 +2,70 @@
|
||||
# Rust Snippets #
|
||||
#######################################################################
|
||||
|
||||
###############
|
||||
# Functions #
|
||||
###############
|
||||
snippet fn "A function, optionally with arguments and return type."
|
||||
priority -50
|
||||
|
||||
snippet fn "A function, optionally with arguments and return type." b
|
||||
fn ${1:function_name}(${2})${3/..*/ -> /}${3} {
|
||||
${VISUAL}${0:${VISUAL/(.*)/(?1::\/* code *\/)/}}
|
||||
${VISUAL}${0}
|
||||
}
|
||||
endsnippet
|
||||
|
||||
snippet test "Test function"
|
||||
snippet test "Test function" b
|
||||
#[test]
|
||||
fn ${1:test_function_name}() {
|
||||
${VISUAL}${0:${VISUAL/(.*)/(?1::\/* code *\/)/}}
|
||||
}
|
||||
endsnippet
|
||||
|
||||
snippet new "A new function"
|
||||
pub fn new(${2}) -> ${1:Name} {
|
||||
${VISUAL}${0}return $1 { ${3} };
|
||||
}
|
||||
endsnippet
|
||||
|
||||
snippet main "The main function"
|
||||
pub fn main() {
|
||||
${VISUAL}${0}
|
||||
}
|
||||
endsnippet
|
||||
|
||||
|
||||
snippet bench "Bench function" b
|
||||
#[bench]
|
||||
fn ${1:bench_function_name}(b: &mut test::Bencher) {
|
||||
b.iter(|| {
|
||||
${VISUAL}${0}
|
||||
})
|
||||
}
|
||||
endsnippet
|
||||
|
||||
snippet let "A let statement"
|
||||
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
|
||||
|
||||
snippet pln "println!(..)" b
|
||||
println!("${1}"${2/..*/, /}${2});
|
||||
endsnippet
|
||||
|
||||
snippet fmt "format!(..)"
|
||||
format!("${1}"${2/..*/, /}${2});
|
||||
endsnippet
|
||||
|
||||
snippet macro "macro_rules!" b
|
||||
macro_rules! ${1:name} (
|
||||
(${2:matcher}) => (
|
||||
${3}
|
||||
)
|
||||
)
|
||||
endsnippet
|
||||
|
||||
snippet ec "extern crate ..." b
|
||||
extern crate ${1:sync};
|
||||
@ -51,10 +76,10 @@ snippet ecl "...extern crate log;" b
|
||||
#[phase(syntax, link)] extern crate log;
|
||||
endsnippet
|
||||
|
||||
snippet mod "A mod." b
|
||||
snippet mod "A module" b
|
||||
mod ${1:`!p snip.rv = snip.basename.lower() or "name"`} {
|
||||
${VISUAL}${0:${VISUAL/(.*)/(?1::\/* code *\/)/}}
|
||||
} /* $1 */
|
||||
${VISUAL}${0}
|
||||
}
|
||||
endsnippet
|
||||
|
||||
snippet crate "Create header information" b
|
||||
@ -78,24 +103,45 @@ snippet feat "#![feature(..)]" b
|
||||
#![feature(${1:macro_rules})]
|
||||
endsnippet
|
||||
|
||||
snippet der "#[deriving(..)]" b
|
||||
#[deriving(${1:Show})]
|
||||
endsnippet
|
||||
|
||||
snippet attr "#[..]" b
|
||||
#[${1:inline}]
|
||||
endsnippet
|
||||
|
||||
##################
|
||||
# Common types #
|
||||
##################
|
||||
snippet opt "Option<..>"
|
||||
Option<${1:int}>
|
||||
endsnippet
|
||||
|
||||
snippet res "Result<.., ..>"
|
||||
Result<${1:~str}, ${2:()}>
|
||||
Result<${1:int}, ${2:()}>
|
||||
endsnippet
|
||||
|
||||
|
||||
|
||||
|
||||
snippet if "if .. (if)" b
|
||||
if ${1:/* condition */} {
|
||||
${VISUAL}${0:${VISUAL/(.*)/(?1::\/* code *\/)/}}
|
||||
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
|
||||
|
||||
@ -105,21 +151,27 @@ match ${1} {
|
||||
}
|
||||
endsnippet
|
||||
|
||||
snippet loop "loop {}" b
|
||||
loop {
|
||||
${VISUAL}${0}
|
||||
}
|
||||
endsnippet
|
||||
|
||||
snippet while "while .. {}" b
|
||||
while ${1:condition} {
|
||||
${VISUAL}${0:${VISUAL/(.*)/(?1::\/* code *\/)/}}
|
||||
while ${1} {
|
||||
${VISUAL}${0}
|
||||
}
|
||||
endsnippet
|
||||
|
||||
snippet for "for .. in .." b
|
||||
for ${1:i} in ${2:range(0u, 10)} {
|
||||
${VISUAL}${0:${VISUAL/(.*)/(?1::\/* code *\/)/}}
|
||||
${VISUAL}${0}
|
||||
}
|
||||
endsnippet
|
||||
|
||||
snippet spawn "spawn(proc() { .. });" b
|
||||
spawn(proc() {
|
||||
${VISUAL}${0:${VISUAL/(.*)/(?1::\/* code *\/)/}}
|
||||
${VISUAL}${0}
|
||||
});
|
||||
endsnippet
|
||||
|
||||
@ -131,26 +183,23 @@ snippet duplex "Duplex stream" b
|
||||
let (${1:from_child}, ${2:to_child}) = sync::duplex();
|
||||
endsnippet
|
||||
|
||||
#####################
|
||||
# TODO commenting #
|
||||
#####################
|
||||
snippet todo "A Todo comment"
|
||||
// [TODO]: ${1:Description} - `!v strftime("%Y-%m-%d %I:%M%P")`
|
||||
endsnippet
|
||||
|
||||
snippet fixme "FIXME comment"
|
||||
// FIXME: ${1}
|
||||
endsnippet
|
||||
|
||||
############
|
||||
# Struct #
|
||||
############
|
||||
snippet st "Struct" b
|
||||
struct ${1:`!p snip.rv = snip.basename.title() or "name"`} {
|
||||
${VISUAL}${0:${VISUAL/(.*)/(?1::\/* code *\/)/}}
|
||||
struct ${1:`!p snip.rv = snip.basename.title() or "Name"`} {
|
||||
${VISUAL}${0}
|
||||
}
|
||||
endsnippet
|
||||
|
||||
snippet stn "Struct with new constructor." b
|
||||
pub struct ${1:`!p snip.rv = snip.basename.title() or "name"`} {
|
||||
${3:/* code */}
|
||||
pub struct ${1:`!p snip.rv = snip.basename.title() or "Name"`} {
|
||||
${3}
|
||||
}
|
||||
|
||||
impl $1 {
|
||||
@ -162,48 +211,36 @@ impl $1 {
|
||||
}
|
||||
endsnippet
|
||||
|
||||
|
||||
##########
|
||||
# Enum #
|
||||
##########
|
||||
snippet enum "An enum" b
|
||||
enum ${1:enum_name} {
|
||||
enum ${1:Name} {
|
||||
${VISUAL}${0},
|
||||
}
|
||||
endsnippet
|
||||
|
||||
snippet type "A type" b
|
||||
type ${1:NewName} = ${VISUAL}${0};
|
||||
endsnippet
|
||||
|
||||
##########
|
||||
# Impl #
|
||||
##########
|
||||
snippet imp "An impl" b
|
||||
impl ${1:Name} {
|
||||
${VISUAL}${0:${VISUAL/(.*)/(?1::\/* code *\/)/}}
|
||||
${VISUAL}${0}
|
||||
}
|
||||
endsnippet
|
||||
|
||||
snippet drop "Drop implementation" b
|
||||
impl Drop for ${1:Name} {
|
||||
fn drop(&mut self) {
|
||||
${VISUAL}${0:${VISUAL/(.*)/(?1::\/* code *\/)/}}
|
||||
${VISUAL}${0}
|
||||
}
|
||||
}
|
||||
endsnippet
|
||||
|
||||
|
||||
############
|
||||
# Traits #
|
||||
############
|
||||
snippet trait "Trait block" b
|
||||
snippet trait "Trait definition" b
|
||||
trait ${1:Name} {
|
||||
${VISUAL}${0:${VISUAL/(.*)/(?1::\/* code *\/)/}}
|
||||
${VISUAL}${0}
|
||||
}
|
||||
endsnippet
|
||||
|
||||
|
||||
#############
|
||||
# Statics #
|
||||
#############
|
||||
snippet ss "A static string."
|
||||
static ${1}: &'static str = "${VISUAL}${0}";
|
||||
endsnippet
|
||||
|
@ -8,7 +8,7 @@ snippet "b(egin)?" "begin{} / end{}" br
|
||||
\end{$1}
|
||||
endsnippet
|
||||
|
||||
snippet tab
|
||||
snippet tab "tabular / array environment" b
|
||||
\begin{${1:t}${1/(t)$|(a)$|(.*)/(?1:abular)(?2:rray)/}}{${2:c}}
|
||||
$0${2/((?<=.)c|l|r)|./(?1: & )/g}
|
||||
\end{$1${1/(t)$|(a)$|(.*)/(?1:abular)(?2:rray)/}}
|
||||
|
@ -3,58 +3,22 @@ priority -50
|
||||
###########################################################################
|
||||
# SnipMate Snippets #
|
||||
###########################################################################
|
||||
snippet header
|
||||
" File: ${1:`!v expand('%:t')`}
|
||||
" Author: ${2:`!v g:snips_author`}
|
||||
" Description: ${3}
|
||||
${4:" Last Modified: `!v strftime("%B %d, %Y")`}
|
||||
|
||||
$0
|
||||
endsnippet
|
||||
|
||||
snippet gvar "Global / configuration variable"
|
||||
snippet gvar "Global / configuration variable" b
|
||||
if !exists("g:${1:MyUltraImportantVar}")
|
||||
let g:$1 = ${2:"${3:<tab>}"}
|
||||
endif
|
||||
endsnippet
|
||||
|
||||
snippet guard
|
||||
snippet guard "script reload guard" b
|
||||
if exists('${1:did_`!p snip.rv = snip.fn.replace('.','_')`}') || &cp${2: || version < 700}
|
||||
finish
|
||||
endif
|
||||
let $1 = 1${3}
|
||||
endsnippet
|
||||
|
||||
snippet f
|
||||
snippet f "function" b
|
||||
fun ${1:function_name}(${2})
|
||||
${3:" code}
|
||||
endf
|
||||
endsnippet
|
||||
|
||||
snippet for
|
||||
for ${1:needle} in ${2:haystack}
|
||||
${3:" code}
|
||||
endfor
|
||||
endsnippet
|
||||
|
||||
snippet wh
|
||||
while ${1:condition}
|
||||
${2:" code}
|
||||
endw
|
||||
endsnippet
|
||||
|
||||
snippet if
|
||||
if ${1:condition}
|
||||
${2:" code}
|
||||
endif
|
||||
endsnippet
|
||||
|
||||
snippet ife
|
||||
if ${1:condition}
|
||||
${2}
|
||||
else
|
||||
${3}
|
||||
endif
|
||||
endsnippet
|
||||
|
||||
# vim:ft=snippets:
|
||||
|
Reference in New Issue
Block a user