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

signatureHelpProvider returns empty response #985

Closed
jemag opened this issue Jul 1, 2022 · 3 comments
Closed

signatureHelpProvider returns empty response #985

jemag opened this issue Jul 1, 2022 · 3 comments
Assignees
Labels
bug Something isn't working textDocument/signatureHelp

Comments

@jemag
Copy link

jemag commented Jul 1, 2022

Server Version

v.0.28.1

Terraform Version

Terraform v0.14.10

Client Version

Neovim (NVIM v0.8.0-dev+537-gffbed8d6c)

Log Output

https://gist.github.com/cb9737660e034ef2b4430b7bf5702c45

Expected Behavior

SignatureHelpProvider capabilities returns nothing

Actual Behavior

SignatureHelpProvider returns empty response

Steps to Reproduce

  1. Open any terraform file
  2. Notice SignatureHelpProvider capability response

Notes

It seems that currently signature help is not supported (#857). However, the server currently seems to return an empty response instead of simply returning nothing.

This makes it hard for clients of the server to guess if the capability is actually supported or not. See : neovim/neovim#18939

From that issue, to add context:

See microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#textDocument_formatting for an example. That also makes me think that an empty dict must not be treated as falsy because DocumentFormattingOptions doesn't even have any properties

@radeksimko radeksimko added the bug Something isn't working label Jul 1, 2022
@radeksimko
Copy link
Member

radeksimko commented Jul 1, 2022

Hi @jemag
Thanks for the report.

This looks like an effect of the Go bindings for LSP which we leverage from gopls, or rather the unfortunate effect of these bindings being generated from TypeScript where a field/variable can freely change type while still communicating the subset of types that are supported.

/**
* The server provides signature help support.
*/
SignatureHelpProvider SignatureHelpOptions `json:"signatureHelpProvider,omitempty"`

This of course doesn't translate that well into any strongly typed language such as Go, so gopls maintainers already used interface{} (any type) to account for this in other instances, e.g.

/**
* The server provides folding provider support.
*/
FoldingRangeProvider interface{}/* bool | FoldingRangeOptions | FoldingRangeRegistrationOptions*/ `json:"foldingRangeProvider,omitempty"`

The only reason this likely doesn't affect gopls is because it already implements that signatureHelp capability, so that struct is never empty.

We could either send a patch upstream to gopls, to fix the logic which generates the Go bindings, and/or re-implement the whole ServerCapabilities struct internally.

As for a better long-term solution, LSP 3.17 finally introduced machine-readable spec. AFAIK nobody has yet tried to generate Go binding from that, but it's likely going to be much easier, cleaner and safer and it may eradicate problems like this.


The same problem likely applies to onTypeFormatting capability which we don't implement (yet)

/**
* The server provides document formatting on typing.
*/
DocumentOnTypeFormattingProvider DocumentOnTypeFormattingOptions `json:"documentOnTypeFormattingProvider,omitempty"`

@radeksimko
Copy link
Member

Signature help was implemented as part of #1077 and a number of other supporting PRs, so this should no longer be an issue. This is now part of the latest v0.31.0 release.

The other mentioned problem with onTypeFormatting is being addressed as another side effect of #1256

@github-actions
Copy link

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 25, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working textDocument/signatureHelp
Projects
None yet
Development

No branches or pull requests

3 participants