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

Make JuliaFormatter ignore bind macro in notebook file #3072

Merged
merged 7 commits into from
Oct 29, 2024

Conversation

christiangnrd
Copy link
Contributor

@christiangnrd christiangnrd commented Oct 23, 2024

This is regularly the only change when I format my code/notebooks, and it gets reset whenever the notebook is saved. By telling JuliaFormatter to ignore it, it reduces noise in commits (if accidentally committed) and means I don't have to worry about formatting code I didn't write nor will I ever see.

I believe this is a good solution to #2623 as it solves the issue of files being constantly reformatted for those who use JuliaFormatter, and it does not affect those who do not. (Other than 2 extra lines in the notebook)

Closes #2623

Try this Pull Request!

Open Julia and type:

julia> import Pkg
julia> Pkg.activate(temp=true)
julia> Pkg.add(url="https://github.com/christiangnrd/Pluto.jl", rev="patch-2")
julia> using Pluto

@fonsp fonsp changed the title Make JuliaFormatter ignore bind macro Make JuliaFormatter ignore bind macro in notebook file Oct 25, 2024
@fonsp
Copy link
Owner

fonsp commented Oct 25, 2024

Nice! Can you add a comment to the code that links to https://domluna.github.io/JuliaFormatter.jl/stable/#Turn-off/on-formatting ?

@christiangnrd
Copy link
Contributor Author

@fonsp Done!

Copy link
Owner

@fonsp fonsp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to verify, did you create a new file using this Pluto version, format an old file and a new file with JF and check that the new one does not change?

@christiangnrd
Copy link
Contributor Author

christiangnrd commented Oct 25, 2024

Good call. I had done quick testing on my notebook that doesn't use the Pluto package management.

Just created a new notebook that uses @bind and it works!

@fonsp
Copy link
Owner

fonsp commented Oct 28, 2024

Hey! Actually can you put the comments inside the fake macro? That makes it more clear that it's part of the macro and not the whole file

image

It looks like JuliaFormatter still works when the comments are inside the macro

@christiangnrd
Copy link
Contributor Author

@fonsp Done and tested.

@fonsp
Copy link
Owner

fonsp commented Oct 28, 2024

Awesome! Did you also test that JuliaFormatter works for the rest of the file? i.e. that format: on also works

@christiangnrd
Copy link
Contributor Author

I did!

@fonsp fonsp merged commit e630067 into fonsp:main Oct 29, 2024
9 of 11 checks passed
@fonsp
Copy link
Owner

fonsp commented Oct 29, 2024

Awesome! Maybe you're interested in a bigger project?

Like #2691 🌟

Or research for #2781 would be really useful!

These are some Julia-only projects, but if you are also interested in using JavaScript/React then let me know!

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.

Make Pluto boilerplate formatted according to JuliaFormatter
2 participants