aboutsummaryrefslogtreecommitdiff
path: root/vim/bundle/vim-snippets/UltiSnips/rust.snippets
diff options
context:
space:
mode:
authorKarel Kočí <cynerd@email.cz>2016-06-30 16:03:25 +0200
committerKarel Kočí <cynerd@email.cz>2016-06-30 16:03:25 +0200
commite573b3020c032400eed60b649a2cbf55266e6bb0 (patch)
tree8f572394ac8433529c7a8e70d160a2fbe8268b4e /vim/bundle/vim-snippets/UltiSnips/rust.snippets
parentb8c667bd64b3edd38d56c63c5bd1db53a23b4499 (diff)
downloadmyconfigs-e573b3020c032400eed60b649a2cbf55266e6bb0.tar.gz
myconfigs-e573b3020c032400eed60b649a2cbf55266e6bb0.tar.bz2
myconfigs-e573b3020c032400eed60b649a2cbf55266e6bb0.zip
Add current configurations from old repository
Diffstat (limited to 'vim/bundle/vim-snippets/UltiSnips/rust.snippets')
-rw-r--r--vim/bundle/vim-snippets/UltiSnips/rust.snippets106
1 files changed, 106 insertions, 0 deletions
diff --git a/vim/bundle/vim-snippets/UltiSnips/rust.snippets b/vim/bundle/vim-snippets/UltiSnips/rust.snippets
new file mode 100644
index 0000000..40e7605
--- /dev/null
+++ b/vim/bundle/vim-snippets/UltiSnips/rust.snippets
@@ -0,0 +1,106 @@
+#######################################################################
+# Rust Snippets #
+#######################################################################
+
+priority -50
+
+snippet let "let variable declaration" b
+let ${1:name}${2:: ${3:type}} = ${4};
+endsnippet
+
+snippet letm "let mut variable declaration" b
+let mut ${1:name}${2:: ${3:type}} = ${4};
+endsnippet
+
+snippet fn "A function, optionally with arguments and return type."
+fn ${1:function_name}(${2})${3/..*/ -> /}${3} {
+ ${VISUAL}${0}
+}
+endsnippet
+
+snippet pfn "A public function, optionally with arguments and return type."
+pub fn ${1:function_name}(${2})${3/..*/ -> /}${3} {
+ ${VISUAL}${0}
+}
+endsnippet
+
+snippet arg "Function Arguments" i
+${1:a}: ${2:T}${3:, arg}
+endsnippet
+
+snippet || "Closure, anonymous function (inline)" i
+${1:move }|${2}| { $3 }
+endsnippet
+
+snippet |} "Closure, anonymous function (block)" i
+${1:move }|${2}| {
+ $3
+}
+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 mod "A module" b
+mod ${1:`!p snip.rv = snip.basename.lower() or "name"`} {
+ ${VISUAL}${0}
+}
+endsnippet
+
+snippet for "for .. in .." b
+for ${1:i} in ${2} {
+ ${VISUAL}${0}
+}
+endsnippet
+
+snippet todo "A Todo comment"
+// [TODO]: ${1:Description} - `!v strftime("%Y-%m-%d %I:%M%P")`
+endsnippet
+
+snippet st "Struct" b
+struct ${1:`!p snip.rv = snip.basename.title() or "Name"`} {
+ ${VISUAL}${0}
+}
+endsnippet
+
+# TODO: fancy dynamic field mirroring like Python slotclass
+snippet stn "Struct with new constructor." b
+pub struct ${1:`!p snip.rv = snip.basename.title() or "Name"`} {
+ fd${0}
+}
+
+impl $1 {
+ pub fn new(${2}) -> $1 {
+ $1 { ${3} }
+ }
+}
+endsnippet
+
+snippet fd "Struct field definition" w
+${1:name}: ${2:Type},
+endsnippet
+
+snippet impl "Struct/Trait implementation" b
+impl ${1:Type/Trait}${2: for ${3:Type}} {
+ ${0}
+}
+endsnippet
+
+# vim:ft=snippets: