Go
Zed 原生支持 Go。
- Tree-sitter: tree-sitter/tree-sitter-go
- 语言服务器: golang/tools/tree/master/gopls
设置
我们建议通过 go 的包管理器安装 gopls,而不是通过 Homebrew 或您的 Linux 发行版的包管理器安装。
- 请确保您已卸载通过包管理器安装的任何版本的 gopls
# MacOS homebrew
brew remove gopls
# Ubuntu
sudo apt-get remove gopls
sudo snap remove gopls
# Arch
sudo pacman -R gopls
- 使用 go 模块工具安装/更新
gopls
到最新版本
go install golang.org/x/tools/gopls@latest
- 确保
gopls
在您的路径中
which gopls
gopls version
如果找不到 gopls
,您可能需要将 export PATH="$PATH:$HOME/go/bin"
添加到您的 .zshrc
/ .bash_profile
内嵌提示
Zed 为内嵌提示设置了以下初始化选项
"hints": {
"assignVariableTypes": true,
"compositeLiteralFields": true,
"compositeLiteralTypes": true,
"constantValues": true,
"functionTypeParameters": true,
"parameterNames": true,
"rangeVariableTypes": true
}
以便在 Zed 在设置中启用内嵌提示时,语言服务器发回内嵌提示。
使用
"lsp": {
"gopls": {
"initialization_options": {
"hints": {
....
}
}
}
}
来覆盖这些设置。
有关更多信息,请参阅gopls inlayHints 文档。
Go Mod
- Tree-sitter: camdencheek/tree-sitter-go-mod
- 语言服务器: N/A
Go Sum
- Tree-sitter: amaanq/tree-sitter-go-sum
- 语言服务器: N/A
Go Work
- Tree-sitter: tree-sitter-go-work
- 语言服务器: N/A