chore: make Prettier + fix spelling, update upgrade/switch instructions, prefer ale...
[webi-installers/.git] / vim-go / README.md
1 ---
2 title: vim-go
3 homepage: https://github.com/fatih/vim-go
4 tagline: |
5   vim-go adds Go language support for Vim.
6 ---
7
8 To update (replacing the current version) run `webi vim-go`.
9
10 ## Cheat Sheet
11
12 > `vim-go` provides integration with various official and 3rd party go tooling
13 > for linting, vetting, etc.
14
15 You'll also need to install [`ALE`](https://webinstall.dev/vim-ale) (part of
16 [`vim-essentials`](https://webinstall.dev/vim-essentials)) or
17 [`syntastic`](https://webinstall.dev/vim-syntastic) first.
18
19 ### How to install by hand
20
21 ```bash
22 git clone --depth=1 https://github.com/fatih/vim-go.git ~/.vim/pack/plugins/start/vim-go
23 ```
24
25 ### How to configure your `.vimrc`
26
27 ```vim
28 " don't check syntax immediately on open or on quit
29 let g:syntastic_check_on_open = 1
30 let g:syntastic_check_on_wq = 0
31
32 " we also want to get rid of accidental trailing whitespace on save
33 autocmd BufWritePre * :%s/\s\+$//e
34 ```
35
36 ```vim
37 """""""""""""""""""""""""""
38 " Golang-specific options "
39 """""""""""""""""""""""""""
40
41 " tell syntastic that go, golint, and errcheck are installed
42 let g:syntastic_go_checkers = ['go', 'golint', 'errcheck']
43
44 " tell vim-go that goimports is installed
45 let g:go_fmt_command = "goimports"
46
47 " tell vim-go to highlight
48 let g:go_highlight_functions = 1
49 let g:go_highlight_methods = 1
50 let g:go_highlight_structs = 1
51 let g:go_highlight_operators = 1
52 let g:go_highlight_build_constraints = 1
53 ```
54
55 ### How to install go language tools
56
57 ```bash
58 # gopls
59 go get golang.org/x/tools/gopls
60
61 # golint
62 go get golang.org/x/lint/golint
63
64 # errcheck
65 go get github.com/kisielk/errcheck
66
67 # gotags
68 go get github.com/jstemmer/gotags
69
70 # goimports
71 go get golang.org/x/tools/cmd/goimports
72
73 # gorename
74 go get golang.org/x/tools/cmd/gorename
75
76 # goreturns
77 go get github.com/sqs/goreturns
78
79 # gotype
80 go get golang.org/x/tools/cmd/gotype
81 ```