-
-
Notifications
You must be signed in to change notification settings - Fork 791
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
LST: Add argument names to function completions #3308
Conversation
As discussed in #3295 cc https://github.com/Olian04 https://github.com/movva-gpu |
Actually, there's a bug : it doesn't work for std lib functions. I'm investigating... |
I agree, it's better like this already |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What a cool PR!!
Judging the by the tests this PR reintroduces the duplication bug we just fixed by removing the text edits. We must continue to use that API, or a different solution must be found. The maintainers of the protocol told us we should use the text edit API so I believe that to be the best approach.
If it does not introduce the issue we need tests to demonstrate how that is the case. I think there's tests missing for the new functionality too?
Does this PR also cover my final gripe with the previous PR?
fn some_func(key, val, cb) -> String { todo }
fn consumer(cb: fn(a, b, c) -> String) { todo }
consumer(some_func) // <- should not include any args nor parentheses |
Yes I'm unsure myself how we can identify when to safely add parens to function calls. I wouldn't want the programmer to have to remove them. |
Maybe we can have this feature be a code action instead? That way users can trigger it when it makes sense and not have to remove anything for most cases? |
Yes, that make sense, let me see how other languages do that. |
Update:
Full demo (video): |
@lpil I believe it can be resolved without "text_edit" (I used |
Rust doesn't practically have higher order functions in this way, so it is not a problem. How about instead for this feature is instead of adding parens and placeholder variables names automatically we instead complete the function name without parens, and then when they add parens we show in a tooltip the documentation, types, etc of each argument as they are added. This keeps the programmer in full control, does not add invalid variables to the code, doesn't use the internal names in external code, and the behaviour is uncontroversial. Concurrently we can in the github issue we can discuss what heuristics would be appropriate to decide when (if ever) to add parens. I'm currently leaning towards never adding them as always adding them would mean doing the wrong thing half the time, and conditionally adding them means the programmer cannot operate purely by muscle memory and instead must pause to see if parens have been added or not before knowing how to continue typing. |
Let me close this and let me experiment further with your proposal |
Changes:
before (video)
https://github.com/gleam-lang/gleam/assets/830536/26e9b25a-3c9b-41b6-85ac-c02a4409ec7d
after (video)
https://github.com/gleam-lang/gleam/assets/830536/89cbbceb-93f8-4912-a56b-785b2bd08dbb
gifs