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

Vscode does not prompt "built-in" #34

Closed
wenbingzhang opened this issue Jun 22, 2018 · 10 comments
Closed

Vscode does not prompt "built-in" #34

wenbingzhang opened this issue Jun 22, 2018 · 10 comments

Comments

@wenbingzhang
Copy link

Vscode does not prompt "built-in"

@willxm
Copy link

willxm commented Jun 27, 2018

the same problem

@mdempsky
Copy link
Owner

Can you please elaborate?

Best would be if you can provide a minimal Go test file, where your cursor is within the file when you request completion, what completions you're receiving, and what completions you expected.

Thanks.

@willxm
Copy link

willxm commented Jun 27, 2018

before, I use github.com/nsf/gocode, the built-in prompt is working
screen shot 2018-06-27 at 11 40 40 pm
after, I remove the github.com/nsf/gocode and install github.com/mdempsky/gocode.
Unfortunately, built-in prompt is not working.
screen shot 2018-06-27 at 11 52 42 pm

Thanks.

@mdempsky
Copy link
Owner

mdempsky commented Jul 3, 2018

I see. In github.com/mdempsky/gocode/suggest/candidate.go there's:

// TODO(mdempsky): Change this to true.
const proposeBuiltins = false

If you change that from false to true, reinstall gocode (i.e., go install github.com/mdempsky/gocode), and restart gocode (gocode exit), it should suggest those built-ins.

Can you test that out and let me know if it works as you expect? If so, I'll look into enabling it by default.

@willxm
Copy link

willxm commented Jul 4, 2018

I change that
screen shot 2018-07-04 at 9 17 54 am
restart
screen shot 2018-07-04 at 9 19 07 am

geocode -s -debug

but panic...

2018/07/04 09:28:01 -------------------------------------------------------
2018/07/04 09:28:01 Error parsing input file (outer block):
2018/07/04 09:28:01 /Users/willxm/go/src/test/problem/main.go:31:6: expected selector or type assertion, found ';'
panic: runtime error: invalid memory address or nil pointer dereference

goroutine 23 [running]:
runtime/debug.Stack(0xb, 0xc4207b7410, 0x1)
/usr/local/Cellar/go/1.10/libexec/src/runtime/debug/stack.go:24 +0xa7
runtime/debug.PrintStack()
/usr/local/Cellar/go/1.10/libexec/src/runtime/debug/stack.go:16 +0x22
main.(*Server).AutoComplete.func1(0xc420172640)
/Users/willxm/go/src/github.com/mdempsky/gocode/server.go:71 +0x94
panic(0x141e1a0, 0x16fbb40)
/usr/local/Cellar/go/1.10/libexec/src/runtime/panic.go:505 +0x229
go/types.(*Package).Path(...)
/usr/local/Cellar/go/1.10/libexec/src/go/types/package.go:30
github.com/mdempsky/gocode/suggest.(*candidateCollector).asCandidate(0xc4200a45b0, 0x14fe820, 0xc4200932c0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
/Users/willxm/go/src/github.com/mdempsky/gocode/suggest/candidate.go:126 +0x140
github.com/mdempsky/gocode/suggest.(*candidateCollector).getCandidates(0xc4200a45b0, 0xc4207a9d10, 0xc4200a45b0, 0x151)
/Users/willxm/go/src/github.com/mdempsky/gocode/suggest/candidate.go:94 +0xeb
github.com/mdempsky/gocode/suggest.(*Config).Suggest(0xc4207b7aa0, 0xc420164c30, 0x29, 0xc4200d06e0, 0x153, 0x153, 0x150, 0x170d080, 0x143df40, 0xc420050a90, ...)
/Users/willxm/go/src/github.com/mdempsky/gocode/suggest/suggest.go:71 +0x2b6
main.(*Server).AutoComplete(0x172b100, 0xc4200896c0, 0xc420172640, 0x0, 0x0)
/Users/willxm/go/src/github.com/mdempsky/gocode/server.go:102 +0x1fc
reflect.Value.call(0xc4200744e0, 0xc42000e580, 0x13, 0x149ea5b, 0x4, 0xc420050f18, 0x3, 0x3, 0xc420071b40, 0x13f7700, ...)
/usr/local/Cellar/go/1.10/libexec/src/reflect/value.go:447 +0x969
reflect.Value.Call(0xc4200744e0, 0xc42000e580, 0x13, 0xc42016ef18, 0x3, 0x3, 0x1469ba0, 0x1480401, 0xc420070200)
/usr/local/Cellar/go/1.10/libexec/src/reflect/value.go:308 +0xa4
net/rpc.(*service).call(0xc420071a00, 0xc420092690, 0xc420176198, 0xc4201761b0, 0xc4200a6400, 0xc420108de0, 0x13e3560, 0xc4200896c0, 0x16, 0x13e3520, ...)
/usr/local/Cellar/go/1.10/libexec/src/net/rpc/server.go:384 +0x14e
created by net/rpc.(*Server).ServeCodec
/usr/local/Cellar/go/1.10/libexec/src/net/rpc/server.go:480 +0x43a
2018/07/04 09:28:02 Got autocompletion request for '/Users/willxm/go/src/test/problem/main.go'
2018/07/04 09:28:02 Cursor at: 338

mdempsky added a commit that referenced this issue Jul 4, 2018
Avoids a nil pointer dereference for builtin objects, which don't have
an associated package.

Updates #34.
@mdempsky
Copy link
Owner

mdempsky commented Jul 4, 2018

Sorry about that. I tested that before recommending it, but apparently had an old checkout.

I believe I've fixed proposeBuiltins at master. Please try again. Thank you.

@mdempsky
Copy link
Owner

mdempsky commented Jul 4, 2018

Suggestions for builtins are now controlled by a -builtin flag in the client. If you can configure VS Code to set that flag, you should get the suggestions you're expecting.

If there's a preferable way to integrate that customization into VS Code, let me know.

@willxm
Copy link

willxm commented Jul 4, 2018

I restart gocode

gocode -s -builtin -debug

output

2018/07/04 11:11:19 =======================================================
2018/07/04 11:11:19 Got autocompletion request for '/Users/willxm/go/src/test/problem/main.go'
2018/07/04 11:11:19 Cursor at: 36
2018/07/04 11:11:19 -------------------------------------------------------
package main

func main() {
var s s#
}
2018/07/04 11:11:19 -------------------------------------------------------
2018/07/04 11:11:19 Elapsed duration: 259.846µs
2018/07/04 11:11:19 Offset: 0
2018/07/04 11:11:19 Number of candidates found: 1
2018/07/04 11:11:19 Candidates are:
2018/07/04 11:11:19 var s invalid type
2018/07/04 11:11:19 =======================================================

screen shot 2018-07-04 at 11 14 25 am

also can not prompt "builtin", it's right ?

@ramya-rao-a
Copy link

ramya-rao-a commented Jul 16, 2018

Thanks for the fix @mdempsky! I've verified that it works as intended.

@willxm Please follow the below to try the integrated fix in VS Code. I'll release an update early next week.

  • Download https://github.com/Microsoft/vscode-go/blob/master/Go-latest.vsix
  • Run code --install-extension Go-latest.vsix
  • If the above fails with Error: end of central directory record signature not found, then clone this repo, switch to branch source and use the Go-latest.vsix file
  • Reload VS Code
  • If you get a prompt to update gocode, go ahead and update it

@ramya-rao-a
Copy link

ramya-rao-a commented Jul 16, 2018

@mdempsky Any thoughts on #32? Looks like using the -source flag is the solution but that makes completions very slow. Any updates on the cache branch?

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

4 participants