go.md

 1# Go
 2
 3Go support is available natively in Zed.
 4
 5- Tree-sitter: [tree-sitter/tree-sitter-go](https://github.com/tree-sitter/tree-sitter-go)
 6- Language Server: [golang/tools/tree/master/gopls](https://github.com/golang/tools/tree/master/gopls)
 7
 8## Setup
 9
10We recommend installing gopls via go's package manager and not via Homebrew or your Linux distribution's package manager.
11
121. Make sure you have uninstalled any version of gopls you have installed via your package manager:
13
14```sh
15# MacOS homebrew
16brew remove gopls
17# Ubuntu
18sudo apt-get remove gopls
19sudo snap remove gopls
20# Arch
21sudo pacman -R gopls
22```
23
242. Install/Update `gopls` to the latest version using the go module tool:
25
26```sh
27go install golang.org/x/tools/gopls@latest
28```
29
303. Ensure that `gopls` is in your path:
31
32```sh
33which gopls
34gopls version
35```
36
37If `gopls` is not found you will likely need to add `export PATH="$PATH:$HOME/go/bin"` to your `.zshrc` / `.bash_profile`
38
39## Inlay Hints
40
41Zed sets the following initialization options for inlay hints:
42
43```json
44"hints": {
45    "assignVariableTypes": true,
46    "compositeLiteralFields": true,
47    "compositeLiteralTypes": true,
48    "constantValues": true,
49    "functionTypeParameters": true,
50    "parameterNames": true,
51    "rangeVariableTypes": true
52}
53```
54
55to make the language server send back inlay hints when Zed has them enabled in the settings.
56
57Use
58
59```json
60"lsp": {
61    "gopls": {
62        "initialization_options": {
63            "hints": {
64                ....
65            }
66        }
67    }
68}
69```
70
71to override these settings.
72
73See [gopls inlayHints documentation](https://github.com/golang/tools/blob/master/gopls/doc/inlayHints.md) for more information.
74
75## Go Mod
76
77- Tree-sitter: [camdencheek/tree-sitter-go-mod](https://github.com/camdencheek/tree-sitter-go-mod)
78- Language Server: N/A
79
80## Go Sum
81
82- Tree-sitter: [amaanq/tree-sitter-go-sum](https://github.com/amaanq/tree-sitter-go-sum)
83- Language Server: N/A
84
85## Go Work
86
87- Tree-sitter:
88  [tree-sitter-go-work](https://github.com/d1y/tree-sitter-go-work)
89- Language Server: N/A