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

Add JuliaFormatter plugin #412

Merged
merged 6 commits into from
Aug 7, 2023
Merged

Add JuliaFormatter plugin #412

merged 6 commits into from
Aug 7, 2023

Conversation

gdalle
Copy link
Collaborator

@gdalle gdalle commented Jul 28, 2023

Add a JuliaFormatter plugin which takes a style keyword argument and constructs a .JuliaFormatter.toml file using only the style choice (it's up to the user to customize it further).

This sets the style of automatic formatting for JuliaFormatter.jl, and thus also for the VSCode extension.

Solves #324

@codecov
Copy link

codecov bot commented Jul 28, 2023

Codecov Report

Merging #412 (f3e53e7) into master (2aa4f9b) will decrease coverage by 0.89%.
Report is 1 commits behind head on master.
The diff coverage is 58.82%.

@@            Coverage Diff             @@
##           master     #412      +/-   ##
==========================================
- Coverage   94.45%   93.56%   -0.89%     
==========================================
  Files          22       23       +1     
  Lines         667      684      +17     
==========================================
+ Hits          630      640      +10     
- Misses         37       44       +7     
Files Changed Coverage Δ
src/PkgTemplates.jl 100.00% <ø> (ø)
src/plugin.jl 98.38% <ø> (ø)
src/plugins/formatter.jl 58.82% <58.82%> (ø)

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@gdalle gdalle mentioned this pull request Jul 28, 2023
Copy link
Collaborator

@nickrobinson251 nickrobinson251 left a comment

Choose a reason for hiding this comment

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

Apart from changing the default, i think this looks great! please could you also increment the version number in Project.toml? thanks!

src/plugins/juliaformatter.jl Outdated Show resolved Hide resolved
@gdalle
Copy link
Collaborator Author

gdalle commented Jul 31, 2023

This is ready!


function view(p::JuliaFormatter, t::Template, pkg::AbstractString)
d = Dict{String,String}()
if p.style == "nostyle"
Copy link
Collaborator

Choose a reason for hiding this comment

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

why not use nothing for this?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

because it is not a String, and for the interactive menu it seemed easier if all the entries were strings

Copy link
Collaborator

Choose a reason for hiding this comment

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

how about just the empty string ""?

@gdalle
Copy link
Collaborator Author

gdalle commented Jul 31, 2023

Also solves #328

For now the BlueStyle plugin is separate from the JuliaFormatter one, perhaps we should deprecate it and add a generic code style badge based on the JuliaFormatter style?

@nickrobinson251
Copy link
Collaborator

thanks, again!

@gdalle
Copy link
Collaborator Author

gdalle commented Aug 7, 2023

You're welcome! Good for merging?

@@ -33,6 +33,7 @@ export
Git,
GitHubActions,
GitLabCI,
JuliaFormatter,
Copy link
Collaborator

Choose a reason for hiding this comment

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

one problem with this that i just thought of, is that if JuliaFormatter.jl is loaded (e.g. in startup.jl ), then we'll see

julia> using PkgTemplates
WARNING: using PkgTemplates.JuliaFormatter in module Main conflicts with an existing identifier.

...do people put JuliaFormatter in their startup?

Do you think this is an issue?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm not a regular JuliaFormatter user so i've no idea if this name conflict is going to be a common issue for users

but there's only one formatter for Julia... so i wonder if we should just name this plugin Formatter (or JuliaFormat or some such) to avoid the name conflict?

(I guess we don't have this issue with Documenter as it's usually only loaded in a separate docs/ env)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think renaming to Formatter is a good idea, I have JuliaFormatter in my startup

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done in the next commit

@gdalle
Copy link
Collaborator Author

gdalle commented Aug 7, 2023

Not sure how to deprecate the BlueStyle badge? Can probably be done in a separate PR

@nickrobinson251
Copy link
Collaborator

if you bump the version we can make a release straight away :)

@gdalle
Copy link
Collaborator Author

gdalle commented Aug 7, 2023

Done!

@gdalle
Copy link
Collaborator Author

gdalle commented Aug 7, 2023

Only bumped the patch version because I believe the change is nonbreaking

In particular, a package may set version = "0.2.4" when it has feature additions compared to 0.2.3 as long as it remains backward compatible with 0.2.0. See also The version field.

https://pkgdocs.julialang.org/v1/compatibility/#compat-pre-1.0

@nickrobinson251 nickrobinson251 merged commit ecdeffe into JuliaCI:master Aug 7, 2023
11 of 13 checks passed
@gdalle gdalle deleted the juliaformatter_plugin branch August 7, 2023 13:03
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.

2 participants