jupyterlab_code_formatter icon indicating copy to clipboard operation
jupyterlab_code_formatter copied to clipboard

Code formatters for other languages

Open jtpio opened this issue 5 years ago • 14 comments

It would be interesting to make this extension able to format code written in other languages than Python, by:

  • showing the right formatter to the user based on the file type (related to #4)
  • running the formatters in a subprocess if they are not usable via Python imports directly

jtpio avatar May 07 '19 16:05 jtpio

Indeed, the whole package is built with this in mind but personally I don't use anything other than Python with jupyterlab.

I think writing something for Priettier or Julia probably make sense as a first step

ryantam626 avatar May 07 '19 17:05 ryantam626

I think writing something for Priettier or Julia probably make sense as a first step

Agree. Prettier can even run directly on the frontend.

jtpio avatar May 07 '19 18:05 jtpio

Agree

SolarisYan avatar Jul 13 '19 05:07 SolarisYan

@ryantam626

Ryan, I am thinking to add a simple enhancement for R code, as R is commonly used stats language.

The idea is really simple as below:

  1. Create an R bash cmd script to include R package called formatR
  2. Format the cell code by calling this R script and turn back results to Juypter cell. PS: I guess the idea can be applied for Julia as well.

And this solution requires R runtime installed on the client machine, should be working perfectly on both Mac and Linux. For Windows, I probably need to come up with a cmd script other than asking the user to install Cygwin.

Please let me know your thought.

dev-wei avatar Aug 01 '19 17:08 dev-wei

I think the general idea is correct :+1:

I have tinkered with formatR a while back but never got around to finishing it, let me know if you need any help :smile:

ryantam626 avatar Aug 01 '19 18:08 ryantam626

It's good to hear back from you.

I am going to create a new issue later for PR and tracking purposes. I appreciate your offer for help too.

dev-wei avatar Aug 01 '19 22:08 dev-wei

It would be nice to have the ability to format markdown cells. From that perspective, a general code formatter like Prettier is a great idea.

ashwinvis avatar Oct 09 '19 11:10 ashwinvis

Regarding this, there is a new formatter for Julia inspired by black and similar formatters, and it's working great right now: https://github.com/domluna/JuliaFormatter.jl

Hope support for Julia with this formatter can be added in a near future. Julia, alongside Python and R is an excellent language to use in Jupyter.

dialvarezs avatar May 04 '20 15:05 dialvarezs

@dialvarezs that will take me some time to implement, I took a look into it last weekend, Julia is pretty slow while it's compiling for the first time, to provide a better UX I would need to make it compile upfront before user use it for formatting.

ryantam626 avatar May 11 '20 08:05 ryantam626

@ryantam626 yes, you're right. Julia is a great language but has that issue of the precompilation time. If the formatter is executed without precompilation every time, it would be very slow indeed. Anyways, hope you can look into it.

And btw, great work with your extension!!! It's one of my fav jupyterlab extensions.

dialvarezs avatar May 11 '20 18:05 dialvarezs

@dialvarezs rest assured I am indeed looking at this :+1: Also thanks for your kind words :smile:

ryantam626 avatar May 12 '20 15:05 ryantam626

Hey, @ryantam626

Thanks for the awesome extension. I recommend it to anyone I can.

Is there any news for Julia support? That would be highly appreciated!

BexTuychiev avatar Jan 07 '23 15:01 BexTuychiev

Hi, @BexTuychiev

Sorry for the late reply, I haven't given this project much love, I just kinda lost steam over the years as I got increasingly burnt out, but lately I have gotten a second wind (perhaps only for a brief period...)

Is there any news for Julia support?

No, not yet, FWIW I am in middle to a big refactor for the project (mostly due to the evolution of jupyterlab's plugin tooling), additional formatters support would be one of the things I can look at after that.

Without the the refactor, the development envrionment for this plugin is just nightmare-ish to use, so that is currently trumping all tasks.

ryantam626 avatar May 05 '23 08:05 ryantam626

I would also be super interested in Julia, the language has made some significant advantages in terms of precompile times as well, so maybe the earlier concerns are not necessarily a problem anymore by now.

marvinlenk avatar Mar 08 '24 16:03 marvinlenk