-
Notifications
You must be signed in to change notification settings - Fork 17.7k
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: add support for more code lenses #36787
Comments
@hyangah suggested that we could use code lenses to offer the user an option to start a local godoc server. |
Another code lens feature VS Code Go provides is 'run test' and 'debug test' code actions. They are currently through a separate |
I'm keen to give the |
That's awesome @martskins - please do send a changelist when you're ready :) I think the show message is fine for now (we do something similar for Ideally, we'd be able to write to the VS Code output channel like the extension does, but LSP doesn't support that yet. Looks like @marwan-at-work, who wrote the |
Running tests is tricker than running In
The problem with the gopls window-output is twofold:
So from VSCode's perspective, using that will actually be a much less friendly user experience than what's currently in place until the proposal Rebecca mentioned is accepted and implemented in clients. I believe it was mentioned to me at some point that you can do custom requests and each client will have to implement that custom request, so that's another route but im not familiar with it :) |
For VS Code, there is also 'debug test' code lens that works closely with the debugger. I expect that will be hard to delegate to |
As a vim user I would say that I would find it useful to be able to run tests delegating it to gopls, even if it doesn't output the failure message. I understand that this is far from ideal though. But being able to at least check that the tests still pass is a pretty decent addition. The idea to use VS Code (or vim, or you name it) itself to run the tests sounds to me as a decent compromise until that proposal is accepted though. |
@martskins in VSCode, we already have this implemented on the plugin-level and it uses output channels appropriately. So it would be a step backwards in terms of user experience in VSCode. Would it be possible for gopls to toggle this on/off so that vim users can turn it on and VSCode users can turn it off? Preferably automagically 😄 |
Yeah, the plan is to have this feature be off by default until it reaches parity with VS Code. (See more detail in @findleyr's comment on https://golang.org/cl/231959). |
We have many lenses now. What's left to do? |
I would say that the remaining work is to check which code lenses VS Code supports, so that we can try to reach feature parity. Also, we could add the code lens @hyangah suggested in #36787 (comment). |
vscode-go plans to utilize gopls's codelens by replacing the commands List of codelenses currently offered by vscode-go. (@mcjcloud)
Codelenses with open feature requests
|
Change https://golang.org/cl/245358 mentions this issue: |
The "debug test" and "debug benchmark" code lens will be available with |
This CL adds a "debug test" and "debug benchmark" codelens to the intercepted lenses from gopls. Additionally, a fix is included for finding the function name argument in the arguments that come from gopls. Updates golang/go#36787 Change-Id: I1a109902bbee25ecb9bbf4ae1c8d9af1b6d2fa2f Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/245358 Run-TryBot: Hyang-Ah Hana Kim <[email protected]> TryBot-Result: kokoro <[email protected]> Reviewed-by: Hyang-Ah Hana Kim <[email protected]>
Change https://golang.org/cl/246017 mentions this issue: |
This CL adds a code lens to run all benchmarks in a file. Additionally, it updates the test command handler to better support both tests and benchmarks. Updates golang/go#36787 Change-Id: I6e90460f7d97607f96c263be0754537764bd0052 Reviewed-on: https://go-review.googlesource.com/c/tools/+/246017 Run-TryBot: Robert Findley <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Robert Findley <[email protected]>
Can add "which interfaces are implemented" code lens? 0 references | impl Writer
func (devNull) Write(p []byte) (int, error) {
return len(p), nil
} |
I'd love to see a code lense to similar to guru's freevars command. |
rust-analyzer has already a good support on codelens, it'll be good to see it lands in gopls as it's super useful. rust-analyzer codelens references/implementations with codelsn info provided by rust-analyzer (calculated based on cursor position) , I can easily debug rust test item in vim using vimspector and test debug currently it's a pain to debug go in neovim |
This feature will be in gopls/v0.16, using gopls' own lightweight godoc server.
This feature will be in gopls/v0.16, though as a Code Action with a web UI, not a Code Lens. The remaining code lenses suggested here are all variations of "run/debug this main/test/benchmark". I'm going to assert that debugging is a bigger project and should have its own issues. As for "run test/bench", we already have a code lens for that, though it's off by default because VS Code provides a superior client-side test UX. For other editors, the main obstacle to using the "run test" command is that there is no uniform way for clients to know that the progress messages from the command form a stdout/stderr stream that should be redirected to a terminal-like buffer. See discussion (in the context of Emacs+Eglot, but the ideas generalize) at joaotavora/eglot#1402. Personally I find code lenses to be a very distracting UX, and we've been discussing relegating most of gopls' current lenses to code actions. For example, Toggle GC Details flips a bit in the server that causes it to display diagnostic annotations containing information about compiler optimization decisions. Why would anyone want a Toggle GC Details code lens to appear in every source file, just for the 1% percent of the time they are thinking about microoptimizations? It should be a Code Action in a menu that is there when you need it but unobtrusive when you (mostly) don't. So I'm inclined to say that ideally, the net change in Code Lenses should be negative. not positive. Some features, such as #56695 (if only we knew how to implement it efficiently), do perhaps make sense as code lenses, though they could also be expressed as inlay hints. Any objections to closing this issue? |
What role will the web UI have? How will something like Vim on a terminal use that? |
There are a number of useful features we can offer though a browser that we can't realistically squeeze into LSP itself, at least not yet. In the future, I would love for LSP extensions enable us to:
The web UX isn't ideal but a large majority of users run on windowing environments (though not all of them love to switch windows). If you're running in a terminal over ssh then it may be possible to proxy the showDocument(URI) requests to a local web browser. If you're not using windowing at all (e.g. linux console), then unfortunately the web features won't be of much use. |
We should support the
textDocument/codeLens
request type.The VS Code Go extension has a number of code lenses we could add as a starting point.
See microsoft/vscode-go#3003.
The text was updated successfully, but these errors were encountered: