Updated go snippets, added json snippets

This commit is contained in:
Holger Rapp 2012-02-24 09:42:56 +01:00
parent 45b1d09d53
commit f8af2e2fa6
2 changed files with 32 additions and 13 deletions

View File

@ -5,7 +5,7 @@
# optional local name?
snippet /^import/ "Import declaration" r
import (
"${1:package}"
"${1:package}"
)
endsnippet
@ -17,7 +17,7 @@ endsnippet
# Mostly converted from: https://github.com/AlanQuatermain/go-tmbundle
snippet /^cons/ "Constants declaration" r
const (
${1:constant}${2/(.+)/ /}${2:type} = ${0:value}
${1:constant}${2/(.+)/ /}${2:type} = ${0:value}
)
endsnippet
@ -27,26 +27,26 @@ endsnippet
snippet iota "Iota constant generator" b
const (
${1:constant}${2/(.+)/ /}${2:type} = iota
${1:constant}${2/(.+)/ /}${2:type} = iota
)
endsnippet
# statements
snippet for "For loop" !b
for ${1:condition}${1/(.+)/ /}{
${0:// body}
${0:${VISUAL}}
}
endsnippet
snippet forr "For range loop" !b
for ${2:name} := range ${1:collection} {
${0:// body}
${0:${VISUAL}}
}
endsnippet
snippet if "If statement" !b
if ${1:condition}${1/(.+)/ /}{
${0:// body}
${0:${VISUAL}}
}
endsnippet
@ -58,30 +58,30 @@ endsnippet
snippet case "Case clause" !b
case ${1:condition}:
${0://body}
${0:${VISUAL}}
endsnippet
snippet default "Default clause" !b
default:
${0://body}
${0:${VISUAL}}
endsnippet
# functions
snippet /^main/ "Main function" r
func main() {
${0:// body}
${0:${VISUAL}}
}
endsnippet
snippet /^meth/ "Method" r
func (${1:receiver} ${2:type}) ${3:name}(${4:params})${5/(.+)/ /}${5:type} {
${0:// body}
${0:${VISUAL}}
}
endsnippet
snippet /^func/ "Function" r
snippet func "Function" b
func ${1:name}(${2:params})${3/(.+)/ /}${3:type} {
${0:// body}
${0:${VISUAL}}
}
endsnippet
@ -100,7 +100,7 @@ endsnippet
snippet vars "Variables declaration" !b
var (
${1:name}${2/(.+)/ /}${2:type}${3: = ${0:value} }
${1:name}${2/(.+)/ /}${2:type}${3: = ${0:value} }
)
endsnippet

19
UltiSnips/json.snippets Normal file
View File

@ -0,0 +1,19 @@
snippet s "String" b
"${1:key}": "${0:value}",
endsnippet
snippet n "number" b
"${1:key}": ${0:value},
endsnippet
snippet a "Array" b
[
${VISUAL}$0
],
endsnippet
snippet o "Object" b
{
${VISUAL}$0
},
endsnippet