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

Implement signature intellisense #640

Merged
merged 13 commits into from
Dec 3, 2021
Merged

Implement signature intellisense #640

merged 13 commits into from
Dec 3, 2021

Conversation

jonatanklosko
Copy link
Member

Closes #477.

Requires Elixir 1.13

Demo

signature.mp4

Notes

The primary logic is encapsulated in SignatureMatcher, it uses the new Code.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

  • I normalized docs/info extraction into Livebook.Intellisense.Docs and cleaned up the completion stuff accordingly
  • I changed .button class to .button-base, since it was conflicting with an existing Monaco editor class.
  • Removed the Code.Fragment backport, since it should no longer be necessary when we require Elixir 1.13

Copy link
Contributor

@josevalim josevalim left a 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 jonatanklosko force-pushed the jk-signature branch 4 times, most recently from 582d9cb to a8ca119 Compare November 5, 2021 18:30
* 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>
@jonatanklosko jonatanklosko marked this pull request as ready for review December 3, 2021 20:56
@jonatanklosko jonatanklosko merged commit e2490c0 into main Dec 3, 2021
@jonatanklosko jonatanklosko deleted the jk-signature branch December 3, 2021 20:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add a signature provider
2 participants