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