jupyterlab-contrib / jupyterlab_code_formatter

A JupyterLab plugin to facilitate invocation of code formatters.
https://jupyterlab-code-formatter.readthedocs.io/
MIT License
855 stars 55 forks source link

Code formatters for other languages #24

Open jtpio opened 5 years ago

jtpio commented 5 years ago

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

ryantam626 commented 5 years ago

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

jtpio commented 5 years ago

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

Agree. Prettier can even run directly on the frontend.

SolarisYan commented 5 years ago

Agree

dev-wei commented 5 years ago

@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.

ryantam626 commented 5 years ago

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:

dev-wei commented 5 years ago

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.

ashwinvis commented 5 years ago

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.

dialvarezs commented 4 years ago

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.

ryantam626 commented 4 years ago

@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.

dialvarezs commented 4 years ago

@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.

ryantam626 commented 4 years ago

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

BexTuychiev commented 1 year ago

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!

ryantam626 commented 1 year ago

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.

marvinlenk commented 8 months ago

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.