mirror of
				https://github.com/amix/vimrc
				synced 2025-10-31 14:43:35 +08:00 
			
		
		
		
	Updated plugins
This commit is contained in:
		
							
								
								
									
										215
									
								
								sources_non_forked/vim-go/gosnippets/UltiSnips/go.snippets
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										215
									
								
								sources_non_forked/vim-go/gosnippets/UltiSnips/go.snippets
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,215 @@ | ||||
| # Snippets for Go | ||||
|  | ||||
| priority -10 | ||||
|  | ||||
| # when to abbriviate and when not? | ||||
| # b doesn't work here, because it ignores whitespace | ||||
| # optional local name? | ||||
| snippet import "Import declaration" b | ||||
| import ( | ||||
| 	"${1:package}" | ||||
| ) | ||||
| endsnippet | ||||
|  | ||||
| snippet package "Package declaration" b | ||||
| // Package $1 provides ${2:...} | ||||
| package ${1:main} | ||||
| ${0:${VISUAL}} | ||||
| 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} { | ||||
| 	${0:${VISUAL}} | ||||
| } | ||||
| endsnippet | ||||
|  | ||||
| snippet fori "Integer for loop" b | ||||
| for ${1:i} := 0; $1 < ${2:N}; $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 | ||||
|  | ||||
| snippet anon "Anonymous Function" !b | ||||
| ${1:fn} := func() { | ||||
| 	${2} | ||||
| } | ||||
| endsnippet | ||||
|  | ||||
| # types and variables | ||||
| snippet map "Map type" b | ||||
| map[${1:keytype}]${2:valtype} | ||||
| endsnippet | ||||
|  | ||||
| snippet : "Short 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 | ||||
|  | ||||
| snippet er "Error clause " !b | ||||
| if err != nil { | ||||
| 	${0} | ||||
| } | ||||
| endsnippet | ||||
|  | ||||
| snippet errn "Error return " !b | ||||
| if err != nil { | ||||
| 	return err | ||||
| } | ||||
| ${0} | ||||
| endsnippet | ||||
|  | ||||
| snippet errn, "Error return with two return values" !b | ||||
| if err != nil { | ||||
| 	return ${1:nil}, err | ||||
| } | ||||
| ${0} | ||||
| endsnippet | ||||
|  | ||||
| snippet errn,, "Error return with three return values" !b | ||||
| if err != nil { | ||||
| 	return ${1:nil}, ${2:nil}, err | ||||
| } | ||||
| ${0} | ||||
| endsnippet | ||||
|  | ||||
| snippet ok "OK statement" !b | ||||
| if !ok { | ||||
| 	${0:${VISUAL}} | ||||
| } | ||||
| endsnippet | ||||
|  | ||||
| snippet gof "Anonymous Goroutine" !b | ||||
| go func() { | ||||
| 	${1} | ||||
| }() | ||||
| endsnippet | ||||
|  | ||||
| snippet def "Anonymous Defer" !b | ||||
| defer func() { | ||||
| 	${1} | ||||
| }() | ||||
| endsnippet | ||||
|  | ||||
| snippet ff "Fmt Printf debug" !b | ||||
| fmt.Printf("${1} %+v\n", $1) | ||||
| endsnippet | ||||
|  | ||||
| snippet fn "Fmt Println debug" !b | ||||
| fmt.Println("${1}") | ||||
| endsnippet | ||||
|  | ||||
| snippet lf "Log Printf debug" !b | ||||
| log.Printf("${1} %+v\n", $1) | ||||
| endsnippet | ||||
|  | ||||
| snippet ln "Log Println debug" !b | ||||
| log.Println("${1}") | ||||
| endsnippet | ||||
|  | ||||
| snippet make "make allocation" !b | ||||
| make(${1:Type}, ${2:size})${0} | ||||
| endsnippet | ||||
|  | ||||
| snippet test "test function" b | ||||
| func Test${1:Function}(t *testing.T) { | ||||
| 	${2} | ||||
| } | ||||
| endsnippet | ||||
|  | ||||
| # vim:ft=snippets: | ||||
							
								
								
									
										243
									
								
								sources_non_forked/vim-go/gosnippets/snippets/go.snip
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										243
									
								
								sources_non_forked/vim-go/gosnippets/snippets/go.snip
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,243 @@ | ||||
| # shorthand variable declaration | ||||
| snippet v | ||||
| 	${1} := ${2} | ||||
| # variable initialization | ||||
| snippet vr | ||||
| 	var ${1:t} ${0:string} | ||||
| # variable declaration | ||||
| snippet var | ||||
| 	var ${1} ${2} = ${3} | ||||
| # variables declaration | ||||
| snippet vars | ||||
| 	var ( | ||||
| 		${1} ${2} = ${3} | ||||
| 	) | ||||
| # append | ||||
| snippet ap | ||||
| 	append(${1:slice}, ${0:value}) | ||||
| # bool | ||||
| snippet bl | ||||
| 	bool | ||||
| # byte | ||||
| snippet bt | ||||
| 	byte | ||||
| # break | ||||
| snippet br | ||||
| 	break | ||||
| # channel | ||||
| snippet ch | ||||
| 	chan ${0:int} | ||||
| # case | ||||
| snippet cs | ||||
| 	case ${1:value}: | ||||
| 		${0} | ||||
| # const | ||||
| snippet c | ||||
| 	const ${1:NAME} = ${0:0} | ||||
| # constants with iota | ||||
| snippet co | ||||
| 	const ( | ||||
| 		${1:NAME1} = iota | ||||
| 		${0:NAME2} | ||||
| 	) | ||||
| # continue | ||||
| snippet cn | ||||
| 	continue | ||||
| # defer | ||||
| snippet df | ||||
| 	defer ${0:func}() | ||||
| # defer recover | ||||
| snippet dfr | ||||
| 	defer func() { | ||||
| 		if err := recover(); err != nil { | ||||
| 			${0} | ||||
| 		} | ||||
| 	}() | ||||
| # gpl | ||||
| snippet gpl | ||||
| 	/* | ||||
| 	 * This program is free software; you can redistribute it and/or modify | ||||
| 	 * it under the terms of the GNU General Public License as published by | ||||
| 	 * the Free Software Foundation; either version 2 of the License, or | ||||
| 	 * (at your option) any later version. | ||||
| 	 * | ||||
| 	 * This program is distributed in the hope that it will be useful, | ||||
| 	 * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
| 	 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | ||||
| 	 * GNU General Public License for more details. | ||||
| 	 * | ||||
| 	 * You should have received a copy of the GNU General Public License | ||||
| 	 * along with this program; if not, see <http://www.gnu.org/licenses/>. | ||||
| 	 * | ||||
| 	 * Copyright (C) ${1:Author}, `strftime("%Y")` | ||||
| 	 */ | ||||
|  | ||||
| 	${0} | ||||
| # int | ||||
| snippet i | ||||
| 	int | ||||
| # import | ||||
| snippet im | ||||
| 	import ( | ||||
| 		"${1:package}" | ||||
| 	) | ||||
| # interface | ||||
| snippet in | ||||
| 	interface{} | ||||
| # full interface snippet | ||||
| snippet inf | ||||
| 	interface ${1:name} { | ||||
| 		${2:/* methods */} | ||||
| 	} | ||||
| # if condition | ||||
| snippet if | ||||
| 	if ${1:/* condition */} { | ||||
| 		${2} | ||||
| 	} | ||||
| # else snippet | ||||
| snippet el | ||||
| 	else { | ||||
| 		${1} | ||||
| 	} | ||||
| # error snippet | ||||
| snippet ir | ||||
| 	if err != nil { | ||||
| 		return err | ||||
| 	} | ||||
| 	${0} | ||||
| # false | ||||
| snippet f | ||||
| 	false | ||||
| # fallthrough | ||||
| snippet ft | ||||
| 	fallthrough | ||||
| # float | ||||
| snippet fl | ||||
| 	float32 | ||||
| # float32 | ||||
| snippet f3 | ||||
| 	float32 | ||||
| # float64 | ||||
| snippet f6 | ||||
| 	float64 | ||||
| # if else | ||||
| snippet ie | ||||
| 	if ${1:/* condition */} { | ||||
| 		${2} | ||||
| 	} else { | ||||
| 		${3} | ||||
| 	} | ||||
| 	${0} | ||||
| # for loop | ||||
| snippet fo | ||||
| 	for ${2:i} := 0; $2 < ${1:count}; $2${3:++} { | ||||
| 		${4} | ||||
| 	} | ||||
| 	${0} | ||||
| # for range loop | ||||
| snippet fr | ||||
| 	for ${1:k}, ${2:v} := range ${3} { | ||||
| 		${4} | ||||
| 	} | ||||
| 	${0} | ||||
| # function simple | ||||
| snippet fun | ||||
| 	func ${1:funcName}(${2}) ${3:error} { | ||||
| 		${4} | ||||
| 	} | ||||
| 	${0} | ||||
| # function on receiver | ||||
| snippet fum | ||||
| 	func (self ${1:type}) ${2:funcName}(${3}) ${4:error} { | ||||
| 		${5} | ||||
| 	} | ||||
| 	${0} | ||||
| # Fmt Printf debug | ||||
| snippet ff | ||||
| 	fmt.Printf("${1} %+v\n", ${0}) | ||||
| # Fmt Println debug | ||||
| snippet fn | ||||
| 	fmt.Println("${1}") | ||||
| # log printf | ||||
| snippet lf | ||||
| 	log.Printf("%${1:s}", ${2:var}) | ||||
| # log printf | ||||
| snippet lp | ||||
| 	log.Println("${1}") | ||||
| # make | ||||
| snippet mk | ||||
| 	make(${1:[]string}, ${0:0}) | ||||
| # map | ||||
| snippet mp | ||||
| 	map[${1:string}]${0:int} | ||||
| # main() | ||||
| snippet main | ||||
| 	func main() { | ||||
| 		${1} | ||||
| 	} | ||||
| 	${0} | ||||
| # new | ||||
| snippet nw | ||||
| 	new(${0:type}) | ||||
| # panic | ||||
| snippet pn | ||||
| 	panic("${0:msg}") | ||||
| # print | ||||
| snippet pr | ||||
| 	fmt.Printf("%${1:s}\n", ${2:var}) | ||||
| # range | ||||
| snippet rn | ||||
| 	range ${0} | ||||
| # return | ||||
| snippet rt | ||||
| 	return ${0} | ||||
| # result | ||||
| snippet rs | ||||
| 	result | ||||
| # select | ||||
| snippet sl | ||||
| 	select { | ||||
| 	case ${1:v1} := <-${2:chan1} | ||||
| 		${3} | ||||
| 	case ${4:v2} := <-${5:chan2} | ||||
| 		${6} | ||||
| 	default: | ||||
| 		${0} | ||||
| 	} | ||||
| # string | ||||
| snippet sr | ||||
| 	string | ||||
| # struct | ||||
| snippet st | ||||
| 	struct ${1:name} { | ||||
| 		${2:/* data */} | ||||
| 	} | ||||
| 	${0} | ||||
| # switch | ||||
| snippet sw | ||||
| 	switch ${1:var} { | ||||
| 	case ${2:value1}: | ||||
| 		${3} | ||||
| 	case ${4:value2}: | ||||
| 		${5} | ||||
| 	default: | ||||
| 		${0} | ||||
| 	} | ||||
| snippet sp | ||||
| 	fmt.Sprintf("%${1:s}", ${2:var}) | ||||
| # true | ||||
| snippet t | ||||
| 	true | ||||
| # goroutine named function | ||||
| snippet g | ||||
| 	go ${1:funcName}(${0}) | ||||
| # goroutine anonymous function | ||||
| snippet ga | ||||
| 	go func(${1} ${2:type}) { | ||||
| 		${3:/* code */} | ||||
| 	}(${0}) | ||||
| # test function | ||||
| snippet test | ||||
| 	func Test${1:Function}(t *testing.T) { | ||||
| 		${2} | ||||
| 	} | ||||
		Reference in New Issue
	
	Block a user
	 amix
					amix