Skip to content
This repository has been archived by the owner on Feb 17, 2021. It is now read-only.

Autocomplete does not work within incomplete if statements #23

Closed
cskr opened this issue Jan 4, 2019 · 1 comment
Closed

Autocomplete does not work within incomplete if statements #23

cskr opened this issue Jan 4, 2019 · 1 comment

Comments

@cskr
Copy link

cskr commented Jan 4, 2019

Steps to reproduce

  • Create a directory outside GOPATH and initialize it as a module with go mod init github.com/cskr/foo.
  • Use VIM with vim-go installed and create main.go with following content.
package main

func main() {
	var v MyStruct
}

type MyStruct struct {
	Field int
}
  • Hit C-x C-o after typing if v. immediately after the variable declaration as shown below,
func main() {
	var v MyStruct
	if v.
}
  • Pattern not found was displayed as error. However, if I add braces at the end of if as shown below or and then try C-x C-o or define MyStruct before main, it works.
func main() {
	var v MyStruct
	if v. {}
}

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

go version go1.11.4 linux/amd64

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

GOARCH="amd64"
GOOS="linux"

What is the debug output of gocode?

2019/01/04 21:38:00 Got autocompletion request for '/home/cskr/foo/main.go'
2019/01/04 21:38:00 Cursor at: 50
2019/01/04 21:38:00 -------------------------------------------------------
package main

func main() {
	var v MyStruct
	if v.#
}

type MyStruct struct {
	Field int
}
2019/01/04 21:38:00 -------------------------------------------------------
2019/01/04 21:38:00 error in package github.com/cskr/foo: /home/cskr/foo/main.go:4:8:undeclared name: MyStruct
2019/01/04 21:38:00 error in package github.com/cskr/foo: /home/cskr/foo/main.go:8:6:undeclared name: MyStruct
2019/01/04 21:38:00 Elapsed duration: 69.581082ms
2019/01/04 21:38:00 Offset: 0
2019/01/04 21:38:00 Number of candidates found: 0
2019/01/04 21:38:00 Candidates are:
2019/01/04 21:38:00 =======================================================

What (client-side) flags are you passing into gocode?

I pass -unimported-packages.

What editor are using?

VIM 8.0

@stamblerre
Copy link
Owner

stamblerre commented Oct 30, 2019

Sorry for not getting back to you earlier. This repository is currently in maintenance mode, so I will close this issue. The current recommendation for autocompletion is to use gopls.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants