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

The depth of auto-signature-help #11984

Open
ixxie opened this issue Nov 1, 2024 · 3 comments
Open

The depth of auto-signature-help #11984

ixxie opened this issue Nov 1, 2024 · 3 comments
Labels
A-helix-term Area: Helix term improvements C-enhancement Category: Improvements

Comments

@ixxie
Copy link

ixxie commented Nov 1, 2024

I like the auto-signature-help feature, but it currently has a major drawback: it's applied regardless of how deep you are in the function.

Consider the scenario where you pass a large object to the function; this is common in configuration functions, like defineConfig from Vite:
image
As you can imagine, this becomes incredible annoying: the signature help is continuously displayed as you edit the configuration object.

Having auto-signature-help be shallow could resolve it: if the cursor is immediately inside the function signature, you render the help, but if it is deeper, e.g. inside an object nested inside the signature, than it is not rendered.

If this is usecase dependent it could be a configuration option, but I would argue it should be shallow by default.

My be related to #9144 and #5827 but I am not sure how those are scoped.

@kirawi
Copy link
Member

kirawi commented Dec 23, 2024

I realize this was brought up on Matrix a few years ago but never in an issue to the best of my memory, but we wanted to implement VSCode's algorithm (which I believe is fairly trivial) to determine when to open the signature-help menu. Working in Python made me understand how horrible the system currently is.

https://github.com/microsoft/vscode/blob/151ef3514e76629f4e7bf3951439b1e0dae0a6e5/src/vs/editor/contrib/parameterHints/browser/parameterHints.ts#L23 might be it

@kirawi kirawi added C-enhancement Category: Improvements A-helix-term Area: Helix term improvements labels Dec 23, 2024
@kirawi
Copy link
Member

kirawi commented Dec 23, 2024

On second thought, we probably really don't need to care what VSCode does as long as we ensure that the behavior is predictable and unobtrusive.

@kirawi kirawi added E-easy Call for participation: Experience needed to fix: Easy / not much E-good-first-issue Call for participation: Issues suitable for new contributors labels Dec 23, 2024
@samuelselleck
Copy link
Contributor

Looking at the VSCode implementation it seems to rely on LSP trigger reasons/trigger characters. The current implementation of signature help in helix doesn't seem to provide the LSP with this information (see SignatureHelpContext missing at helix-lsp/src/client.rs:1085 in the function text_document_signature_help). I'm guessing that this is how the LSP can make the call to not to show signature help in nested objects based on SignatureHelpTriggerKind and document position.

I'm not sure how well this maps to modal editors - I personally like that signature help shows up when entering insert mode. Maybe it would be possible to make "enter insert mode" behave as a "virtual" trigger character? Not very familiar with the LSP spec and have no idea if that is reasonable.

I looked at how it could be approached from the client side as well using tree-sitter (checking the node depth compared to the "function argument" parent node, and variants). The problem with this is that signature help is provided for other types as well (for example rust structs), and the grammar name for a function can vary between languages. It might be possible to use this approach by introducing language specific config for "tree sitter nodes that are treated as signature help roots", but this doesn't feel very robust.

@kirawi kirawi removed E-easy Call for participation: Experience needed to fix: Easy / not much E-good-first-issue Call for participation: Issues suitable for new contributors labels Jan 24, 2025
@kirawi kirawi marked this as a duplicate of #12643 Jan 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-helix-term Area: Helix term improvements C-enhancement Category: Improvements
Projects
None yet
Development

No branches or pull requests

3 participants