Go
Go support is available natively in Zed.
- Tree Sitter: tree-sitter/tree-sitter-go
- Language Server: golang/tools/tree/master/gopls
Setup
We recommend installing gopls via go's package manager and not via Homebrew or your Linux distribution's package manager.
- Make sure you have uninstalled any version of gopls you have installed via your package manager:
# MacOS homebrew
brew remove gopls
# Ubuntu
sudo apt-get remove gopls
sudo snap remove gopls
# Arch
sudo pacman -R gopls
- Install/Update
gopls
to the latest version using the go module tool:
go install golang.org/x/tools/gopls@latest
- Ensure that
gopls
is in your path:
which gopls
gopls version
If gopls
is not found you will likely need to add export PATH="$PATH:$HOME/go/bin"
to your .zshrc
/ .bash_profile
Inlay Hints
Zed sets the following initialization options for inlay hints:
"hints": {
"assignVariableTypes": true,
"compositeLiteralFields": true,
"compositeLiteralTypes": true,
"constantValues": true,
"functionTypeParameters": true,
"parameterNames": true,
"rangeVariableTypes": true
}
to make the language server send back inlay hints when Zed has them enabled in the settings.
Use
"lsp": {
"gopls": {
"initialization_options": {
"hints": {
....
}
}
}
}
to override these settings.
See gopls inlayHints documentation for more information.
Go Mod
- Tree Sitter: camdencheek/tree-sitter-go-mod
- Language Server: N/A
Go Sum
- Tree Sitter: amaanq/tree-sitter-go-sum
- Language Server: N/A
Go Work
- Tree Sitter: tree-sitter-go-work
- Language Server: N/A