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

Updated plugins

This commit is contained in:
amix
2015-03-14 20:02:10 +00:00
parent d195ccb777
commit 2cb073a57d
73 changed files with 1098 additions and 525 deletions

View File

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

View File

@ -32,13 +32,13 @@ 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}
@ -114,4 +114,4 @@ snippet try try .. rescue .. end
end
snippet pry
require IEx; IEx.pry
$0
${0}

View File

@ -592,6 +592,10 @@ snippet link:rss
<link rel="alternate" href="${1:rss.xml}" title="RSS" type="application/atom+xml" />
snippet link:touch
<link rel="apple-touch-icon" href="${1:favicon.png}" />
snippet main
<main role="main">
${0}
</main>
snippet map
<map name="${1}">
${0}

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}) {
@ -252,6 +257,10 @@ snippet cdir
# Misc
# 'use strict';
snippet us
'use strict';
# setTimeout function
snippet timeout
setTimeout(function () {${0}}${2}, ${1:10});

View File

@ -36,7 +36,7 @@ snippet crw
cattr_accessor :${0:attr_names}
snippet defcreate
def create
@${1:model_class_name} = ${2:ModelClassName}.new(params[:$1])
@${1:model_class_name} = ${2:ModelClassName}.new($1_params)
respond_to do |format|
if @$1.save
@ -95,7 +95,7 @@ snippet defupdate
@${1:model_class_name} = ${2:ModelClassName}.find(params[:id])
respond_to do |format|
if @$1.update_attributes(params[:$1])
if @$1.update($1_params)
flash[:notice] = '$2 was successfully updated.'
format.html { redirect_to(@$1) }
format.xml { head :ok }
@ -105,6 +105,10 @@ snippet defupdate
end
end
end
snippet defparams
def ${1:model_class_name}_params
params.require(:$1).permit()
end
snippet dele delegate .. to
delegate :${1:methods}, to: :${0:object}
snippet dele delegate .. to .. prefix .. allow_nil

View File

@ -3,11 +3,11 @@
#################
# Functions
snippet fn
snippet fn "Function definition"
fn ${1:function_name}(${2})${3} {
${0}
}
snippet test
snippet test "Unit test function"
#[test]
fn ${1:test_function_name}() {
${0}
@ -19,32 +19,51 @@ snippet bench "Bench function" b
${0}
})
}
snippet new
snippet new "Constructor function"
pub fn new(${2}) -> ${1:Name} {
${0}return $1 { ${3} };
$1 { ${3} };
}
snippet main
snippet main "Main function"
pub fn main() {
${0}
}
snippet let
let ${1:name: type} = ${2};
snippet let
let mut ${1:name: type} = ${2};
snippet pln
snippet let "let variable declaration"
let ${1:name}${2:: ${3:type}} = ${4};
snippet letm "let mut variable declaration"
let mut ${1:name}${2:: ${3:type}} = ${4};
snippet pln "println!"
println!("${1}");
snippet pln,
snippet pln, "println! with format param"
println!("${1}", ${2});
snippet ec
# Modules
snippet ec "extern crate"
extern crate ${1:sync};
snippet ecl
#![feature(phase)]
#[phase(plugin, link)] extern crate log;
snippet ecl "extern crate log"
#[macro_use]
extern crate log;
snippet mod
mod ${1:`substitute(vim_snippets#Filename(), '\(_\|^\)\(.\)', '\u\2', 'g')`} {
${0}
} /* $1 */
snippet crate
snippet testmod "Test module" b
#[cfg(test)]
mod tests {
use super::${1:*};
test${0}
}
# Attributes
snippet allow "allow lint attribute" b
#[allow(${1:unused_variable})]
snippet cfg "cfg attribute" b
#[cfg(${1:target_os = "linux"})]
snippet feat "feature attribute" b
#![feature(${1:plugin})]
snippet der "#[derive(..)]" b
#[derive(${1:Debug})]
snippet attr "#[..]" b
#[${1:inline}]
snippet crate "Define create meta attributes"
// Crate name
#![crate_name = "${1:crate_name}"]
// Additional metadata attributes
@ -53,110 +72,107 @@ snippet crate
#![comment = "${4:Comment.}"]
// Specify the output type
#![crate_type = "${5:lib}"]
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
snippet opt "Option<T>"
Option<${1:i32}>
snippet res "Result<T, E>"
Result<${1:~str}, ${2:()}>
# Control structures
snippet if
if ${1} {
${0}
}
snippet ife
snippet ife "if / else"
if ${1} {
${2}
} else {
${0}
}
snippet el
snippet el "else"
else {
${0}
}
snippet eli
snippet eli "else if"
else if ${1} {
${0}
}
snippet mat
snippet mat "match pattern"
match ${1} {
${2} => ${3},
${2} => ${3}
}
snippet case "Case clause of pattern match"
${1:_} => ${2:expression}
snippet loop "loop {}" b
loop {
${0}
}
snippet while
snippet while "while loop"
while ${1:condition} {
${0}
}
snippet for
snippet for "for ... in ... loop"
for ${1:i} in ${2:0u..10} {
${0}
}
snippet spawn
spawn(proc() {
${0}
});
snippet chan
let (${1:tx}, ${2:rx}): (Sender<${3:int}>, Receiver<${4:int}>) = channel();
snippet duplex
let (${1:from_child}, ${2:to_child}) = sync::duplex();
# TODO commenting
snippet todo
snippet todo "TODO comment"
// [TODO]: ${0:Description}
snippet fixme "FIXME comment"
// FIXME: $0
# Struct
snippet st
snippet st "Struct definition"
struct ${1:`substitute(vim_snippets#Filename(), '\(_\|^\)\(.\)', '\u\2', 'g')`} {
${0}
}
snippet stn
struct ${1:`substitute(vim_snippets#Filename(), '\(_\|^\)\(.\)', '\u\2', 'g')`} {
snippet impl "Struct/Trait implementation"
impl ${1:Type/Trait}${2: for ${3:Type}} {
${0}
}
snippet stn "Struct with new constructor"
pub struct ${1:`substitute(vim_snippets#Filename(), '\(_\|^\)\(.\)', '\u\2', 'g')`} {
${0}
}
impl $1 {
pub fn new(${2}) -> $1 {
${4}return $1 {
${5}
};
$1 { ${3} };
}
}
snippet typ
type ${1:NewName} = $0;
# Enum
snippet enum
snippet type "Type alias"
type ${1:NewName} = $2;
snippet enum "enum definition"
enum ${1:Name} {
${0},
${2},
}
# Impl
snippet imp
impl ${1:Name} {
# Traits
snippet trait "Trait definition"
trait ${1:Name} {
${0}
}
snippet drop
snippet drop "Drop trait implementation (destructor)"
impl Drop for ${1:Name} {
fn drop(&mut self) {
${0}
}
}
# Traits
snippet trait
trait ${1:Name} {
${0}
}
# Statics
snippet ss
snippet ss "static string declaration"
static ${1}: &'static str = "${0}";
snippet stat
snippet stat "static item declaration"
static ${1}: ${2:usize} = ${0};
# Concurrency
snippet scoped "spawn a scoped thread"
thread::scoped(${1:move }|| {
${0}
});
snippet spawn "spawn a thread"
thread::spawn(${1:move }|| {
${0}
});
snippet chan "Declare (Sender, Receiver) pair of asynchronous channel()"
let (${1:tx}, ${2:rx}): (Sender<${3:i32}>, Receiver<${4:i32}>) = channel();
# Testing
snippet as "assert!"
assert!(${1:predicate})
snippet ase "assert_eq!"
assert_eq!(${1:expected}, ${2:actual})

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