35 lines
1.0 KiB
Plaintext

hook global BufSetOption filetype=go %{
set buffer snippets %opt{snippets} # keep global snippets (if any)
# Main structure of a go file
set -add buffer snippets 'init-structure' 'inist' \
%{ phantom-selection-clear ; snippets-insert %{package main
import(${})
func main() {${}}
}; phantom-selection-add-selection ; phantom-selection-iterate-next }
# Basic read file and populate array
set -add buffer snippets 'read-populate' 'rbufpop' \
%{ phantom-selection-clear ; snippets-insert %{file, err := os.Open("${}")
check(err)
defer file.Close()
${} := make([]string, 0)
scanner := bufio.NewScanner(file)
for scanner.Scan() {
lines = append(${}, scanner.Text())
}
}; phantom-selection-add-selection ; phantom-selection-iterate-next }
}
# With phantom
#set -add buffer snippets 'name' 'short' \
# %{ phantom-selection-clear ; snippets-insert %{snippet-here
#}; phantom-selection-add-selection ; phantom-selection-iterate-next }
#
# Without phantom
#set -add buffer snippets 'name' 'short' %{ snippets-insert %snippet-here{
#}}