Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gopls functionality doesn't when GOPATH should be detected #2254

Closed
dhduvall opened this issue May 2, 2019 · 3 comments · Fixed by #2255
Closed

gopls functionality doesn't when GOPATH should be detected #2254

dhduvall opened this issue May 2, 2019 · 3 comments · Fixed by #2255

Comments

@dhduvall
Copy link
Contributor

dhduvall commented May 2, 2019

What did you do? (required. The issue will be closed when not provided.)

I have let g:go_autodetect_gopath = 1 in my ~/.vimrc, which does a fine job of figuring out what $GOPATH should be set to in my workspace. Then I use one of the functions that uses gopls, such as autocomplete.

The issue seems to be that the BufEnter autocmd that sets $GOPATH based on the autodetected value runs after gopls is launched (from the FileType autocmd in the vim-go augroup, if I'm reading this correctly). If I start vim with $GOPATH already set correctly, everything seems to work correctly.

Perhaps I need to move away from using g:go_autodetect_gopath, but I'm not sure what mechanism I'd use to set $GOPATH (I don't want or need to set it generally outside vim, and it's potentially different for different workspaces).

What did you expect to happen?

Get correct autocomplete results.

What happened instead?

Get back nothing. :messages shows

vim-go: [completion] FAIL
vim-go: no matches

Configuration (MUST fill this out):

  • vim-go version:
    3e9a292

  • vimrc you used to reproduce (use a minimal vimrc with other plugins disabled; do not link to a 2,000 line vimrc):

  • Vim version (first three lines from :version):

VIM - Vi IMproved 8.1 (2018 May 18, compiled Dec 07 2018 22:08:48)
Included patches: 1-549
Modified by [email protected]
  • Go version (go version):
    1.12.4

  • Go environment (go env):

@bhcleek
Copy link
Collaborator

bhcleek commented May 2, 2019

Thank you for the report @dhduvall . This may be a fairly easy fix. I'll get to it as soon as I can, but there are some caveats that might complicate some use cases.

FWIW, I use https://direnv.net/ to manage these kinds of things so that even go build at the commandline will work.

bhcleek added a commit to bhcleek/vim-go that referenced this issue May 2, 2019
@bhcleek bhcleek changed the title gopls functionality doesn't work without $GOPATH set gopls functionality doesn't when GOPATH should be detected May 2, 2019
@bhcleek
Copy link
Collaborator

bhcleek commented May 2, 2019

Does #2255 resolve this for you?

@dhduvall
Copy link
Contributor Author

dhduvall commented May 2, 2019

Yes, it does; thank you!

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

Successfully merging a pull request may close this issue.

2 participants