acd91816db624c76b2ca8b343be34ef0bfc612cc
[webi-installers/.git] / vim-go / install.sh
1 #!/bin/bash
2
3 {
4     set -e
5     set -u
6
7     mkdir -p "$HOME/.vim/pack/plugins/start"
8     rm -rf "$HOME/.vim/pack/plugins/start/vim-go"
9     git clone --depth=1 https://github.com/fatih/vim-go.git "$HOME/.vim/pack/plugins/start/vim-go"
10
11     # Install go linting tools
12     echo "Building go language tools..."
13     echo gopls
14     go get golang.org/x/tools/gopls > /dev/null #2>/dev/null
15     echo golint
16     go get golang.org/x/lint/golint > /dev/null #2>/dev/null
17     echo errcheck
18     go get github.com/kisielk/errcheck > /dev/null #2>/dev/null
19     echo goimports
20     go get golang.org/x/tools/cmd/goimports > /dev/null #2>/dev/null
21     echo goreturns
22     go get github.com/sqs/goreturns > /dev/null #2>/dev/null
23
24     if [ -f "$HOME/.vimrc" ]; then
25         set +e
26         if ! grep 'source.*go.vim' -r ~/.vimrc; then
27             mkdir -p ~/.vim/plugin
28             printf '\n" Golang: reasonable defaults from webinstall.dev/vim-go\n' >> ~/.vimrc
29             printf 'source ~/.vim/plugin/go.vim\n' >> ~/.vimrc
30         fi
31         set -e
32     fi
33
34     if ! [ -f "$HOME/.vim/plugin/go.vim" ]; then
35         mkdir -p ~/.vim/plugin
36         WEBI_HOST=${WEBI_HOST:-"https://webinstall.dev"}
37         curl -fsS -o ~/.vim/plugin/go.vim "$WEBI_HOST/packages/vim-go/go.vim"
38     fi
39 }