-
Notifications
You must be signed in to change notification settings - Fork 423
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
Implement signature intellisense #640
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jonatanklosko
force-pushed
the
jk-signature
branch
from
October 25, 2021 17:15
5824793
to
2a07798
Compare
jonatanklosko
force-pushed
the
jk-signature
branch
from
October 25, 2021 17:16
2a07798
to
3cd669d
Compare
josevalim
reviewed
Oct 25, 2021
josevalim
approved these changes
Oct 25, 2021
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.
Just some minor comments and ship it!
EDIT: Actually, don't ship it, we need to wait until v1.13! :D
jonatanklosko
force-pushed
the
jk-signature
branch
from
October 26, 2021 11:42
ab217c4
to
5dc9c2c
Compare
jonatanklosko
force-pushed
the
jk-signature
branch
4 times, most recently
from
November 5, 2021 18:30
582d9cb
to
a8ca119
Compare
* Add editor settings form * Add configuration for intellisense defaults * Read fresh settings when editor mounts * Scope attribute names * Fix disabled button styling * Simplify signature box and enable by default * Split settings into system and user sections * Update lib/livebook_web/live/settings_live.ex Co-authored-by: José Valim <jose.valim@dashbit.co> * Update lib/livebook_web/live/settings_live.ex Co-authored-by: José Valim <jose.valim@dashbit.co> Co-authored-by: José Valim <jose.valim@dashbit.co>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Closes #477.
Requires Elixir 1.13
Demo
signature.mp4
Notes
The primary logic is encapsulated in
SignatureMatcher
, it uses the newCode.Fragment.container_cursor_to_quoted
. It handles pipes, imports, aliases, captured remote functions and anonymous functions. It also normalizes signatures for Erlang functions based on spec annotations if available.Once the signature box pops up Monaco makes new requests very frequently (pretty much any keystroke, cursor movement), so I added a simple heuristic to reuse the last response (moving from cursor position to the closest comma/parenthesis and checking if the the resulting prefix is the same as before). Also, we don't want to send all the code, yet we want to support multiline calls, so I used another heuristic to send relevant lines (taking the lines with unclosed parenthesis).
Also
Livebook.Intellisense.Docs
and cleaned up the completion stuff accordingly.button
class to.button-base
, since it was conflicting with an existing Monaco editor class.Code.Fragment
backport, since it should no longer be necessary when we require Elixir 1.13