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

x/tools/gopls: how to disable diagnostics publish? #37875

Closed
netjune opened this issue Mar 16, 2020 · 14 comments
Closed

x/tools/gopls: how to disable diagnostics publish? #37875

netjune opened this issue Mar 16, 2020 · 14 comments
Labels
Milestone

Comments

@netjune
Copy link

@netjune netjune commented Mar 16, 2020

I'm using gopls with lsp-mode in emacs. It lags too much. In the log I see that, there are too many diagnostics messages. I want to disable diagnostics and don't know how to do that.
Is there an option to control it?

@ALTree ALTree changed the title How to disable diagnostics publish? x/tools/gopls: how to disable diagnostics publish? Mar 16, 2020
@gopherbot gopherbot added this to the Unreleased milestone Mar 16, 2020
@gopherbot

This comment has been minimized.

Copy link

@gopherbot gopherbot commented Mar 16, 2020

Thank you for filing a gopls issue! Please take a look at the Troubleshooting guide, and make sure that you have provided all of the relevant information here.

@ALTree

This comment has been minimized.

Copy link
Member

@ALTree ALTree commented Mar 16, 2020

I don't use lsp-mode, but maybe this:

https://github.com/emacs-lsp/lsp-mode/blob/master/lsp-go.el#L145-L148

is what you want?

@netjune

This comment has been minimized.

Copy link
Author

@netjune netjune commented Mar 16, 2020

I don't use lsp-mode, but maybe this:

https://github.com/emacs-lsp/lsp-mode/blob/master/lsp-go.el#L145-L148

is what you want?

I have set it to nil. It had no effect. Then in lsp-mode.el I see that it is not used for gopls client. It is only used for the other two: bingo and go-langserver.

https://github.com/emacs-lsp/lsp-mode/blob/6113e321b107915375e7f3fa8e9f85242f7fc874/lsp-go.el#L87

@muirdm

This comment has been minimized.

Copy link

@muirdm muirdm commented Mar 16, 2020

I don't think there is a way to disable diagnostics. You can set (setq lsp-diagnostic-package :none) in lsp-mode, but I don't think that will stop diagnostics from being generated or sent.

Can you give more details on the lag you are seeing? How big is your workspace? Is gopls using a lot of CPU? How did you determine there are too many diagnostics? Do you have RPC debugging enabled in Emacs (printing out all the back-and-forth kills performance in Emacs)?

@netjune

This comment has been minimized.

Copy link
Author

@netjune netjune commented Mar 17, 2020

I used to use gocode with company-go in emacs before. It works well and smoothly. But it is not supported now. So I switched to lsp-mode.

I have used lsp-mode for saveral monthes. It never works smoothly. The lag includes two:

  1. There is a delay before completion menu popups.
  2. There is a delay before I can input next char.

The cpu usage just now:

  1. emacs: 99%
  2. gopls: 34%

My workspace contains about 20 files. But it imports many packages.

I have added some debug message in lsp-mode.el and see that, there are ten of more lsp messages arrived after I input one char in go-mode buffer. Only one of them is completion result. All others are diagnostics messages and most of them are not for the file I'm editing and most of them are empty.

lsp-mode has to parse all of the above messages after user inputs every char. I think this may be the cause of the lag. So I want to disable diagnostic.

Or is it possible for gopls to only publish diagnostics for the file is being edited?

@stamblerre

This comment has been minimized.

Copy link
Contributor

@stamblerre stamblerre commented Mar 17, 2020

@netjune: What version of gopls are you using (gopls version)? Diagnostics should be cached so you shouldn't be getting this many.

@netjune

This comment has been minimized.

Copy link
Author

@netjune netjune commented Mar 17, 2020

I'm using gopls 0.2.2.

golang.org/x/tools/gopls 0.2.2
    golang.org/x/tools/gopls@(devel)

The 0.3.3 crashes for one of my workspace. So I go back to 0.2.2.

@stamblerre

This comment has been minimized.

Copy link
Contributor

@stamblerre stamblerre commented Mar 17, 2020

We're not supporting gopls/v0.2.2 because future versions have significant improvements. Would you be willing to share your gopls logs for v0.3.3 so we can help investigate the issue? Details on how to capture logs can be found here: https://github.com/golang/tools/blob/master/gopls/doc/troubleshooting.md#capturing-logs.

@stamblerre stamblerre modified the milestones: Unreleased, gopls/v0.4.0 Mar 17, 2020
@netjune

This comment has been minimized.

Copy link
Author

@netjune netjune commented Mar 21, 2020

It crashes occasionally. And I don't work on that workspace now. I will do it when I go back to that workspace.

@stamblerre stamblerre modified the milestones: gopls/v0.4.0, gopls/v0.5.0 Mar 21, 2020
@netjune

This comment has been minimized.

Copy link
Author

@netjune netjune commented Mar 29, 2020

I'm using v0.3.4 now. It doesn't crash until now. Maybe the crash bug in 0.3.3 has been fixed in 0.3.4.

@netjune

This comment has been minimized.

Copy link
Author

@netjune netjune commented Mar 29, 2020

With 0.3.4 there is another problem. There are too many window/logMessage messages which make emacs lag. There are about 400 messages during one second.

See https://github.com/netjune/temp_files/blob/master/gopls-3.log

@netjune

This comment has been minimized.

Copy link
Author

@netjune netjune commented Mar 29, 2020

Beside the lag, I still want an option to turn off diagnostics.

I have a directory where I put all my small demo apps. They have names like: demo_foo.go, demo_bar.go... Each of them is a standalone app which has a main function. And they have many global variables and functions with same name. Then the diagnostics is not too usefull. I want to turn off it.

@ALTree ALTree removed the WaitingForInfo label Mar 29, 2020
@gopherbot

This comment has been minimized.

Copy link

@gopherbot gopherbot commented Mar 30, 2020

Change https://golang.org/cl/226371 mentions this issue: internal/lsp: avoid logging context cancellation

@stamblerre

This comment has been minimized.

Copy link
Contributor

@stamblerre stamblerre commented Mar 30, 2020

With 0.3.4 there is another problem. There are too many window/logMessage messages which make emacs lag. There are about 400 messages during one second.

See https://github.com/netjune/temp_files/blob/master/gopls-3.log

Thanks for reporting this! I just mailed a change that should remove those extra log lines.

Beside the lag, I still want an option to turn off diagnostics.

I have a directory where I put all my small demo apps. They have names like: demo_foo.go, demo_bar.go... Each of them is a standalone app which has a main function. And they have many global variables and functions with same name. Then the diagnostics is not too usefull. I want to turn off it.

As @muirdm said, this is not possible as a configuration through gopls, but you can try the setq lsp-diagnostic-package :none) setting. I'm going to close this issue because it's not something we will be handling in gopls itself.

@stamblerre stamblerre closed this Mar 30, 2020
gopherbot pushed a commit to golang/tools that referenced this issue Mar 31, 2020
This change adds a helper function that checks if the context is
canceled, and if so, doesn't log the error. Tried to use it everywhere
in internal/lsp where it fits, which resulted in changing a few pieces
of error handling throughout.

Updates golang/go#37875

Change-Id: I59cbc6f893e3b70cf84524d9944ff7f4b4febd78
Reviewed-on: https://go-review.googlesource.com/c/tools/+/226371
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
Reviewed-by: Heschi Kreinick <heschi@google.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
5 participants
You can’t perform that action at this time.