/usr/share/vim/addons/UltiSnips/go.snippets is in vim-snippets 1.0.0-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 | # 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
# statements
snippet for "For loop" b
for ${1:condition}${1/(.+)/ /}{
${0:${VISUAL}}
}
endsnippet
snippet forr "For range loop" b
for ${2:name} := range ${1:collection} {
${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
snippet select "Select statement" b
select {
case${0}
}
endsnippet
snippet case "Case clause" b
case ${1:condition}:
${0:${VISUAL}}
endsnippet
snippet default "Default clause" b
default:
${0:${VISUAL}}
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
# 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:
|