jupyter-JuliaFormatter: JuliaFormatter for Jupyter Notebook

GitHub repo GitHub - jiangzhuochi/jupyter-JuliaFormatter: JuliaFormatter for Jupyter Notebook

JuliaFormatter for Jupyter Notebook

Format Julia with JuliaFormatter in Jupyter Notebook

前置条件 pre-requisites

of course, you must have some of the corresponding packages installed:

add JuliaFormatter
add JSON

安装 Installation

jupyter nbextension install https://github.com/jiangzhuochi/jupyter-JuliaFormatter/archive/main.zip --user
jupyter nbextension enable jupyter-JuliaFormatter-main/jupyter-JuliaFormatter

功能 Features

  • a toolbar button
  • a keyboard shortcut for reformatting the current code-cell (default: Alt-F, Mac: Option-F)
  • a keyboard shortcut for reformatting whole code-cells (default: Alt-Shift-F, Mac: Option-Shift-F, Same as vscode format shortcut)

配置文件 Configuration File

Support configuration files, .JuliaFormatter.toml must be the same as the current .ipynb file is in the same directory

自定义快捷键 Customize shortcut keys

https://jupyter-contrib-nbextensions.readthedocs.io/en/latest/install.html#enabling-disabling-extensions

You can then open the nbextensions tab on the tree (dashboard/file browser) notebook page to configure nbextensions. You will have access there to a dashboard where extensions can be enabled/disabled via checkboxes. Additionally a short documentation for each extension is displayed, and configuration options are presented.

3 Likes

Hi,

This looks like a very nice tool to have.

Do these packages need to be installed in the base (@v1.8) environment? Is it possible to install them in a different shared environment and specify that to the extension somehow? I prefer to keep my base environment as empty as possible.

Hi, digital_carver:

I’m a novice in the julia language. I don’t know how to use the shared environment. If you install JSON and JuliaFormatter for each environment, I think it will work.

❯ mkdir MyProject
❯ cd .\MyProject\
❯ julia

julia> ]
(@v1.8) pkg> activate .
(MyProject) pkg> add JuliaFormatter
(MyProject) pkg> add JSON

ctrl + D

❯ jupyter notebook (or activate some_env then jupyter notebook)

The first time I used discourse, did you receive my reply? I don’t seem to quote your reply.

Thanks, I’ll try out the extension at some point and let you know how it goes.

Yeah, Discourse seems pretty smart about it - because I’m the only other person in the thread, it marked your post as a reply and notified me.