From a4d70877e590c59e55e93fc436394ff67a043b69 Mon Sep 17 00:00:00 2001 From: AJ ONeal Date: Thu, 1 Oct 2020 20:07:47 +0000 Subject: [PATCH] update go tooling --- golang/install.sh | 41 +++++++++++++++++++++--------- vim-go/go.vim | 30 +++++++++++++++++++++- vim-go/install.sh | 65 +++++++++++++++++++++++++++++++++++++---------- 3 files changed, 109 insertions(+), 27 deletions(-) diff --git a/golang/install.sh b/golang/install.sh index 44fd5be..adb6d20 100644 --- a/golang/install.sh +++ b/golang/install.sh @@ -54,24 +54,41 @@ pkg_post_install() { # 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() { diff --git a/vim-go/go.vim b/vim-go/go.vim index 6d8f73b..d923527 100644 --- a/vim-go/go.vim +++ b/vim-go/go.vim @@ -7,7 +7,13 @@ 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 @@ -15,3 +21,25 @@ let g:go_highlight_methods = 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 diff --git a/vim-go/install.sh b/vim-go/install.sh index acd9181..c5bbe99 100644 --- a/vim-go/install.sh +++ b/vim-go/install.sh @@ -10,30 +10,67 @@ # 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 } -- 2.25.1