-
Notifications
You must be signed in to change notification settings - Fork 69
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
Empty style for strictly opt-in functionality #561
Comments
it's possible to have a style that does this seems similar to #559 (comment) but maybe even more extreme? |
Yea I guess that is similar. Something that only does things that are not contriversial at all, perhaps just remove trailing whitespace etc. |
minimal still does something: @@ -619,8 +623,8 @@ NamedTuple{names}(args::Tuple) where {names} = NamedTuple{names,typeof(args)}(ar
using .Intrinsics: sle_int, add_int
-eval(Core, :(NamedTuple{names,T}(args::T) where {names, T <: Tuple} =
- $(Expr(:splatnew, :(NamedTuple{names,T}), :args))))
+eval(Core, :(NamedTuple{names,T}(args::T) where {names,T<:Tuple} =
+ $(Expr(:splatnew, :(NamedTuple{names,T}), :args))))
@@ -660,157 +664,157 @@ function checked_trunc_uint(::Type{To}, x::From) where {To,From}
y
end
-toInt8(x::Int8) = x
-toInt8(x::Int16) = checked_trunc_sint(Int8, x)
-toInt8(x::Int32) = checked_trunc_sint(Int8, x)
-toInt8(x::Int64) = checked_trunc_sint(Int8, x)
-toInt8(x::Int128) = checked_trunc_sint(Int8, x)
-toInt8(x::UInt8) = bitcast(Int8, check_top_bit(Int8, x))
-toInt8(x::UInt16) = checked_trunc_sint(Int8, check_top_bit(Int8, x))
-toInt8(x::UInt32) = checked_trunc_sint(Int8, check_top_bit(Int8, x))
-toInt8(x::UInt64) = checked_trunc_sint(Int8, check_top_bit(Int8, x))
-toInt8(x::UInt128) = checked_trunc_sint(Int8, check_top_bit(Int8, x))
+toInt8(x::Int8) = x
+toInt8(x::Int16) = checked_trunc_sint(Int8, x)
+toInt8(x::Int32) = checked_trunc_sint(Int8, x)
+toInt8(x::Int64) = checked_trunc_sint(Int8, x)
+toInt8(x::Int128) = checked_trunc_sint(Int8, x)
+toInt8(x::UInt8) = bitcast(Int8, check_top_bit(Int8, x))
+toInt8(x::UInt16) = checked_trunc_sint(Int8, check_top_bit(Int8, x))
+toInt8(x::UInt32) = checked_trunc_sint(Int8, check_top_bit(Int8, x))
+toInt8(x::UInt64) = checked_trunc_sint(Int8, check_top_bit(Int8, x))
+toInt8(x::UInt128) = checked_trunc_sint(Int8, check_top_bit(Int8, x))
+toInt8(x::Bool) = and_int(bitcast(Int8, x), Int8(1)) |
MinimalStyle currently uses the indentation style of one of the other styles. So it will cause different indentation than the source in a few settings. The second example you linked could be fixed with setting |
then that will align assignments that were originally not aligned, we need a the motivation here is in order to adopt formatting as part of the Julia repo's CI, we need a "do nothing" state, and gradually enable things as people see fit |
another thing I can't seem to turn off: diff --git a/base/Base.jl b/base/Base.jl
index 63728fdba3..ed7a09627d 100644
--- a/base/Base.jl
+++ b/base/Base.jl
@@ -22,8 +22,12 @@ ccall(:jl_set_istopmod, Cvoid, (Any, Bool), Base, is_primary_base_module)
# The @inline/@noinline macros that can be applied to a function declaration are not available
# until after array.jl, and so we will mark them within a function body instead.
-macro inline() Expr(:meta, :inline) end
-macro noinline() Expr(:meta, :noinline) end
+macro inline()
+ Expr(:meta, :inline)
+end
+macro noinline()
+ Expr(:meta, :noinline)
+end |
more cases of can't stop formatter from doing something ## Concatenation ##
eltypeof(x) = typeof(x)
@@ -1595,15 +1565,15 @@ typed_vcat(::Type{T}) where {T} = Vector{T}()
typed_hcat(::Type{T}) where {T} = Vector{T}()
## cat: special cases
-vcat(X::T...) where {T} = T[ X[i] for i=1:length(X) ]
-vcat(X::T...) where {T<:Number} = T[ X[i] for i=1:length(X) ]
-hcat(X::T...) where {T} = T[ X[j] for i=1:1, j=1:length(X) ]
-hcat(X::T...) where {T<:Number} = T[ X[j] for i=1:1, j=1:length(X) ]
+vcat(X::T...) where {T} = T[X[i] for i = 1:length(X)]
+vcat(X::T...) where {T<:Number} = T[X[i] for i = 1:length(X)]
+hcat(X::T...) where {T} = T[X[j] for i = 1:1, j = 1:length(X)]
+hcat(X::T...) where {T<:Number} = T[X[j] for i = 1:1, j = 1:length(X)] |
it should align that s
no way to turn that off atm |
this one should work with align_assignment = true https://github.com/domluna/JuliaFormatter.jl/blob/master/test/options.jl#L1180-L1187 |
there are codes that were not aligned, the point is I think we want to automate the pipeline that does literally nothing (or almost), then we can turn one thing on at a time |
yeah ic, right now there's no mode which does nothing. It should be doable since we keep track of the positioning of everything in the original source but hasn't been a large priority (at least for me). It might be pretty involved as well. |
Just chiming in: I think that having a way to start from a no-op mode and then enable features one-by-one would be great to have in my opinion. For a larger project it can be a little scary to reformat everything in one go, so having control over it could help with the adoption of JuliaFormatter for existing packages and projects. |
Yeah exactly, I think I read something a while back about start automation by writing an automatic (but runnable) no-op script/CI, which is what I'm going after here |
So I think as it stands the FST as enough information to be able to do nothing - since it tracks the line offset of every "token". What might be easier, at least from the perspective of gradual formatting is to leverage the no format block feature already present so that only the git diff sections are formatted and the rest is printed out as is. |
Is there a way to configure JuliaFormatter to only do things I specify? I am thinking of something like an "empty" style which makes every change opt-in. Example config
which would only change
=
toin
, but nothing else.The text was updated successfully, but these errors were encountered: