Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

x/tools/gopls: Sublime Text 3 - LSP: Error loading workspace folders(excepted 1, got 0) #43746

Closed
thep0y opened this issue Jan 17, 2021 · 2 comments
Closed

Comments

@thep0y
Copy link

@thep0y thep0y commented Jan 17, 2021

What version of Go are you using (go version)?

$ go version
go version go1.15.6 linux/amd64

Does this issue reproduce with the latest release?

yes.

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
GO111MODULE="on"
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/thepoy/.cache/go-build"
GOENV="/home/thepoy/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/thepoy/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/thepoy/go"
GOPRIVATE=""
GOPROXY="https://goproxy.cn,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/dev/null"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build522328134=/tmp/go-build -gno-record-gcc-switches"

What did you do?

According to the official document, gopls is enabled through LSP in sublime text 3. If I do not start sublime in the terminal, gopls will report an error: Error loading workspace folders(excepted 1, got 0).
If you start sublime in the terminal, everything is normal.
LSP setting:

{
  "clients": {
    "gopls": {
      "enabled": true,
      "command": [
        "gopls"
      ]
    }
  }
}

Project structure:
图片

What did you expect to see?

I hope gopls can run normally.

What did you see instead?

gopls is not working.

@gopherbot gopherbot added this to the Unreleased milestone Jan 17, 2021
@thep0y
Copy link
Author

@thep0y thep0y commented Jan 17, 2021

The shell I use is zsh. When I installed golang, I wrote the GOROOT environment variable in /etc/zsh/zshenv, causing sublime text to fail to read GOROOT when it was started graphically.
I deleted the GOROOT environment variable in zshenv and added GOROOT to .profile, this problem can be solved.

@thep0y thep0y closed this Jan 17, 2021
@agnivade
Copy link
Contributor

@agnivade agnivade commented Jan 17, 2021

This is a common problem with Sublime. Personally I prefer to encode the PATH logic in the sublime config itself like this:

{
	"clients":
	{
		"gopls":
		{
			"command": ["/home/agniva/go/bin/gopls",
				"-v",
				"-rpc.trace",
				"-logfile=/home/agniva/gopls.log"],
			"enabled": true,
			"env": {
				"PATH": "/home/agniva/go/bin:/usr/local/go/bin"
			},
			"scopes":["source.go"],
			"syntaxes": [
				"Packages/Go/Go.sublime-syntax",
        		"Packages/GoSublime/syntax/GoSublime-Go-Recommended.sublime-syntax",
			],
			"settings": {
				"gopls.usePlaceholders": true,
				"gopls.completeUnimported": true,
			},
			"languageId": "go"
		}
	},
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants