# Install x go
echo "Building go language tools..."
+ export GO111MODULE=on
+
+ echo ""
echo gopls
- "$pkg_dst_cmd" get golang.org/x/tools/gopls > /dev/null #2>/dev/null
+ "$pkg_dst_cmd" get golang.org/x/tools/gopls@latest > /dev/null #2>/dev/null
+
+ echo ""
+ echo guru
+ "$pkg_dst_cmd" get golang.org/x/tools/cmd/guru@latest > /dev/null #2>/dev/null
+
+ echo ""
echo golint
- "$pkg_dst_cmd" get golang.org/x/lint/golint > /dev/null #2>/dev/null
- echo errcheck
- "$pkg_dst_cmd" get github.com/kisielk/errcheck > /dev/null #2>/dev/null
- echo gotags
- "$pkg_dst_cmd" get github.com/jstemmer/gotags > /dev/null #2>/dev/null
+ "$pkg_dst_cmd" get golang.org/x/lint/golint@latest > /dev/null #2>/dev/null
+
+ echo ""
echo goimports
- "$pkg_dst_cmd" get golang.org/x/tools/cmd/goimports > /dev/null #2>/dev/null
+ "$pkg_dst_cmd" get golang.org/x/tools/cmd/goimports@latest > /dev/null #2>/dev/null
+
+ echo ""
echo gorename
- "$pkg_dst_cmd" get golang.org/x/tools/cmd/gorename > /dev/null #2>/dev/null
+ "$pkg_dst_cmd" get golang.org/x/tools/cmd/gorename@latest > /dev/null #2>/dev/null
+
+ echo ""
echo gotype
- "$pkg_dst_cmd" get golang.org/x/tools/cmd/gotype > /dev/null #2>/dev/null
+ "$pkg_dst_cmd" get golang.org/x/tools/cmd/gotype@latest > /dev/null #2>/dev/null
+
+ echo ""
echo stringer
- "$pkg_dst_cmd" get golang.org/x/tools/cmd/stringer > /dev/null #2>/dev/null
- echo goreturns
- "$pkg_dst_cmd" get github.com/sqs/goreturns > /dev/null #2>/dev/null
+ "$pkg_dst_cmd" get golang.org/x/tools/cmd/stringer@latest > /dev/null #2>/dev/null
+
+ echo ""
+ echo golangci-lint
+ "$pkg_dst_cmd" get github.com/golangci/golangci-lint/cmd/golangci-lint@latest > /dev/null #2>/dev/null
+
+ echo ""
}
pkg_done_message() {
let g:syntastic_go_checkers = ['go', 'golint', 'errcheck']
" tell vim-go that goimports is installed
-let g:go_fmt_command = "goreturns"
+let g:go_fmt_command = "goimports"
+
+" Show type info as you type
+let g:go_auto_type_info = 1
+
+" golangci-lint on save
+let g:go_metalinter_autosave=1
" tell vim-go to highlight
let g:go_highlight_functions = 1
let g:go_highlight_structs = 1
let g:go_highlight_operators = 1
let g:go_highlight_build_constraints = 1
+
+" and lots of extra highligting
+let g:go_highlight_extra_types = 1
+let g:go_highlight_operators = 1
+let g:go_highlight_function_calls = 1
+let g:go_highlight_fields = 1
+let g:go_highlight_build_constraints = 1
+let g:go_highlight_generate_tags = 1
+let g:go_highlight_format_strings = 1
+let g:go_highlight_variable_declarations = 1
+let g:go_highlight_variable_assignments = 1
+
+" and error highlighting
+let g:go_highlight_array_whitespace_error = 1
+let g:go_highlight_chan_whitespace_error = 1
+let g:go_highlight_space_tab_error = 1
+let g:go_highlight_trailing_whitespace_error = 1
+
+" highlighting that doesn't seem to help
+" let g:go_highlight_string_spellcheck = 1
+" let g:go_highlight_function_parameters = 1
+" let g:go_highlight_types = 1
# Install go linting tools
echo "Building go language tools..."
- echo gopls
- go get golang.org/x/tools/gopls > /dev/null #2>/dev/null
- echo golint
- go get golang.org/x/lint/golint > /dev/null #2>/dev/null
- echo errcheck
+ export GO111MODULE=on
+
+ echo ""
+
+ # Official Golang Tooling
+ echo -n "golint: "
+ go get golang.org/x/lint/golint@latest > /dev/null #2>/dev/null
+ echo -n "gopls: "
+ go get golang.org/x/tools/gopls@latest > /dev/null #2>/dev/null
+ echo -n "guru: "
+ go get golang.org/x/tools/cmd/guru@latest > /dev/null #2>/dev/null
+ echo -n "goimports: "
+ go get golang.org/x/tools/cmd/goimports@latest > /dev/null #2>/dev/null
+ echo -n "gorename: "
+ go get golang.org/x/tools/cmd/gorename@latest > /dev/null #2>/dev/null
+ echo -n "gotype: "
+ go get golang.org/x/tools/cmd/gotype@latest > /dev/null #2>/dev/null
+
+ echo -n "golangci-lint: "
+ go get github.com/golangci/golangci-lint/cmd/golangci-lint@master > /dev/null #2>/dev/null
+
+ # Community Tooling
+ echo -n "fillstruct: "
+ go get github.com/davidrjenni/reftools/cmd/fillstruct@master > /dev/null #2>/dev/null
+ echo -n "godef: "
+ go get github.com/rogpeppe/godef@master > /dev/null #2>/dev/null
+ echo -n "motion: "
+ go get github.com/fatih/motion@master > /dev/null #2>/dev/null
+ echo -n "errcheck: "
go get github.com/kisielk/errcheck > /dev/null #2>/dev/null
- echo goimports
- go get golang.org/x/tools/cmd/goimports > /dev/null #2>/dev/null
- echo goreturns
- go get github.com/sqs/goreturns > /dev/null #2>/dev/null
+ echo -n "dlv: "
+ go get github.com/go-delve/delve/cmd/dlv@master > /dev/null #2>/dev/null
+ echo -n "iferr: "
+ go get github.com/koron/iferr@master > /dev/null #2>/dev/null
+ echo -n "impl: "
+ go get github.com/josharian/impl@master > /dev/null #2>/dev/null
+ echo -n "keyify: "
+ go get honnef.co/go/tools/cmd/keyify@master > /dev/null #2>/dev/null
+ echo -n "gomodifytags: "
+ go get github.com/fatih/gomodifytags@master > /dev/null #2>/dev/null
+ echo -n "asmfmt: "
+ go get github.com/klauspost/asmfmt/cmd/asmfmt@master > /dev/null #2>/dev/null
+ echo -n "gotags: "
+ go get github.com/jstemmer/gotags > /dev/null #2>/dev/null
if [ -f "$HOME/.vimrc" ]; then
set +e
if ! grep 'source.*go.vim' -r ~/.vimrc; then
- mkdir -p ~/.vim/plugin
+ mkdir -p ~/.vim/plugins
printf '\n" Golang: reasonable defaults from webinstall.dev/vim-go\n' >> ~/.vimrc
- printf 'source ~/.vim/plugin/go.vim\n' >> ~/.vimrc
+ printf 'source ~/.vim/plugins/go.vim\n' >> ~/.vimrc
fi
set -e
fi
- if ! [ -f "$HOME/.vim/plugin/go.vim" ]; then
- mkdir -p ~/.vim/plugin
+ if ! [ -f "$HOME/.vim/plugins/go.vim" ]; then
+ mkdir -p ~/.vim/plugins
WEBI_HOST=${WEBI_HOST:-"https://webinstall.dev"}
- curl -fsS -o ~/.vim/plugin/go.vim "$WEBI_HOST/packages/vim-go/go.vim"
+ curl -fsS -o ~/.vim/plugins/go.vim "$WEBI_HOST/packages/vim-go/go.vim"
fi
+
+ echo 'Running :GoInstallBinaries in vim ...'
+ printf ':GoInstallBinaries\n:q\n' | vim -e
}