Some checks failed
Detach Plugins / check (FlyGrep.vim) (push) Has been cancelled
Detach Plugins / check (GitHub.vim) (push) Has been cancelled
Detach Plugins / check (JavaUnit.vim) (push) Has been cancelled
Detach Plugins / check (SourceCounter.vim) (push) Has been cancelled
Detach Plugins / check (cpicker.nvim) (push) Has been cancelled
Detach Plugins / check (dein-ui.vim) (push) Has been cancelled
Detach Plugins / check (git.vim) (push) Has been cancelled
Detach Plugins / check (iedit.vim) (push) Has been cancelled
Detach Plugins / check (scrollbar.vim) (push) Has been cancelled
Detach Plugins / check (vim-chat) (push) Has been cancelled
Detach Plugins / check (vim-cheat) (push) Has been cancelled
Detach Plugins / check (vim-todo) (push) Has been cancelled
Detach Plugins / check (xmake.vim) (push) Has been cancelled
test / Linux (nvim, nightly) (push) Has been cancelled
test / Linux (nvim, v0.3.8) (push) Has been cancelled
test / Linux (nvim, v0.4.0) (push) Has been cancelled
test / Linux (nvim, v0.4.2) (push) Has been cancelled
test / Linux (nvim, v0.4.3) (push) Has been cancelled
test / Linux (nvim, v0.4.4) (push) Has been cancelled
test / Linux (nvim, v0.5.0) (push) Has been cancelled
test / Linux (nvim, v0.5.1) (push) Has been cancelled
test / Linux (nvim, v0.6.0) (push) Has been cancelled
test / Linux (nvim, v0.6.1) (push) Has been cancelled
test / Linux (nvim, v0.7.0) (push) Has been cancelled
test / Linux (nvim, v0.7.2) (push) Has been cancelled
test / Linux (nvim, v0.8.0) (push) Has been cancelled
test / Linux (nvim, v0.8.1) (push) Has been cancelled
test / Linux (nvim, v0.8.2) (push) Has been cancelled
test / Linux (nvim, v0.8.3) (push) Has been cancelled
test / Linux (nvim, v0.9.0) (push) Has been cancelled
test / Linux (nvim, v0.9.1) (push) Has been cancelled
test / Linux (true, vim, v7.4.052) (push) Has been cancelled
test / Linux (true, vim, v7.4.1689) (push) Has been cancelled
test / Linux (true, vim, v7.4.629) (push) Has been cancelled
test / Linux (true, vim, v8.0.0027) (push) Has been cancelled
test / Linux (true, vim, v8.0.0183) (push) Has been cancelled
test / Linux (vim, nightly) (push) Has been cancelled
test / Linux (vim, v8.0.0184) (push) Has been cancelled
test / Linux (vim, v8.0.1453) (push) Has been cancelled
test / Linux (vim, v8.1.2269) (push) Has been cancelled
test / Linux (vim, v8.2.2434) (push) Has been cancelled
test / Linux (vim, v8.2.3995) (push) Has been cancelled
test / Windows (nvim, nightly) (push) Has been cancelled
test / Windows (nvim, v0.3.8) (push) Has been cancelled
test / Windows (nvim, v0.4.2) (push) Has been cancelled
test / Windows (nvim, v0.4.3) (push) Has been cancelled
test / Windows (nvim, v0.4.4) (push) Has been cancelled
test / Windows (nvim, v0.5.0) (push) Has been cancelled
test / Windows (nvim, v0.5.1) (push) Has been cancelled
test / Windows (nvim, v0.6.0) (push) Has been cancelled
test / Windows (nvim, v0.6.1) (push) Has been cancelled
test / Windows (nvim, v0.7.0) (push) Has been cancelled
test / Windows (nvim, v0.7.2) (push) Has been cancelled
test / Windows (nvim, v0.8.0) (push) Has been cancelled
test / Windows (nvim, v0.8.1) (push) Has been cancelled
test / Windows (nvim, v0.8.2) (push) Has been cancelled
test / Windows (nvim, v0.8.3) (push) Has been cancelled
test / Windows (nvim, v0.9.0) (push) Has been cancelled
test / Windows (nvim, v0.9.1) (push) Has been cancelled
test / Windows (vim, nightly) (push) Has been cancelled
test / Windows (vim, v7.4.1185) (push) Has been cancelled
test / Windows (vim, v7.4.1689) (push) Has been cancelled
test / Windows (vim, v8.0.0027) (push) Has been cancelled
test / Windows (vim, v8.0.1453) (push) Has been cancelled
test / Windows (vim, v8.1.2269) (push) Has been cancelled
test / Windows (vim, v8.2.2434) (push) Has been cancelled
test / Windows (vim, v8.2.3995) (push) Has been cancelled
docker / docker (push) Has been cancelled
mirror / check (coding) (push) Has been cancelled
mirror / check (gitee) (push) Has been cancelled
mirror / check (gitlab) (push) Has been cancelled
116 lines
2.1 KiB
Plaintext
116 lines
2.1 KiB
Plaintext
# Snippets for Go
|
|
|
|
priority -50
|
|
|
|
# when to abbriviate and when not?
|
|
# b doesn't work here, because it ignores whitespace
|
|
# optional local name?
|
|
snippet /^import/ "Import declaration" r
|
|
import (
|
|
"${1:package}"
|
|
)
|
|
endsnippet
|
|
|
|
snippet /^package/ "Package declaration" r
|
|
// Package $1 provides ...
|
|
package ${1:main}
|
|
endsnippet
|
|
|
|
# Mostly converted from: https://github.com/AlanQuatermain/go-tmbundle
|
|
snippet /^cons/ "Constants declaration" r
|
|
const (
|
|
${1:constant}${2/(.+)/ /}${2:type} = ${0:value}
|
|
)
|
|
endsnippet
|
|
|
|
snippet /^con/ "Constant declaration" r
|
|
const ${1:name}${2/(.+)/ /}${2:type} = ${0:value}
|
|
endsnippet
|
|
|
|
snippet iota "Iota constant generator" b
|
|
const (
|
|
${1:constant}${2/(.+)/ /}${2:type} = iota
|
|
)
|
|
endsnippet
|
|
|
|
snippet struct "Struct declaration" b
|
|
type ${1:Struct} struct {
|
|
${0:${VISUAL}}
|
|
}
|
|
endsnippet
|
|
|
|
snippet interface "Interface declaration" b
|
|
type ${1:Interface} interface {
|
|
${0:${VISUAL}}
|
|
}
|
|
endsnippet
|
|
|
|
snippet if "If statement" b
|
|
if ${1:condition}${1/(.+)/ /}{
|
|
${0:${VISUAL}}
|
|
}
|
|
endsnippet
|
|
|
|
snippet switch "Switch statement" b
|
|
switch ${1:expression}${1/(.+)/ /}{
|
|
case$0
|
|
}
|
|
endsnippet
|
|
|
|
# functions
|
|
snippet /^main/ "Main function" r
|
|
func main() {
|
|
${0:${VISUAL}}
|
|
}
|
|
endsnippet
|
|
|
|
snippet /^meth/ "Method" r
|
|
func (${1:receiver} ${2:type}) ${3:name}(${4:params})${5/(.+)/ /}${5:type} {
|
|
${0:${VISUAL}}
|
|
}
|
|
endsnippet
|
|
|
|
snippet func "Function" b
|
|
func ${1:name}(${2:params})${3/(.+)/ /}${3:type} {
|
|
${0:${VISUAL}}
|
|
}
|
|
endsnippet
|
|
|
|
snippet funch "HTTP handler" b
|
|
func ${1:handler}(${2:w} http.ResponseWriter, ${3:r} *http.Request) {
|
|
${0:${VISUAL}}
|
|
}
|
|
endsnippet
|
|
|
|
# types and variables
|
|
snippet map "Map type" b
|
|
map[${1:keytype}]${2:valtype}
|
|
endsnippet
|
|
|
|
snippet : "Variable declaration :=" b
|
|
${1:name} := ${0:value}
|
|
endsnippet
|
|
|
|
snippet var "Variable declaration" b
|
|
var ${1:name}${2/(.+)/ /}${2:type}${3: = ${0:value}}
|
|
endsnippet
|
|
|
|
snippet vars "Variables declaration" b
|
|
var (
|
|
${1:name}${2/(.+)/ /}${2:type}${3: = ${0:value} }
|
|
)
|
|
endsnippet
|
|
|
|
snippet json "JSON field"
|
|
\`json:"${1:displayName}"\`
|
|
endsnippet
|
|
|
|
# vim:ft=snippets:
|
|
|
|
# error handling
|
|
snippet err "Basic error handling" b
|
|
if err != nil {
|
|
log.${1:Fatal}(err)
|
|
}
|
|
endsnippet
|