I apologize for opening an issue for this, but I was unsure how to ask a question.
Is there a method for restarting or reinitializing gopls? Often I get into a state where goals is unhappy, either from switching complex branches, or some error in another package. I can resolve this by simply restarting vim, but I'd prefer a different approach.
If there is a better way to ask questions to this community, please let me know.
Thanks for asking the question, @mnarrell. Switching branches without restarting Vim will put you in a bad state with gopls right now, but that won't always be true. I definitely recommend exiting Vim before switching branches. However, if you have problems with gopls because of some error in a package, please create issue in https://github.com/golang/go/issues so the maintainers can address the root cause.
There is not a command to explicitly restart gopls, but you do have options (ordered from most to least preferred):
GoBuildTags with any argument (e.g. :GoBuildTags '' to reset build tags or with a comma separated list of the build tags you want to use) to cause gopls to be reconfigured. I suspect this may be enough to fix the issues you're seeing.GoUpdateBinaries gopls to reinstall gopls; that will cause gopls to be restarted by vim-go.call go#lsp#Restart().call go#lsp#Exit() this isn't much better than just killing gopls.Honestly, those last two functions may change in the future and aren't currently intended for users to call explicitly.
Thanks Billie, you’re doing great work.
On Thu, Oct 24, 2019 at 7:41 AM Billie Cleek notifications@github.com
wrote:
Thanks for asking the question, @mnarrell https://github.com/mnarrell.
Switching branches without restarting Vim will put you in a bad state with
gopls right now, but that won't always be true. I definitely recommend
exiting Vim before switching branches. However, if you have problems with
gopls because of some error in a package, please create issue in
https://github.com/golang/go/issues so the maintainers can address the
root cause.There is not a command to explicitly restart gopls, but you do have
options (ordered from most to least preferred):
- execute GoBuildTags with any argument (e.g. :GoBuildTags '' to reset
build tags or with a comma separated list of the build tags you want to
use) to cause gopls to be reconfigured. I suspect this may be enough
to fix the issues you're seeing.- execute GoUpdateBinaries gopls to reinstall gopls; that will cause
gopls to be restarted by vim-go.- execute call go#lsp#Restart().
- execute call go#lsp#Exit() this isn't much better than just killing
gopls.Honestly, those last two functions may change in the future and aren't
currently intended for users to call explicitly.—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/fatih/vim-go/issues/2550?email_source=notifications&email_token=AABOFR5PEP5SXXFDLUN5JELQQGQYDA5CNFSM4JEKNPNKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOECFCDMI#issuecomment-545923505,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/AABOFR2TKP2HWVXFHNMC2WDQQGQYDANCNFSM4JEKNPNA
.
Thanks @bhcleek , just using map to call call go#lsp#Exit() manually when needed
Most helpful comment
Thanks for asking the question, @mnarrell. Switching branches without restarting Vim will put you in a bad state with
goplsright now, but that won't always be true. I definitely recommend exiting Vim before switching branches. However, if you have problems withgoplsbecause of some error in a package, please create issue in https://github.com/golang/go/issues so the maintainers can address the root cause.There is not a command to explicitly restart
gopls, but you do have options (ordered from most to least preferred):GoBuildTagswith any argument (e.g.:GoBuildTags ''to reset build tags or with a comma separated list of the build tags you want to use) to causegoplsto be reconfigured. I suspect this may be enough to fix the issues you're seeing.GoUpdateBinaries goplsto reinstallgopls; that will causegoplsto be restarted by vim-go.call go#lsp#Restart().call go#lsp#Exit()this isn't much better than just killinggopls.Honestly, those last two functions may change in the future and aren't currently intended for users to call explicitly.