lsp: Implement textDocument/signatureHelp for ProjectClientState::Local environment#12909
Conversation
|
We require contributors to sign our Contributor License Agreement, and we don't have @tomoikey on file. You can sign our CLA at https://zed.dev/cla. Once you've signed, post a comment here that says '@cla-bot check'. |
SignatureHelp in localtextDocument/signatureHelp in local
textDocument/signatureHelp in localtextDocument/signatureHelp in Local
textDocument/signatureHelp in LocaltextDocument/signatureHelp in Local
textDocument/signatureHelp in LocaltextDocument/signatureHelp for ProjectClientState::Local environment
textDocument/signatureHelp for ProjectClientState::Local environmenttextDocument/signatureHelp for ProjectClientState::Local environment
This comment was marked as resolved.
This comment was marked as resolved.
|
The cla-bot has been summoned, and re-checked this pull request! |
This comment was marked as resolved.
This comment was marked as resolved.
|
The cla-bot has been summoned, and re-checked this pull request! |
There was a problem hiding this comment.
Thank you, I've glanced over and left some NIT comments that are not very important.
Two more important notes I'd like to emphasize:
- the remote code seems not finished, and if that causes issues, I'd just remove this entirely for now — having the feature working in single player mode is just fine too, I can pick up the multiplayer part later (or welcome to do so here, or in a follow-up patch).
I think this direction is less important at the current PR state, and it's more beneficial to concentrate on the single player usability (my next bullet)
- This feature is amazing but lacks visibility and dynamics — after looking at the code, it seems that the only way to see the signature help is by calling a corresponding action?
I would also love to get it automatically open after a method completion is accepted, and, maybe, something else? (I'd try to see how it looks when shown for a certain completion menu item selected)
This way, people will see that there's something new added, and will be able to type and see the signature help (if it's close enough to the caret input).
For now, I'll transfer this PR to draft until we straighten the singleplayer mode, but it already looks very close to that, thanks!
…oo() occurs and auto_signature_help is true
…-> foo() occurs and auto_signature_help is false
… where markdown tests were located away from the logic
Thank you for addressing the remote mode!!! Movie2024-07-10.22.27.32.mov
Regarding the combination of settings, I agree that some patterns might be confusing. However, we need to ensure that they do not interfere with each other. Using a mathematical set theory analogy, the intersection of the set auto_signature_help and the set show_signature_help_after_completion (A ^ B) should be an empty set. If the intersection of these two setting sets is not empty, it would lead to a loss of customization (independence) of the settings. Therefore,
This way, the settings are independent and highly customizable without interfering with each other. If additional needs arise, these should be further divided independently or new independent settings should be added. Additionally, I split the modules into several parts as various concepts were mixed within a single file.
This Thursday and Friday, it is highly likely that I will not be able to allocate time due to a company event. On a side note, interactions on GitHub feel very asynchronous and inconvenient for collaborative development. |
Why not? My whole point is that by ensuring that they do not interfere, we make it less intuitive for certain languages. issue, doing
What does this chatgpt-esque phrase mean? What is the point of the behavior, described above and who would want that? I propose to rework the settings, if you find this configuration confusing. pub enum SignatureHelpPopovers {
Off,
AfterCompletionsOnly,
Everywhere
}there's a fourth variant, |
|
@SomeoneToIgnore I have no choice but to imagine what behavior the Zed team wants for Zed from your words. It is natural for ambiguity to arise when using natural language. I am not good at English. The reason I sound like ChatGPT is that I am using ChatGPT as an intermediary for communication with you. I understand that I am taking up your time due to communication issues. I apologize for that. After dinner, I plan to create a combined setting for auto_signature_help and show_signature_help_after_completion, as you suggested. However, the settings in the top right corner of the screen are toggles, so it seems they can’t represent more than three values. How would you like to handle this? pub enum SignatureHelpPopovers {
Off,
AfterCompletionsOnly,
Everywhere
}
|
But isn't I have the following ideas on the settings:
The middle ground was chosen to be "after the completions only" as something very useful feature-wise. 2 existing parameters are just fine with that logic if and But if you want to use the enum, I'd keep the toggle switching between |
I understand that you have to use your ways for translations which is fine per se, and my remark was not targeted at that part. My main problem with that phrase is how "water is wet, sun rises on the east" those words are, not moving us towards an actionable resolution of the issue, something like I've tried to do in the previous comment. The point is to identify the point of confusion, make it well usable for people and implement it without bugs, while such generic phrases bring nothing but extra confusion and the discussion bloat. That's why I'm not sure that using a less async way of communicating will help here — from my perspective, all I constantly do in this PR for a month is: coming, opening the very same pet project, clicking around a few minutes and seeing more issues, sometimes in the very same sequence of actions. I want to emphasize that I do not aim to attack or anyhow express hostility with such messages, but rather provide some feedback and attempt to highlight the issues. |
|
@SomeoneToIgnore "auto_signature_help": true,
"show_signature_help_after_completion": WHATEVER,do you mean "true", or do you want to introduce a new concept of "WHATEVER" in addition to "true" and "false"? |
There was a problem hiding this comment.
I think the first iteration is ready to be merged.
I've went on and fixed the settings myself as it's simpler than to explain it another time, hope that made it more clear.
One last thing that I noticed only recently: languages with overrides may provide multiple signatures for a single function/method.

Also, there's no other popover components such as the description.
I've laid the ground work for that, and there's a new TODO in the signature_help.rs where the data gets stripped to just one signature.
Later, somebody may follow with this up, but for now this PR is very useful for languages like Rust, thank you a lot for the heavy lifting.
Follow-up of #12909 * Fully preserve LSP data when sending it via collab, and only strip it on the client. * Avoid extra custom request handlers, and extend multi LSP server query protocol instead. Release Notes: - N/A
Follow-up of #12909 * Fully preserve LSP data when sending it via collab, and only strip it on the client. * Avoid extra custom request handlers, and extend multi LSP server query protocol instead. Release Notes: - N/A
|
This should really be enabled by default |
|
Anecdotally, it took me a long time to find this feature because I was looking for "parameter hints" or "argument hints" and didn't think to search "signature" |
+1. I ended up here while trying to figure out why this feature wasn't enabled when I typed This change actually does enable the feature by default (note I agree that we should enable it by default (this is also the standard behavior in VS Code). If users don't need the popup, they can simply press |

Closes #5155
Closes #4879
Purpose
There was no way to know what to put in function signatures or struct fields other than hovering at the moment. Therefore, it was necessary to implement LSP's
textDocument/signatureHelp.I tried my best to match the surrounding coding style, but since this is my first contribution, I believe there are various aspects that may be lacking. I would greatly appreciate your code review.
Description
When the window is displayed, the current argument or field at the cursor's position is automatically bolded. If the cursor moves and there is nothing to display, the window closes automatically.
To minimize changes and reduce the burden of review and debugging, the SignatureHelp feature is implemented only when
is_localistrue.Some
unimplemented!()macros are embedded, but rest assured that they are not called in this implementation.How to try it out
Press
cmd + i(MacOS),ctrl + i(Linux).Enable auto signature help (2 ways)
Add
"auto_signature_help": truetosettings.jsonOr
Press
Auto Signature Help. (Defaultfalse)Disable to show signature help after completion
Add
"show_signature_help_after_completion": falsetosettings.jsonMovie
2024-07-10.3.57.59.mov
Screen Shot
Release Notes: