-
-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cmd/govim: add config for defining the gopls environment
gopls can be configured with an environment, an environment which is passed to go/packages. For example, setting GOOS and GOARCH, or setting GOFLAGS=-tags=other to set a build tag. Therefore we define a govim config key, "GoplsEnv", for setting this environment. For example: govim#config#Set("GoplsEnv", {"GOFLAGS": "-mod=readonly"}) As part of this add a test that verifies the behaviour of the above setting. Setting of build tags does not current work; that is blocked on golang/go#35548 and will be tested in a follow up PR. Fixes #555
- Loading branch information
Showing
7 changed files
with
127 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
66 changes: 66 additions & 0 deletions
66
cmd/govim/testdata/scenario_modreadonly/config_set_env_goflags_mod_readonly.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
# Test that calling govim#config#Set with a value for GoplsEnv of GOFLAGS | ||
# does the right thing. This will necessarily involve a number of checks | ||
# for the various build flags that can be set via GOFLAGS. | ||
|
||
[short] skip 'Skip short because we sleep for GOVIM_ERRLOGMATCH_WAIT to ensure we don''t have any errors' | ||
|
||
vim ex 'e main.go' | ||
vimexprwait pre.golden getqflist() | ||
vim ex 'w' | ||
|
||
# We have to sleep here because there is no event we are waiting for | ||
sleep $GOVIM_ERRLOGMATCH_WAIT | ||
|
||
# Verify go.mod has not changed | ||
cmp go.mod go.mod.golden.pre | ||
|
||
# Change go.mod from outside Vim | ||
exec go get example.com/blah@v1.0.0 | ||
exec go mod tidy | ||
cmp go.mod go.mod.golden.post | ||
|
||
# Verify the diagnostic has been updated | ||
vimexprwait post.golden getqflist() | ||
|
||
# Disabled pending resolution to https://github.com/golang/go/issues/34103 | ||
# errlogmatch -count=0 'LogMessage callback: &protocol\.LogMessageParams\{Type:(1|2), Message:".*' | ||
|
||
-- go.mod -- | ||
module mod.com | ||
|
||
go 1.13 | ||
-- go.mod.golden.pre -- | ||
module mod.com | ||
|
||
go 1.13 | ||
-- go.mod.golden.post -- | ||
module mod.com | ||
|
||
go 1.13 | ||
|
||
require example.com/blah v1.0.0 | ||
-- main.go -- | ||
package main | ||
|
||
import "example.com/blah" | ||
|
||
func main() { | ||
println(blah.Name) | ||
} | ||
-- pre.golden -- | ||
[ | ||
{ | ||
"bufnr": 1, | ||
"col": 8, | ||
"lnum": 3, | ||
"module": "", | ||
"nr": 0, | ||
"pattern": "", | ||
"text": "could not import example.com/blah (no package for import example.com/blah)", | ||
"type": "", | ||
"valid": 1, | ||
"vcol": 0 | ||
} | ||
] | ||
-- post.golden -- | ||
[] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"GoplsEnv": {"GOFLAGS": "-mod=readonly"} | ||
} |