livebook-dev / livebook

Automate code & data workflows with interactive Elixir notebooks
https://livebook.dev
Apache License 2.0
4.81k stars 413 forks source link

Support formatter options #2702

Open jonatanklosko opened 2 months ago

jonatanklosko commented 2 months ago

Currently Livebook formats the code without respecting any plugins or formatter options. We could add Kino.formatter_options(...) with options matching .formatter.exs. The logic would be similar to the mix format task. In order to handle :import_deps, we would need to traverse the dependencies and read their .formatter.exs. There is no public API to do this for the Mix.install/1 project, but we could possibly make Mix.in_install_dir/1 public in Elixir.

For now this issue is mostly to track interest and use cases.

Also see prior discussion in #1212.

zachallaun commented 2 months ago

I'd like and would use this. Especially useful for libraries with macros usually used without parens that want to write documentation with Livebook. (Edit: I see this is the primary consideration talked about in the linked past discussion was well 😄)

LostKobrakai commented 2 months ago

I was the trigger for this issue over on slack a few days ago. I've been running into this with heex for building svg visualization in livebook, where the elixir code would format, but the heex markup wouldn't. Especially with tools like phoenix_playground components might become something more people build in livebook as well, even though this wasn't my usecase.