govim / govim

govim is a Go development plugin for Vim8, written in Go
BSD 3-Clause "New" or "Revised" License
874 stars 62 forks source link

setting build tags only for gopls #1144

Open krader1961 opened 2 years ago

krader1961 commented 2 years ago

What version of Vim/Gvim are you using?

Vim/Gvim version
$ vim --version
VIM - Vi IMproved 8.2 (2019 Dec 12, compiled Nov 22 2021 20:10:18)
macOS version - x86_64
Included patches: 1-3650

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

$ go version
go version go1.17.2 darwin/amd64

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

go env Output
$ go env
GOHOSTARCH="amd64"
GOHOSTOS="darwin"

What version/commit of govim are you using?

da0a01d0098ff6336a0b520e5400b5625a2ccf47

How did you install govim?

Vim 8 packages

What did you do?

I added the following to my vimrc a few weeks ago:

" Having to set this env var is fragile and gross. We need it because
" otherwise Gopls won't anaylyze files for other platforms (e.g., Windows)
" when we're editing the source on macOS (Darwin).
let $GOFLAGS = "-tags=darwin,linux,dragonfly,freebsd,netbsd,openbsd,solaris,windows"

What did you see instead?

I updated the govim version which caused it to rebuild the govim and gopls binaries. The rebuild failed, of course, due to the presence of the aforementioned GOFLAGS env var. I looked at the source but couldn't see any way to set the build tags only for the gopls process started by govim? Did I miss something? I know the gopls project is discussing how to better handle this but until that happens could we add a mechanism to tell govim to set that env var for the gopls process? Perhaps a GOVIM_GOPLS_GOFLAGS env var?

tbruyelle commented 2 years ago

Is there any news on this issue ? I'm also working on a codebase where some files have specific build tags, and if I could toggle build tags easily, that would be awesome ! Thanks in advance