vim-go icon indicating copy to clipboard operation
vim-go copied to clipboard

Feature Request: Completion with TinyGo machine package

Open marcofeltmann opened this issue 1 year ago • 1 comments

Hacking with TinyGo lacks Auto-Completion support for machine package

I hacked a little with Tiny Go and got rid of a bunch of linter warnings using the tinygo.nvim plugin to set the target.

But the gd keystrokes for Go Definition won't work, the C-x C-o for completion neither works.

Note I skipped the nvim and vim-go configuration section as it's not a bug, vim-go behaves pretty well. The issue is related to how TinyGo and the machine package behave!

Vim version (first three lines from :version):

NVIM v0.10.0

Go version (go version):

go version go1.22.3 linux/amd64 tinygo version 0.31.2 linux/amd64 (using go version go1.22.3 and LLVM version 17.0.6)

Go environment

go env Output:

{
	"AR": "ar",
	"CC": "gcc",
	"CGO_CFLAGS": "-O2 -g",
	"CGO_CPPFLAGS": "",
	"CGO_CXXFLAGS": "-O2 -g",
	"CGO_ENABLED": "0",
	"CGO_FFLAGS": "-O2 -g",
	"CGO_LDFLAGS": "-O2 -g",
	"CXX": "g++",
	"GCCGO": "gccgo",
	"GO111MODULE": "",
	"GOAMD64": "v1",
	"GOARCH": "amd64",
	"GOBIN": "",
	"GOCACHE": "/home/mafe/.cache/go-build",
	"GOENV": "/home/mafe/.config/go/env",
	"GOEXE": "",
	"GOEXPERIMENT": "",
	"GOFLAGS": "",
	"GOGCCFLAGS": "-fPIC -m64 -fno-caret-diagnostics -Qunused-arguments -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build4078892123=/tmp/go-build -gno-record-gcc-switches",
	"GOHOSTARCH": "amd64",
	"GOHOSTOS": "linux",
	"GOINSECURE": "",
	"GOMOD": "/dev/null",
	"GOMODCACHE": "/home/mafe/go/pkg/mod",
	"GONOPROXY": "",
	"GONOSUMDB": "",
	"GOOS": "linux",
	"GOPATH": "/home/mafe/go",
	"GOPRIVATE": "",
	"GOPROXY": "https://proxy.golang.org,direct",
	"GOROOT": "/nix/store/vz8d6wmfcf38l3h3vymwqr6c5zxp5jmp-go-1.22.3/share/go",
	"GOSUMDB": "sum.golang.org",
	"GOTMPDIR": "",
	"GOTOOLCHAIN": "auto",
	"GOTOOLDIR": "/nix/store/vz8d6wmfcf38l3h3vymwqr6c5zxp5jmp-go-1.22.3/share/go/pkg/tool/linux_amd64",
	"GOVCS": "",
	"GOVERSION": "go1.22.3",
	"GOWORK": "",
	"PKG_CONFIG": "pkg-config"
}

gopls version

gopls version Output:
golang.org/x/tools/gopls v0.15.3

I'd love some hints on how to tackle this and would be happy to try to solve it on my own. :)

marcofeltmann avatar Jun 18 '24 14:06 marcofeltmann

It looks like it's a matter of setting GOROOT and maybe GOFLAGS correctly when Vim is started, and maybe using :GoBuildTags afterwards: https://github.com/pcolladosoto/tinygo.nvim/blob/main/lua/tinygo/init.lua.

I don't know that there's anything to be done here to change vim-go. If I'm reading tinygo.nvim correctly, it seems like everything you need is already in place. I'm happy to help you work through it to verify.

bhcleek avatar Jun 18 '24 18:06 bhcleek